@cloud-ru/ds-uikit-product-page-layout 2.3.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.
|
@@ -10,6 +10,7 @@ const adaptive_1 = require("@cloud-ru/ds-adaptive");
|
|
|
10
10
|
const button_1 = require("@cloud-ru/ds-button");
|
|
11
11
|
const system_1 = require("@cloud-ru/ds-icons/interface/system");
|
|
12
12
|
const list_1 = require("@cloud-ru/ds-list");
|
|
13
|
+
const modal_1 = require("@cloud-ru/ds-modal");
|
|
13
14
|
const tooltip_1 = require("@cloud-ru/ds-tooltip");
|
|
14
15
|
const uikit_product_quota_1 = require("@cloud-ru/ds-uikit-product-quota");
|
|
15
16
|
const utils_1 = require("@cloud-ru/ds-utils");
|
|
@@ -22,6 +23,9 @@ const utils_2 = require("./utils");
|
|
|
22
23
|
function MobileActionsBase({ items, maxVisibleItems }) {
|
|
23
24
|
const containerRef = (0, react_2.useRef)(null);
|
|
24
25
|
const [isOpen, setIsOpen] = (0, react_2.useState)(false);
|
|
26
|
+
const [openQuotaIndex, setOpenQuotaIndex] = (0, react_2.useState)();
|
|
27
|
+
const activeAction = openQuotaIndex === undefined ? undefined : items[openQuotaIndex];
|
|
28
|
+
const openQuota = activeAction?.variant === constants_2.BUTTON_TYPE.Quota ? activeAction : undefined;
|
|
25
29
|
const availableItems = (0, react_2.useMemo)(() => items.filter(item => !item.hidden), [items]);
|
|
26
30
|
const { visibleItems, hiddenItems } = (0, utils_1.useDynamicList)({
|
|
27
31
|
parentContainerRef: containerRef,
|
|
@@ -32,9 +36,9 @@ function MobileActionsBase({ items, maxVisibleItems }) {
|
|
|
32
36
|
if (!(0, utils_2.hasVisibleActions)(items)) {
|
|
33
37
|
return null;
|
|
34
38
|
}
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const droplistItems =
|
|
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);
|
|
41
|
+
const droplistItems = overflowItems.reduce((acc, action) => {
|
|
38
42
|
if (action.variant === 'custom') {
|
|
39
43
|
const { asListItem } = action.render();
|
|
40
44
|
acc.push({
|
|
@@ -70,18 +74,14 @@ function MobileActionsBase({ items, maxVisibleItems }) {
|
|
|
70
74
|
break;
|
|
71
75
|
}
|
|
72
76
|
case constants_2.BUTTON_TYPE.Quota: {
|
|
73
|
-
// QuotaWidget самодостаточен (свой триггер + dropdown) — рендерим инлайн как inactive-айтем.
|
|
74
|
-
const quotaWidget = (0, jsx_runtime_1.jsx)(uikit_product_quota_1.QuotaWidget, { ...action, buttonProps: { size: 'm', fullWidth: true } });
|
|
75
77
|
acc.push({
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
},
|
|
84
|
-
],
|
|
78
|
+
content: { label: action.buttonProps?.label ?? tQuota('quotas') },
|
|
79
|
+
disabled: action.buttonProps?.disabled,
|
|
80
|
+
onClick: () => {
|
|
81
|
+
setIsOpen(false);
|
|
82
|
+
setOpenQuotaIndex(items.indexOf(action));
|
|
83
|
+
action.onWidgetOpen?.();
|
|
84
|
+
},
|
|
85
85
|
});
|
|
86
86
|
break;
|
|
87
87
|
}
|
|
@@ -124,7 +124,7 @@ function MobileActionsBase({ items, maxVisibleItems }) {
|
|
|
124
124
|
}
|
|
125
125
|
return acc;
|
|
126
126
|
}, []);
|
|
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 }) })),
|
|
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: {
|
|
128
128
|
className: styles_module_scss_1.default.button,
|
|
129
129
|
size: 'm',
|
|
130
130
|
fullWidth: true,
|
|
@@ -4,8 +4,9 @@ import { LAYOUT_TYPE, withLayoutType } from '@cloud-ru/ds-adaptive';
|
|
|
4
4
|
import { Button, VIEW } from '@cloud-ru/ds-button';
|
|
5
5
|
import { KebabSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
6
6
|
import { Droplist } from '@cloud-ru/ds-list';
|
|
7
|
+
import { ModalCustom } from '@cloud-ru/ds-modal';
|
|
7
8
|
import { Tooltip } from '@cloud-ru/ds-tooltip';
|
|
8
|
-
import { quotaLocale,
|
|
9
|
+
import { quotaLocale, QuotaWidgetContent } from '@cloud-ru/ds-uikit-product-quota';
|
|
9
10
|
import { useDynamicList } from '@cloud-ru/ds-utils';
|
|
10
11
|
import { useMemo, useRef, useState } from 'react';
|
|
11
12
|
import { TEST_IDS } from '../../constants.js';
|
|
@@ -16,6 +17,9 @@ import { hasVisibleActions } from './utils.js';
|
|
|
16
17
|
function MobileActionsBase({ items, maxVisibleItems }) {
|
|
17
18
|
const containerRef = useRef(null);
|
|
18
19
|
const [isOpen, setIsOpen] = useState(false);
|
|
20
|
+
const [openQuotaIndex, setOpenQuotaIndex] = useState();
|
|
21
|
+
const activeAction = openQuotaIndex === undefined ? undefined : items[openQuotaIndex];
|
|
22
|
+
const openQuota = activeAction?.variant === BUTTON_TYPE.Quota ? activeAction : undefined;
|
|
19
23
|
const availableItems = useMemo(() => items.filter(item => !item.hidden), [items]);
|
|
20
24
|
const { visibleItems, hiddenItems } = useDynamicList({
|
|
21
25
|
parentContainerRef: containerRef,
|
|
@@ -26,9 +30,9 @@ function MobileActionsBase({ items, maxVisibleItems }) {
|
|
|
26
30
|
if (!hasVisibleActions(items)) {
|
|
27
31
|
return null;
|
|
28
32
|
}
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const droplistItems =
|
|
33
|
+
const overflowItems = hiddenItems.concat(visibleItems.filter(action => action.variant === BUTTON_TYPE.Kebab));
|
|
34
|
+
const visibleActions = visibleItems.filter(action => action.variant !== BUTTON_TYPE.Kebab);
|
|
35
|
+
const droplistItems = overflowItems.reduce((acc, action) => {
|
|
32
36
|
if (action.variant === 'custom') {
|
|
33
37
|
const { asListItem } = action.render();
|
|
34
38
|
acc.push({
|
|
@@ -64,18 +68,14 @@ function MobileActionsBase({ items, maxVisibleItems }) {
|
|
|
64
68
|
break;
|
|
65
69
|
}
|
|
66
70
|
case BUTTON_TYPE.Quota: {
|
|
67
|
-
// QuotaWidget самодостаточен (свой триггер + dropdown) — рендерим инлайн как inactive-айтем.
|
|
68
|
-
const quotaWidget = _jsx(QuotaWidget, { ...action, buttonProps: { size: 'm', fullWidth: true } });
|
|
69
71
|
acc.push({
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
},
|
|
78
|
-
],
|
|
72
|
+
content: { label: action.buttonProps?.label ?? tQuota('quotas') },
|
|
73
|
+
disabled: action.buttonProps?.disabled,
|
|
74
|
+
onClick: () => {
|
|
75
|
+
setIsOpen(false);
|
|
76
|
+
setOpenQuotaIndex(items.indexOf(action));
|
|
77
|
+
action.onWidgetOpen?.();
|
|
78
|
+
},
|
|
79
79
|
});
|
|
80
80
|
break;
|
|
81
81
|
}
|
|
@@ -118,7 +118,7 @@ function MobileActionsBase({ items, maxVisibleItems }) {
|
|
|
118
118
|
}
|
|
119
119
|
return acc;
|
|
120
120
|
}, []);
|
|
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 }) })),
|
|
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: {
|
|
122
122
|
className: styles.button,
|
|
123
123
|
size: 'm',
|
|
124
124
|
fullWidth: true,
|