@cloud-ru/ds-uikit-product-page-layout 2.3.1-preview-93c4db1d.0 → 2.3.1-preview-ebce28cc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -20,9 +20,6 @@ const ActionView_1 = require("./ActionView");
|
|
|
20
20
|
const constants_2 = require("./constants");
|
|
21
21
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
22
22
|
const utils_2 = require("./utils");
|
|
23
|
-
function isOverflowOnly(action) {
|
|
24
|
-
return action.variant === constants_2.BUTTON_TYPE.Kebab || action.variant === constants_2.BUTTON_TYPE.Quota;
|
|
25
|
-
}
|
|
26
23
|
function MobileActionsBase({ items, maxVisibleItems }) {
|
|
27
24
|
const containerRef = (0, react_2.useRef)(null);
|
|
28
25
|
const [isOpen, setIsOpen] = (0, react_2.useState)(false);
|
|
@@ -30,18 +27,17 @@ function MobileActionsBase({ items, maxVisibleItems }) {
|
|
|
30
27
|
const activeAction = openQuotaIndex === undefined ? undefined : items[openQuotaIndex];
|
|
31
28
|
const openQuota = activeAction?.variant === constants_2.BUTTON_TYPE.Quota ? activeAction : undefined;
|
|
32
29
|
const availableItems = (0, react_2.useMemo)(() => items.filter(item => !item.hidden), [items]);
|
|
33
|
-
const measurableItems = (0, react_2.useMemo)(() => availableItems.filter(action => action.variant !== constants_2.BUTTON_TYPE.Quota), [availableItems]);
|
|
34
30
|
const { visibleItems, hiddenItems } = (0, utils_1.useDynamicList)({
|
|
35
31
|
parentContainerRef: containerRef,
|
|
36
|
-
items:
|
|
32
|
+
items: availableItems,
|
|
37
33
|
maxVisibleItems,
|
|
38
34
|
});
|
|
39
35
|
const { t: tQuota } = uikit_product_quota_1.quotaLocale.useTranslations();
|
|
40
36
|
if (!(0, utils_2.hasVisibleActions)(items)) {
|
|
41
37
|
return null;
|
|
42
38
|
}
|
|
43
|
-
const overflowItems =
|
|
44
|
-
const visibleActions = visibleItems.filter(action =>
|
|
39
|
+
const overflowItems = hiddenItems.concat(visibleItems.filter(action => action.variant === constants_2.BUTTON_TYPE.Kebab));
|
|
40
|
+
const visibleActions = visibleItems.filter(action => action.variant !== constants_2.BUTTON_TYPE.Kebab);
|
|
45
41
|
const droplistItems = overflowItems.reduce((acc, action) => {
|
|
46
42
|
if (action.variant === 'custom') {
|
|
47
43
|
const { asListItem } = action.render();
|
|
@@ -128,7 +124,7 @@ function MobileActionsBase({ items, maxVisibleItems }) {
|
|
|
128
124
|
}
|
|
129
125
|
return acc;
|
|
130
126
|
}, []);
|
|
131
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.mobileActionsWrapper, ref: containerRef, "data-test-id": constants_1.TEST_IDS.mobileActions.root, children: [droplistItems.length > 0 && ((0, jsx_runtime_1.jsx)(list_1.Droplist, { size: 'm', open: isOpen, onOpenChange: setIsOpen, items: droplistItems, children: (0, jsx_runtime_1.jsx)(button_1.Button, { className: styles_module_scss_1.default.button, view: button_1.VIEW.Outline, appearance: 'neutral', icon: (0, jsx_runtime_1.jsx)(system_1.KebabSVG, {}), size: 'm', "data-test-id": constants_1.TEST_IDS.mobileActions.trigger }) })), openQuota && ((0, jsx_runtime_1.jsxs)(modal_1.ModalCustom, { open: true, onClose: () => setOpenQuotaIndex(undefined),
|
|
127
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.mobileActionsWrapper, ref: containerRef, "data-test-id": constants_1.TEST_IDS.mobileActions.root, children: [droplistItems.length > 0 && ((0, jsx_runtime_1.jsx)(list_1.Droplist, { size: 'm', open: isOpen, onOpenChange: setIsOpen, items: droplistItems, children: (0, jsx_runtime_1.jsx)(button_1.Button, { className: styles_module_scss_1.default.button, view: button_1.VIEW.Outline, appearance: 'neutral', icon: (0, jsx_runtime_1.jsx)(system_1.KebabSVG, {}), size: 'm', "data-test-id": constants_1.TEST_IDS.mobileActions.trigger }) })), openQuota && ((0, jsx_runtime_1.jsxs)(modal_1.ModalCustom, { open: true, onClose: () => setOpenQuotaIndex(undefined), children: [(0, jsx_runtime_1.jsx)(modal_1.ModalCustom.Header, { title: tQuota('quotas'), subtitle: openQuota.projectName }), (0, jsx_runtime_1.jsx)(modal_1.ModalCustom.Body, { content: (0, jsx_runtime_1.jsx)(uikit_product_quota_1.QuotaWidgetContent, { quotas: openQuota.quotas, quotasUrl: openQuota.quotasUrl, projectName: openQuota.projectName, loading: openQuota.loading, error: openQuota.error, onRefresh: openQuota.onRefresh, canEditQuota: openQuota.canEditQuota, onIncreaseQuotaClick: openQuota.onIncreaseQuotaClick, onQuotasUrlClick: openQuota.onQuotasUrlClick, disableSorting: openQuota.disableSorting, skeletonRowCount: openQuota.skeletonRowCount, hideMobileHeader: true }) })] })), visibleActions.map((action, index) => ((0, react_1.createElement)(ActionView_1.ActionView, { ...action, key: index, commonProps: {
|
|
132
128
|
className: styles_module_scss_1.default.button,
|
|
133
129
|
size: 'm',
|
|
134
130
|
fullWidth: true,
|
|
@@ -14,9 +14,6 @@ import { ActionView } from './ActionView.js';
|
|
|
14
14
|
import { BUTTON_TYPE } from './constants.js';
|
|
15
15
|
import styles from './styles.module.css';
|
|
16
16
|
import { hasVisibleActions } from './utils.js';
|
|
17
|
-
function isOverflowOnly(action) {
|
|
18
|
-
return action.variant === BUTTON_TYPE.Kebab || action.variant === BUTTON_TYPE.Quota;
|
|
19
|
-
}
|
|
20
17
|
function MobileActionsBase({ items, maxVisibleItems }) {
|
|
21
18
|
const containerRef = useRef(null);
|
|
22
19
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -24,18 +21,17 @@ function MobileActionsBase({ items, maxVisibleItems }) {
|
|
|
24
21
|
const activeAction = openQuotaIndex === undefined ? undefined : items[openQuotaIndex];
|
|
25
22
|
const openQuota = activeAction?.variant === BUTTON_TYPE.Quota ? activeAction : undefined;
|
|
26
23
|
const availableItems = useMemo(() => items.filter(item => !item.hidden), [items]);
|
|
27
|
-
const measurableItems = useMemo(() => availableItems.filter(action => action.variant !== BUTTON_TYPE.Quota), [availableItems]);
|
|
28
24
|
const { visibleItems, hiddenItems } = useDynamicList({
|
|
29
25
|
parentContainerRef: containerRef,
|
|
30
|
-
items:
|
|
26
|
+
items: availableItems,
|
|
31
27
|
maxVisibleItems,
|
|
32
28
|
});
|
|
33
29
|
const { t: tQuota } = quotaLocale.useTranslations();
|
|
34
30
|
if (!hasVisibleActions(items)) {
|
|
35
31
|
return null;
|
|
36
32
|
}
|
|
37
|
-
const overflowItems =
|
|
38
|
-
const visibleActions = visibleItems.filter(action =>
|
|
33
|
+
const overflowItems = hiddenItems.concat(visibleItems.filter(action => action.variant === BUTTON_TYPE.Kebab));
|
|
34
|
+
const visibleActions = visibleItems.filter(action => action.variant !== BUTTON_TYPE.Kebab);
|
|
39
35
|
const droplistItems = overflowItems.reduce((acc, action) => {
|
|
40
36
|
if (action.variant === 'custom') {
|
|
41
37
|
const { asListItem } = action.render();
|
|
@@ -122,7 +118,7 @@ function MobileActionsBase({ items, maxVisibleItems }) {
|
|
|
122
118
|
}
|
|
123
119
|
return acc;
|
|
124
120
|
}, []);
|
|
125
|
-
return (_jsxs("div", { className: styles.mobileActionsWrapper, ref: containerRef, "data-test-id": TEST_IDS.mobileActions.root, children: [droplistItems.length > 0 && (_jsx(Droplist, { size: 'm', open: isOpen, onOpenChange: setIsOpen, items: droplistItems, children: _jsx(Button, { className: styles.button, view: VIEW.Outline, appearance: 'neutral', icon: _jsx(KebabSVG, {}), size: 'm', "data-test-id": TEST_IDS.mobileActions.trigger }) })), openQuota && (_jsxs(ModalCustom, { open: true, onClose: () => setOpenQuotaIndex(undefined),
|
|
121
|
+
return (_jsxs("div", { className: styles.mobileActionsWrapper, ref: containerRef, "data-test-id": TEST_IDS.mobileActions.root, children: [droplistItems.length > 0 && (_jsx(Droplist, { size: 'm', open: isOpen, onOpenChange: setIsOpen, items: droplistItems, children: _jsx(Button, { className: styles.button, view: VIEW.Outline, appearance: 'neutral', icon: _jsx(KebabSVG, {}), size: 'm', "data-test-id": TEST_IDS.mobileActions.trigger }) })), openQuota && (_jsxs(ModalCustom, { open: true, onClose: () => setOpenQuotaIndex(undefined), children: [_jsx(ModalCustom.Header, { title: tQuota('quotas'), subtitle: openQuota.projectName }), _jsx(ModalCustom.Body, { content: _jsx(QuotaWidgetContent, { quotas: openQuota.quotas, quotasUrl: openQuota.quotasUrl, projectName: openQuota.projectName, loading: openQuota.loading, error: openQuota.error, onRefresh: openQuota.onRefresh, canEditQuota: openQuota.canEditQuota, onIncreaseQuotaClick: openQuota.onIncreaseQuotaClick, onQuotasUrlClick: openQuota.onQuotasUrlClick, disableSorting: openQuota.disableSorting, skeletonRowCount: openQuota.skeletonRowCount, hideMobileHeader: true }) })] })), visibleActions.map((action, index) => (_createElement(ActionView, { ...action, key: index, commonProps: {
|
|
126
122
|
className: styles.button,
|
|
127
123
|
size: 'm',
|
|
128
124
|
fullWidth: true,
|