@cloud-ru/uikit-product-quota 3.0.2 → 3.0.3-preview-d635e8b9.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.
- package/dist/cjs/components/QuotaWidget/QuotaWidget.d.ts +1 -1
- package/dist/cjs/components/QuotaWidget/QuotaWidget.js +2 -2
- package/dist/cjs/components/QuotaWidget/components/ProjectHeader/ProjectHeader.d.ts +2 -2
- package/dist/cjs/components/QuotaWidget/components/ProjectHeader/ProjectHeader.js +2 -2
- package/dist/cjs/components/QuotaWidgetMini/QuotaWidgetMini.d.ts +1 -1
- package/dist/cjs/components/QuotaWidgetMini/QuotaWidgetMini.js +2 -2
- package/dist/cjs/components/QuotaWidgetMobile/QuotaWidgetMobile.d.ts +1 -1
- package/dist/cjs/components/QuotaWidgetMobile/QuotaWidgetMobile.js +2 -2
- package/dist/cjs/types.d.ts +1 -3
- package/dist/esm/components/QuotaWidget/QuotaWidget.d.ts +1 -1
- package/dist/esm/components/QuotaWidget/QuotaWidget.js +2 -2
- package/dist/esm/components/QuotaWidget/components/ProjectHeader/ProjectHeader.d.ts +2 -2
- package/dist/esm/components/QuotaWidget/components/ProjectHeader/ProjectHeader.js +2 -2
- package/dist/esm/components/QuotaWidgetMini/QuotaWidgetMini.d.ts +1 -1
- package/dist/esm/components/QuotaWidgetMini/QuotaWidgetMini.js +2 -2
- package/dist/esm/components/QuotaWidgetMobile/QuotaWidgetMobile.d.ts +1 -1
- package/dist/esm/components/QuotaWidgetMobile/QuotaWidgetMobile.js +2 -2
- package/dist/esm/types.d.ts +1 -3
- package/package.json +5 -5
- package/src/components/QuotaWidget/QuotaWidget.tsx +0 -2
- package/src/components/QuotaWidget/components/ProjectHeader/ProjectHeader.tsx +2 -3
- package/src/components/QuotaWidgetMini/QuotaWidgetMini.tsx +1 -2
- package/src/components/QuotaWidgetMobile/QuotaWidgetMobile.tsx +1 -2
- package/src/types.ts +1 -3
|
@@ -9,4 +9,4 @@ export type QuotaWidgetProps = WithSupportProps<QuotaWidgetPropsBase & {
|
|
|
9
9
|
/** Свойства кнопки открытия виджета */
|
|
10
10
|
buttonProps?: Pick<ButtonFunctionProps, 'size' | 'className' | 'fullWidth' | 'label' | 'appearance' | 'disabled'>;
|
|
11
11
|
}>;
|
|
12
|
-
export declare function QuotaWidget({ quotas, disableSorting, isLoading, isError, onRefresh, projectName, quotasUrl, canEditQuota,
|
|
12
|
+
export declare function QuotaWidget({ quotas, disableSorting, isLoading, isError, onRefresh, projectName, quotasUrl, canEditQuota, onIncreaseQuotaClick, onWidgetOpen, onQuotasUrlClick, buttonProps, ...props }: QuotaWidgetProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -25,7 +25,7 @@ const QuotaCardsGrid_1 = require("../../helperComponents/QuotaCardsGrid");
|
|
|
25
25
|
const ProjectHeader_1 = require("./components/ProjectHeader");
|
|
26
26
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
27
27
|
function QuotaWidget(_a) {
|
|
28
|
-
var { quotas, disableSorting, isLoading, isError, onRefresh, projectName, quotasUrl, canEditQuota,
|
|
28
|
+
var { quotas, disableSorting, isLoading, isError, onRefresh, projectName, quotasUrl, canEditQuota, onIncreaseQuotaClick, onWidgetOpen, onQuotasUrlClick, buttonProps } = _a, props = __rest(_a, ["quotas", "disableSorting", "isLoading", "isError", "onRefresh", "projectName", "quotasUrl", "canEditQuota", "onIncreaseQuotaClick", "onWidgetOpen", "onQuotasUrlClick", "buttonProps"]);
|
|
29
29
|
const { t } = (0, uikit_product_locale_1.useLocale)('Quota');
|
|
30
30
|
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
31
31
|
const handleOpenChange = (open) => {
|
|
@@ -35,7 +35,7 @@ function QuotaWidget(_a) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
const exhaustedCount = quotas.filter(item => item.remains === 0).length;
|
|
38
|
-
return ((0, jsx_runtime_1.jsx)(dropdown_1.Dropdown, Object.assign({}, props, { placement: 'bottom-end', open: isOpen, onOpenChange: handleOpenChange, content: (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.content, children: [(0, jsx_runtime_1.jsx)(ProjectHeader_1.ProjectHeader, { projectName: projectName, quotasUrl: quotasUrl, canEditQuota: canEditQuota, isError: isError, onIncreaseQuotaClick: onIncreaseQuotaClick,
|
|
38
|
+
return ((0, jsx_runtime_1.jsx)(dropdown_1.Dropdown, Object.assign({}, props, { placement: 'bottom-end', open: isOpen, onOpenChange: handleOpenChange, content: (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.content, children: [(0, jsx_runtime_1.jsx)(ProjectHeader_1.ProjectHeader, { projectName: projectName, quotasUrl: quotasUrl, canEditQuota: canEditQuota, isError: isError, onIncreaseQuotaClick: onIncreaseQuotaClick, onQuotasUrlClick: onQuotasUrlClick }), (0, jsx_runtime_1.jsx)(QuotaCardsGrid_1.QuotaCardsGrid, { quotas: quotas, disableSorting: disableSorting, isLoading: isLoading, isError: isError, onRefresh: onRefresh })] }), children: (0, jsx_runtime_1.jsx)(button_1.ButtonFunction, Object.assign({ label: t('quotas'), icon: isOpen ? (0, jsx_runtime_1.jsx)(icons_1.ChevronUpSVG, {}) : (0, jsx_runtime_1.jsx)(icons_1.ChevronDownSVG, {}), counter: exhaustedCount > 0
|
|
39
39
|
? {
|
|
40
40
|
value: exhaustedCount,
|
|
41
41
|
appearance: 'red',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QuotaWidgetPropsBase } from '../../../../types';
|
|
2
|
-
type ProjectHeaderProps = Pick<QuotaWidgetPropsBase, 'projectName' | 'canEditQuota' | 'isError' | '
|
|
2
|
+
type ProjectHeaderProps = Pick<QuotaWidgetPropsBase, 'projectName' | 'canEditQuota' | 'isError' | 'onIncreaseQuotaClick'> & {
|
|
3
3
|
quotasUrl: string;
|
|
4
4
|
onQuotasUrlClick?: () => void;
|
|
5
5
|
};
|
|
6
|
-
export declare function ProjectHeader({ projectName, quotasUrl, canEditQuota, isError, onIncreaseQuotaClick,
|
|
6
|
+
export declare function ProjectHeader({ projectName, quotasUrl, canEditQuota, isError, onIncreaseQuotaClick, onQuotasUrlClick, }: ProjectHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -12,8 +12,8 @@ const button_1 = require("@snack-uikit/button");
|
|
|
12
12
|
const typography_1 = require("@snack-uikit/typography");
|
|
13
13
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
14
14
|
const RUSSIAN_CHARS_REGEXP = /[А-Яа-яЁё]/;
|
|
15
|
-
function ProjectHeader({ projectName, quotasUrl, canEditQuota, isError, onIncreaseQuotaClick,
|
|
15
|
+
function ProjectHeader({ projectName, quotasUrl, canEditQuota, isError, onIncreaseQuotaClick, onQuotasUrlClick, }) {
|
|
16
16
|
const { t } = (0, uikit_product_locale_1.useLocale)('Quota');
|
|
17
17
|
const widgetTitle = RUSSIAN_CHARS_REGEXP.test(projectName) ? 'widgetTitle.quotes' : 'widgetTitle.noQuotes';
|
|
18
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.header, children: [(0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.projectWrapper, children: [(0, jsx_runtime_1.jsx)(uikit_product_title_clickable_1.TitleClickable, { title: t(widgetTitle, { project: projectName }), href: quotasUrl, target: '_blank', icon: uikit_product_icons_1.QuotaSVG, onClick: onQuotasUrlClick }), (0, jsx_runtime_1.jsx)(typography_1.Typography.SansBodyS, { className: styles_module_scss_1.default.subtitle, children: t('widgetSubtitle') })] }), canEditQuota && !isError &&
|
|
18
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.header, children: [(0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.projectWrapper, children: [(0, jsx_runtime_1.jsx)(uikit_product_title_clickable_1.TitleClickable, { title: t(widgetTitle, { project: projectName }), href: quotasUrl, target: '_blank', icon: uikit_product_icons_1.QuotaSVG, onClick: onQuotasUrlClick }), (0, jsx_runtime_1.jsx)(typography_1.Typography.SansBodyS, { className: styles_module_scss_1.default.subtitle, children: t('widgetSubtitle') })] }), canEditQuota && !isError && ((0, jsx_runtime_1.jsx)(button_1.ButtonOutline, { appearance: 'neutral', label: t('increaseQuota'), size: 's', onClick: onIncreaseQuotaClick }))] }));
|
|
19
19
|
}
|
|
@@ -4,4 +4,4 @@ export type QuotaWidgetMiniProps = WithSupportProps<QuotaWidgetPropsBase & {
|
|
|
4
4
|
/** Флаг раскрытия аккордиона по умолчанию */
|
|
5
5
|
isExpandedDefault?: boolean;
|
|
6
6
|
}>;
|
|
7
|
-
export declare function QuotaWidgetMini({ quotas, disableSorting, isLoading, isError, onRefresh, projectName, canEditQuota, isExpandedDefault,
|
|
7
|
+
export declare function QuotaWidgetMini({ quotas, disableSorting, isLoading, isError, onRefresh, projectName, canEditQuota, isExpandedDefault, onIncreaseQuotaClick, onWidgetOpen, ...props }: QuotaWidgetMiniProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -26,7 +26,7 @@ const QuotaCardsGrid_1 = require("../../helperComponents/QuotaCardsGrid");
|
|
|
26
26
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
27
27
|
const ACCORDION_ID = 'quotas-widget-accordion';
|
|
28
28
|
function QuotaWidgetMini(_a) {
|
|
29
|
-
var { quotas, disableSorting, isLoading, isError, onRefresh, projectName, canEditQuota, isExpandedDefault,
|
|
29
|
+
var { quotas, disableSorting, isLoading, isError, onRefresh, projectName, canEditQuota, isExpandedDefault, onIncreaseQuotaClick, onWidgetOpen } = _a, props = __rest(_a, ["quotas", "disableSorting", "isLoading", "isError", "onRefresh", "projectName", "canEditQuota", "isExpandedDefault", "onIncreaseQuotaClick", "onWidgetOpen"]);
|
|
30
30
|
const { t } = (0, uikit_product_locale_1.useLocale)('Quota');
|
|
31
31
|
const exhaustedCount = quotas.filter(item => item.remains === 0).length;
|
|
32
32
|
const handleExpandedChange = (expanded) => {
|
|
@@ -34,5 +34,5 @@ function QuotaWidgetMini(_a) {
|
|
|
34
34
|
onWidgetOpen === null || onWidgetOpen === void 0 ? void 0 : onWidgetOpen();
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
return ((0, jsx_runtime_1.jsx)(accordion_1.AccordionPrimary, Object.assign({}, props, { expandedDefault: isExpandedDefault ? ACCORDION_ID : undefined, onExpandedChange: handleExpandedChange, children: (0, jsx_runtime_1.jsxs)(accordion_1.AccordionPrimary.CollapseBlock, { id: ACCORDION_ID, className: styles_module_scss_1.default.collapse, header: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.title, children: [(0, jsx_runtime_1.jsx)(typography_1.Typography.SansTitleM, { children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { maxLines: 1, text: t('widgetTitle.withoutProject') }) }), exhaustedCount > 0 && (0, jsx_runtime_1.jsx)(counter_1.Counter, { value: exhaustedCount, size: 's', appearance: 'red' })] }), (0, jsx_runtime_1.jsx)(typography_1.Typography.SansBodyM, { className: styles_module_scss_1.default.subtitle, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { maxLines: 1, text: projectName }) })] }), children: [(0, jsx_runtime_1.jsx)(QuotaCardsGrid_1.QuotaCardsGrid, { isAccordion: true, quotas: quotas, disableSorting: disableSorting, isLoading: isLoading, isError: isError, onRefresh: onRefresh }), !isError && canEditQuota &&
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)(accordion_1.AccordionPrimary, Object.assign({}, props, { expandedDefault: isExpandedDefault ? ACCORDION_ID : undefined, onExpandedChange: handleExpandedChange, children: (0, jsx_runtime_1.jsxs)(accordion_1.AccordionPrimary.CollapseBlock, { id: ACCORDION_ID, className: styles_module_scss_1.default.collapse, header: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.title, children: [(0, jsx_runtime_1.jsx)(typography_1.Typography.SansTitleM, { children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { maxLines: 1, text: t('widgetTitle.withoutProject') }) }), exhaustedCount > 0 && (0, jsx_runtime_1.jsx)(counter_1.Counter, { value: exhaustedCount, size: 's', appearance: 'red' })] }), (0, jsx_runtime_1.jsx)(typography_1.Typography.SansBodyM, { className: styles_module_scss_1.default.subtitle, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { maxLines: 1, text: projectName }) })] }), children: [(0, jsx_runtime_1.jsx)(QuotaCardsGrid_1.QuotaCardsGrid, { isAccordion: true, quotas: quotas, disableSorting: disableSorting, isLoading: isLoading, isError: isError, onRefresh: onRefresh }), !isError && canEditQuota && ((0, jsx_runtime_1.jsx)(button_1.ButtonOutline, { className: styles_module_scss_1.default.button, fullWidth: true, appearance: 'neutral', label: t('increaseQuota'), size: 's', onClick: onIncreaseQuotaClick }))] }) })));
|
|
38
38
|
}
|
|
@@ -6,4 +6,4 @@ export type QuotaWidgetMobileProps = WithSupportProps<QuotaWidgetPropsBase & {
|
|
|
6
6
|
/** Колбек на закрытие модального окна */
|
|
7
7
|
onClose: () => void;
|
|
8
8
|
}>;
|
|
9
|
-
export declare function QuotaWidgetMobile({ quotas, disableSorting, isLoading, isError, onRefresh, projectName, canEditQuota, isOpen, onClose, onIncreaseQuotaClick,
|
|
9
|
+
export declare function QuotaWidgetMobile({ quotas, disableSorting, isLoading, isError, onRefresh, projectName, canEditQuota, isOpen, onClose, onIncreaseQuotaClick, ...props }: QuotaWidgetMobileProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -17,11 +17,11 @@ const uikit_product_locale_1 = require("@cloud-ru/uikit-product-locale");
|
|
|
17
17
|
const uikit_product_mobile_modal_1 = require("@cloud-ru/uikit-product-mobile-modal");
|
|
18
18
|
const QuotaCardsGrid_1 = require("../../helperComponents/QuotaCardsGrid");
|
|
19
19
|
function QuotaWidgetMobile(_a) {
|
|
20
|
-
var { quotas, disableSorting, isLoading, isError, onRefresh, projectName, canEditQuota, isOpen, onClose, onIncreaseQuotaClick
|
|
20
|
+
var { quotas, disableSorting, isLoading, isError, onRefresh, projectName, canEditQuota, isOpen, onClose, onIncreaseQuotaClick } = _a, props = __rest(_a, ["quotas", "disableSorting", "isLoading", "isError", "onRefresh", "projectName", "canEditQuota", "isOpen", "onClose", "onIncreaseQuotaClick"]);
|
|
21
21
|
const { t } = (0, uikit_product_locale_1.useLocale)('Quota');
|
|
22
22
|
return (
|
|
23
23
|
// @ts-expect-error no approve button needed
|
|
24
|
-
(0, jsx_runtime_1.jsx)(uikit_product_mobile_modal_1.MobileModal, Object.assign({}, props, { closeButtonEnabled: true, open: isOpen, onClose: onClose, title: t('widgetTitle.withoutProject'), subtitle: projectName, cancelButton: isError || !canEditQuota
|
|
24
|
+
(0, jsx_runtime_1.jsx)(uikit_product_mobile_modal_1.MobileModal, Object.assign({}, props, { closeButtonEnabled: true, open: isOpen, onClose: onClose, title: t('widgetTitle.withoutProject'), subtitle: projectName, cancelButton: isError || !canEditQuota
|
|
25
25
|
? undefined
|
|
26
26
|
: {
|
|
27
27
|
appearance: 'neutral',
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -23,10 +23,8 @@ export type QuotaWidgetPropsBase = {
|
|
|
23
23
|
onRefresh: () => void;
|
|
24
24
|
/** Название проекта, по которому отображаются квоты */
|
|
25
25
|
projectName: string;
|
|
26
|
-
/** Флаг наличия прав на редактирование квот */
|
|
26
|
+
/** Флаг наличия прав на редактирование квот, влияет на отображение кнопки увеличения квот */
|
|
27
27
|
canEditQuota: boolean;
|
|
28
|
-
/** Флаг скрытия кнопки увеличения квоты */
|
|
29
|
-
hideIncreaseQuotaButton?: boolean;
|
|
30
28
|
/** Колбек нажатия на кнопку увеличения квот */
|
|
31
29
|
onIncreaseQuotaClick?: () => void;
|
|
32
30
|
/** Колбек открытия виджета квот */
|
|
@@ -9,4 +9,4 @@ export type QuotaWidgetProps = WithSupportProps<QuotaWidgetPropsBase & {
|
|
|
9
9
|
/** Свойства кнопки открытия виджета */
|
|
10
10
|
buttonProps?: Pick<ButtonFunctionProps, 'size' | 'className' | 'fullWidth' | 'label' | 'appearance' | 'disabled'>;
|
|
11
11
|
}>;
|
|
12
|
-
export declare function QuotaWidget({ quotas, disableSorting, isLoading, isError, onRefresh, projectName, quotasUrl, canEditQuota,
|
|
12
|
+
export declare function QuotaWidget({ quotas, disableSorting, isLoading, isError, onRefresh, projectName, quotasUrl, canEditQuota, onIncreaseQuotaClick, onWidgetOpen, onQuotasUrlClick, buttonProps, ...props }: QuotaWidgetProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -19,7 +19,7 @@ import { QuotaCardsGrid } from '../../helperComponents/QuotaCardsGrid';
|
|
|
19
19
|
import { ProjectHeader } from './components/ProjectHeader';
|
|
20
20
|
import styles from './styles.module.css';
|
|
21
21
|
export function QuotaWidget(_a) {
|
|
22
|
-
var { quotas, disableSorting, isLoading, isError, onRefresh, projectName, quotasUrl, canEditQuota,
|
|
22
|
+
var { quotas, disableSorting, isLoading, isError, onRefresh, projectName, quotasUrl, canEditQuota, onIncreaseQuotaClick, onWidgetOpen, onQuotasUrlClick, buttonProps } = _a, props = __rest(_a, ["quotas", "disableSorting", "isLoading", "isError", "onRefresh", "projectName", "quotasUrl", "canEditQuota", "onIncreaseQuotaClick", "onWidgetOpen", "onQuotasUrlClick", "buttonProps"]);
|
|
23
23
|
const { t } = useLocale('Quota');
|
|
24
24
|
const [isOpen, setIsOpen] = useState(false);
|
|
25
25
|
const handleOpenChange = (open) => {
|
|
@@ -29,7 +29,7 @@ export function QuotaWidget(_a) {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
const exhaustedCount = quotas.filter(item => item.remains === 0).length;
|
|
32
|
-
return (_jsx(Dropdown, Object.assign({}, props, { placement: 'bottom-end', open: isOpen, onOpenChange: handleOpenChange, content: _jsxs("div", { className: styles.content, children: [_jsx(ProjectHeader, { projectName: projectName, quotasUrl: quotasUrl, canEditQuota: canEditQuota, isError: isError, onIncreaseQuotaClick: onIncreaseQuotaClick,
|
|
32
|
+
return (_jsx(Dropdown, Object.assign({}, props, { placement: 'bottom-end', open: isOpen, onOpenChange: handleOpenChange, content: _jsxs("div", { className: styles.content, children: [_jsx(ProjectHeader, { projectName: projectName, quotasUrl: quotasUrl, canEditQuota: canEditQuota, isError: isError, onIncreaseQuotaClick: onIncreaseQuotaClick, onQuotasUrlClick: onQuotasUrlClick }), _jsx(QuotaCardsGrid, { quotas: quotas, disableSorting: disableSorting, isLoading: isLoading, isError: isError, onRefresh: onRefresh })] }), children: _jsx(ButtonFunction, Object.assign({ label: t('quotas'), icon: isOpen ? _jsx(ChevronUpSVG, {}) : _jsx(ChevronDownSVG, {}), counter: exhaustedCount > 0
|
|
33
33
|
? {
|
|
34
34
|
value: exhaustedCount,
|
|
35
35
|
appearance: 'red',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QuotaWidgetPropsBase } from '../../../../types';
|
|
2
|
-
type ProjectHeaderProps = Pick<QuotaWidgetPropsBase, 'projectName' | 'canEditQuota' | 'isError' | '
|
|
2
|
+
type ProjectHeaderProps = Pick<QuotaWidgetPropsBase, 'projectName' | 'canEditQuota' | 'isError' | 'onIncreaseQuotaClick'> & {
|
|
3
3
|
quotasUrl: string;
|
|
4
4
|
onQuotasUrlClick?: () => void;
|
|
5
5
|
};
|
|
6
|
-
export declare function ProjectHeader({ projectName, quotasUrl, canEditQuota, isError, onIncreaseQuotaClick,
|
|
6
|
+
export declare function ProjectHeader({ projectName, quotasUrl, canEditQuota, isError, onIncreaseQuotaClick, onQuotasUrlClick, }: ProjectHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -6,8 +6,8 @@ import { ButtonOutline } from '@snack-uikit/button';
|
|
|
6
6
|
import { Typography } from '@snack-uikit/typography';
|
|
7
7
|
import styles from './styles.module.css';
|
|
8
8
|
const RUSSIAN_CHARS_REGEXP = /[А-Яа-яЁё]/;
|
|
9
|
-
export function ProjectHeader({ projectName, quotasUrl, canEditQuota, isError, onIncreaseQuotaClick,
|
|
9
|
+
export function ProjectHeader({ projectName, quotasUrl, canEditQuota, isError, onIncreaseQuotaClick, onQuotasUrlClick, }) {
|
|
10
10
|
const { t } = useLocale('Quota');
|
|
11
11
|
const widgetTitle = RUSSIAN_CHARS_REGEXP.test(projectName) ? 'widgetTitle.quotes' : 'widgetTitle.noQuotes';
|
|
12
|
-
return (_jsxs("div", { className: styles.header, children: [_jsxs("div", { className: styles.projectWrapper, children: [_jsx(TitleClickable, { title: t(widgetTitle, { project: projectName }), href: quotasUrl, target: '_blank', icon: QuotaSVG, onClick: onQuotasUrlClick }), _jsx(Typography.SansBodyS, { className: styles.subtitle, children: t('widgetSubtitle') })] }), canEditQuota && !isError &&
|
|
12
|
+
return (_jsxs("div", { className: styles.header, children: [_jsxs("div", { className: styles.projectWrapper, children: [_jsx(TitleClickable, { title: t(widgetTitle, { project: projectName }), href: quotasUrl, target: '_blank', icon: QuotaSVG, onClick: onQuotasUrlClick }), _jsx(Typography.SansBodyS, { className: styles.subtitle, children: t('widgetSubtitle') })] }), canEditQuota && !isError && (_jsx(ButtonOutline, { appearance: 'neutral', label: t('increaseQuota'), size: 's', onClick: onIncreaseQuotaClick }))] }));
|
|
13
13
|
}
|
|
@@ -4,4 +4,4 @@ export type QuotaWidgetMiniProps = WithSupportProps<QuotaWidgetPropsBase & {
|
|
|
4
4
|
/** Флаг раскрытия аккордиона по умолчанию */
|
|
5
5
|
isExpandedDefault?: boolean;
|
|
6
6
|
}>;
|
|
7
|
-
export declare function QuotaWidgetMini({ quotas, disableSorting, isLoading, isError, onRefresh, projectName, canEditQuota, isExpandedDefault,
|
|
7
|
+
export declare function QuotaWidgetMini({ quotas, disableSorting, isLoading, isError, onRefresh, projectName, canEditQuota, isExpandedDefault, onIncreaseQuotaClick, onWidgetOpen, ...props }: QuotaWidgetMiniProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -20,7 +20,7 @@ import { QuotaCardsGrid } from '../../helperComponents/QuotaCardsGrid';
|
|
|
20
20
|
import styles from './styles.module.css';
|
|
21
21
|
const ACCORDION_ID = 'quotas-widget-accordion';
|
|
22
22
|
export function QuotaWidgetMini(_a) {
|
|
23
|
-
var { quotas, disableSorting, isLoading, isError, onRefresh, projectName, canEditQuota, isExpandedDefault,
|
|
23
|
+
var { quotas, disableSorting, isLoading, isError, onRefresh, projectName, canEditQuota, isExpandedDefault, onIncreaseQuotaClick, onWidgetOpen } = _a, props = __rest(_a, ["quotas", "disableSorting", "isLoading", "isError", "onRefresh", "projectName", "canEditQuota", "isExpandedDefault", "onIncreaseQuotaClick", "onWidgetOpen"]);
|
|
24
24
|
const { t } = useLocale('Quota');
|
|
25
25
|
const exhaustedCount = quotas.filter(item => item.remains === 0).length;
|
|
26
26
|
const handleExpandedChange = (expanded) => {
|
|
@@ -28,5 +28,5 @@ export function QuotaWidgetMini(_a) {
|
|
|
28
28
|
onWidgetOpen === null || onWidgetOpen === void 0 ? void 0 : onWidgetOpen();
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
return (_jsx(AccordionPrimary, Object.assign({}, props, { expandedDefault: isExpandedDefault ? ACCORDION_ID : undefined, onExpandedChange: handleExpandedChange, children: _jsxs(AccordionPrimary.CollapseBlock, { id: ACCORDION_ID, className: styles.collapse, header: _jsxs(_Fragment, { children: [_jsxs("div", { className: styles.title, children: [_jsx(Typography.SansTitleM, { children: _jsx(TruncateString, { maxLines: 1, text: t('widgetTitle.withoutProject') }) }), exhaustedCount > 0 && _jsx(Counter, { value: exhaustedCount, size: 's', appearance: 'red' })] }), _jsx(Typography.SansBodyM, { className: styles.subtitle, children: _jsx(TruncateString, { maxLines: 1, text: projectName }) })] }), children: [_jsx(QuotaCardsGrid, { isAccordion: true, quotas: quotas, disableSorting: disableSorting, isLoading: isLoading, isError: isError, onRefresh: onRefresh }), !isError && canEditQuota &&
|
|
31
|
+
return (_jsx(AccordionPrimary, Object.assign({}, props, { expandedDefault: isExpandedDefault ? ACCORDION_ID : undefined, onExpandedChange: handleExpandedChange, children: _jsxs(AccordionPrimary.CollapseBlock, { id: ACCORDION_ID, className: styles.collapse, header: _jsxs(_Fragment, { children: [_jsxs("div", { className: styles.title, children: [_jsx(Typography.SansTitleM, { children: _jsx(TruncateString, { maxLines: 1, text: t('widgetTitle.withoutProject') }) }), exhaustedCount > 0 && _jsx(Counter, { value: exhaustedCount, size: 's', appearance: 'red' })] }), _jsx(Typography.SansBodyM, { className: styles.subtitle, children: _jsx(TruncateString, { maxLines: 1, text: projectName }) })] }), children: [_jsx(QuotaCardsGrid, { isAccordion: true, quotas: quotas, disableSorting: disableSorting, isLoading: isLoading, isError: isError, onRefresh: onRefresh }), !isError && canEditQuota && (_jsx(ButtonOutline, { className: styles.button, fullWidth: true, appearance: 'neutral', label: t('increaseQuota'), size: 's', onClick: onIncreaseQuotaClick }))] }) })));
|
|
32
32
|
}
|
|
@@ -6,4 +6,4 @@ export type QuotaWidgetMobileProps = WithSupportProps<QuotaWidgetPropsBase & {
|
|
|
6
6
|
/** Колбек на закрытие модального окна */
|
|
7
7
|
onClose: () => void;
|
|
8
8
|
}>;
|
|
9
|
-
export declare function QuotaWidgetMobile({ quotas, disableSorting, isLoading, isError, onRefresh, projectName, canEditQuota, isOpen, onClose, onIncreaseQuotaClick,
|
|
9
|
+
export declare function QuotaWidgetMobile({ quotas, disableSorting, isLoading, isError, onRefresh, projectName, canEditQuota, isOpen, onClose, onIncreaseQuotaClick, ...props }: QuotaWidgetMobileProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -14,11 +14,11 @@ import { useLocale } from '@cloud-ru/uikit-product-locale';
|
|
|
14
14
|
import { MobileModal } from '@cloud-ru/uikit-product-mobile-modal';
|
|
15
15
|
import { QuotaCardsGrid } from '../../helperComponents/QuotaCardsGrid';
|
|
16
16
|
export function QuotaWidgetMobile(_a) {
|
|
17
|
-
var { quotas, disableSorting, isLoading, isError, onRefresh, projectName, canEditQuota, isOpen, onClose, onIncreaseQuotaClick
|
|
17
|
+
var { quotas, disableSorting, isLoading, isError, onRefresh, projectName, canEditQuota, isOpen, onClose, onIncreaseQuotaClick } = _a, props = __rest(_a, ["quotas", "disableSorting", "isLoading", "isError", "onRefresh", "projectName", "canEditQuota", "isOpen", "onClose", "onIncreaseQuotaClick"]);
|
|
18
18
|
const { t } = useLocale('Quota');
|
|
19
19
|
return (
|
|
20
20
|
// @ts-expect-error no approve button needed
|
|
21
|
-
_jsx(MobileModal, Object.assign({}, props, { closeButtonEnabled: true, open: isOpen, onClose: onClose, title: t('widgetTitle.withoutProject'), subtitle: projectName, cancelButton: isError || !canEditQuota
|
|
21
|
+
_jsx(MobileModal, Object.assign({}, props, { closeButtonEnabled: true, open: isOpen, onClose: onClose, title: t('widgetTitle.withoutProject'), subtitle: projectName, cancelButton: isError || !canEditQuota
|
|
22
22
|
? undefined
|
|
23
23
|
: {
|
|
24
24
|
appearance: 'neutral',
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -23,10 +23,8 @@ export type QuotaWidgetPropsBase = {
|
|
|
23
23
|
onRefresh: () => void;
|
|
24
24
|
/** Название проекта, по которому отображаются квоты */
|
|
25
25
|
projectName: string;
|
|
26
|
-
/** Флаг наличия прав на редактирование квот */
|
|
26
|
+
/** Флаг наличия прав на редактирование квот, влияет на отображение кнопки увеличения квот */
|
|
27
27
|
canEditQuota: boolean;
|
|
28
|
-
/** Флаг скрытия кнопки увеличения квоты */
|
|
29
|
-
hideIncreaseQuotaButton?: boolean;
|
|
30
28
|
/** Колбек нажатия на кнопку увеличения квот */
|
|
31
29
|
onIncreaseQuotaClick?: () => void;
|
|
32
30
|
/** Колбек открытия виджета квот */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-ru/uikit-product-quota",
|
|
3
3
|
"title": "Quota",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.3-preview-d635e8b9.0",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"*.css",
|
|
7
7
|
"*.woff",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"@snack-uikit/tooltip": "^1.0.1",
|
|
48
48
|
"@snack-uikit/truncate-string": "^1.0.1",
|
|
49
49
|
"@snack-uikit/typography": "^1.0.1",
|
|
50
|
-
"@cloud-ru/uikit-product-icons": "
|
|
51
|
-
"@cloud-ru/uikit-product-mobile-modal": "
|
|
52
|
-
"@cloud-ru/uikit-product-title-clickable": "
|
|
53
|
-
"@cloud-ru/uikit-product-utils": "
|
|
50
|
+
"@cloud-ru/uikit-product-icons": "19.2.0",
|
|
51
|
+
"@cloud-ru/uikit-product-mobile-modal": "3.0.2",
|
|
52
|
+
"@cloud-ru/uikit-product-title-clickable": "2.0.2",
|
|
53
|
+
"@cloud-ru/uikit-product-utils": "10.0.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@cloud-ru/uikit-product-locale": "*"
|
|
@@ -31,7 +31,6 @@ export function QuotaWidget({
|
|
|
31
31
|
projectName,
|
|
32
32
|
quotasUrl,
|
|
33
33
|
canEditQuota,
|
|
34
|
-
hideIncreaseQuotaButton,
|
|
35
34
|
onIncreaseQuotaClick,
|
|
36
35
|
onWidgetOpen,
|
|
37
36
|
onQuotasUrlClick,
|
|
@@ -64,7 +63,6 @@ export function QuotaWidget({
|
|
|
64
63
|
canEditQuota={canEditQuota}
|
|
65
64
|
isError={isError}
|
|
66
65
|
onIncreaseQuotaClick={onIncreaseQuotaClick}
|
|
67
|
-
hideIncreaseQuotaButton={hideIncreaseQuotaButton}
|
|
68
66
|
onQuotasUrlClick={onQuotasUrlClick}
|
|
69
67
|
/>
|
|
70
68
|
|
|
@@ -9,7 +9,7 @@ import styles from './styles.module.scss';
|
|
|
9
9
|
|
|
10
10
|
type ProjectHeaderProps = Pick<
|
|
11
11
|
QuotaWidgetPropsBase,
|
|
12
|
-
'projectName' | 'canEditQuota' | 'isError' | '
|
|
12
|
+
'projectName' | 'canEditQuota' | 'isError' | 'onIncreaseQuotaClick'
|
|
13
13
|
> & {
|
|
14
14
|
quotasUrl: string;
|
|
15
15
|
onQuotasUrlClick?: () => void;
|
|
@@ -23,7 +23,6 @@ export function ProjectHeader({
|
|
|
23
23
|
canEditQuota,
|
|
24
24
|
isError,
|
|
25
25
|
onIncreaseQuotaClick,
|
|
26
|
-
hideIncreaseQuotaButton,
|
|
27
26
|
onQuotasUrlClick,
|
|
28
27
|
}: ProjectHeaderProps) {
|
|
29
28
|
const { t } = useLocale('Quota');
|
|
@@ -44,7 +43,7 @@ export function ProjectHeader({
|
|
|
44
43
|
<Typography.SansBodyS className={styles.subtitle}>{t('widgetSubtitle')}</Typography.SansBodyS>
|
|
45
44
|
</div>
|
|
46
45
|
|
|
47
|
-
{canEditQuota && !isError &&
|
|
46
|
+
{canEditQuota && !isError && (
|
|
48
47
|
<ButtonOutline appearance='neutral' label={t('increaseQuota')} size='s' onClick={onIncreaseQuotaClick} />
|
|
49
48
|
)}
|
|
50
49
|
</div>
|
|
@@ -28,7 +28,6 @@ export function QuotaWidgetMini({
|
|
|
28
28
|
projectName,
|
|
29
29
|
canEditQuota,
|
|
30
30
|
isExpandedDefault,
|
|
31
|
-
hideIncreaseQuotaButton,
|
|
32
31
|
onIncreaseQuotaClick,
|
|
33
32
|
onWidgetOpen,
|
|
34
33
|
...props
|
|
@@ -77,7 +76,7 @@ export function QuotaWidgetMini({
|
|
|
77
76
|
onRefresh={onRefresh}
|
|
78
77
|
/>
|
|
79
78
|
|
|
80
|
-
{!isError && canEditQuota &&
|
|
79
|
+
{!isError && canEditQuota && (
|
|
81
80
|
<ButtonOutline
|
|
82
81
|
className={styles.button}
|
|
83
82
|
fullWidth
|
|
@@ -25,7 +25,6 @@ export function QuotaWidgetMobile({
|
|
|
25
25
|
isOpen,
|
|
26
26
|
onClose,
|
|
27
27
|
onIncreaseQuotaClick,
|
|
28
|
-
hideIncreaseQuotaButton,
|
|
29
28
|
...props
|
|
30
29
|
}: QuotaWidgetMobileProps) {
|
|
31
30
|
const { t } = useLocale('Quota');
|
|
@@ -40,7 +39,7 @@ export function QuotaWidgetMobile({
|
|
|
40
39
|
title={t('widgetTitle.withoutProject')}
|
|
41
40
|
subtitle={projectName}
|
|
42
41
|
cancelButton={
|
|
43
|
-
isError || !canEditQuota
|
|
42
|
+
isError || !canEditQuota
|
|
44
43
|
? undefined
|
|
45
44
|
: {
|
|
46
45
|
appearance: 'neutral',
|
package/src/types.ts
CHANGED
|
@@ -24,10 +24,8 @@ export type QuotaWidgetPropsBase = {
|
|
|
24
24
|
onRefresh: () => void;
|
|
25
25
|
/** Название проекта, по которому отображаются квоты */
|
|
26
26
|
projectName: string;
|
|
27
|
-
/** Флаг наличия прав на редактирование квот */
|
|
27
|
+
/** Флаг наличия прав на редактирование квот, влияет на отображение кнопки увеличения квот */
|
|
28
28
|
canEditQuota: boolean;
|
|
29
|
-
/** Флаг скрытия кнопки увеличения квоты */
|
|
30
|
-
hideIncreaseQuotaButton?: boolean;
|
|
31
29
|
/** Колбек нажатия на кнопку увеличения квот */
|
|
32
30
|
onIncreaseQuotaClick?: () => void;
|
|
33
31
|
/** Колбек открытия виджета квот */
|