@cloud-ru/ds-uikit-product-quota 1.0.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/CHANGELOG.md +8 -0
- package/LICENSE +201 -0
- package/README.md +458 -0
- package/dist/cjs/components/QuotaWidget/QuotaIncreaseButton.d.ts +4 -0
- package/dist/cjs/components/QuotaWidget/QuotaIncreaseButton.js +15 -0
- package/dist/cjs/components/QuotaWidget/QuotaMobileHeader.d.ts +4 -0
- package/dist/cjs/components/QuotaWidget/QuotaMobileHeader.js +15 -0
- package/dist/cjs/components/QuotaWidget/QuotaWidget.d.ts +12 -0
- package/dist/cjs/components/QuotaWidget/QuotaWidget.js +44 -0
- package/dist/cjs/components/QuotaWidget/QuotaWidgetContent.d.ts +27 -0
- package/dist/cjs/components/QuotaWidget/QuotaWidgetContent.js +33 -0
- package/dist/cjs/components/QuotaWidget/components/ProjectHeader/ProjectHeader.d.ts +7 -0
- package/dist/cjs/components/QuotaWidget/components/ProjectHeader/ProjectHeader.js +19 -0
- package/dist/cjs/components/QuotaWidget/components/ProjectHeader/index.d.ts +1 -0
- package/dist/cjs/components/QuotaWidget/components/ProjectHeader/index.js +17 -0
- package/dist/cjs/components/QuotaWidget/components/ProjectHeader/styles.module.css +30 -0
- package/dist/cjs/components/QuotaWidget/index.d.ts +2 -0
- package/dist/cjs/components/QuotaWidget/index.js +18 -0
- package/dist/cjs/components/QuotaWidget/styles.module.css +49 -0
- package/dist/cjs/components/QuotaWidgetCard/QuotaWidgetCard.d.ts +13 -0
- package/dist/cjs/components/QuotaWidgetCard/QuotaWidgetCard.js +53 -0
- package/dist/cjs/components/QuotaWidgetCard/components/QuotaTooltip/QuotaTooltip.d.ts +6 -0
- package/dist/cjs/components/QuotaWidgetCard/components/QuotaTooltip/QuotaTooltip.js +23 -0
- package/dist/cjs/components/QuotaWidgetCard/components/QuotaTooltip/index.d.ts +1 -0
- package/dist/cjs/components/QuotaWidgetCard/components/QuotaTooltip/index.js +17 -0
- package/dist/cjs/components/QuotaWidgetCard/components/QuotaTooltip/styles.module.css +34 -0
- package/dist/cjs/components/QuotaWidgetCard/index.d.ts +1 -0
- package/dist/cjs/components/QuotaWidgetCard/index.js +17 -0
- package/dist/cjs/components/QuotaWidgetCard/styles.module.css +97 -0
- package/dist/cjs/components/QuotaWidgetMini/QuotaWidgetMini.d.ts +7 -0
- package/dist/cjs/components/QuotaWidgetMini/QuotaWidgetMini.js +27 -0
- package/dist/cjs/components/QuotaWidgetMini/index.d.ts +1 -0
- package/dist/cjs/components/QuotaWidgetMini/index.js +17 -0
- package/dist/cjs/components/QuotaWidgetMini/styles.module.css +15 -0
- package/dist/cjs/components/index.d.ts +3 -0
- package/dist/cjs/components/index.js +19 -0
- package/dist/cjs/constants.d.ts +17 -0
- package/dist/cjs/constants.js +20 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/QuotaCardsGrid.d.ts +6 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/QuotaCardsGrid.js +32 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/components/Grid/Grid.d.ts +6 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/components/Grid/Grid.js +30 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/components/Grid/components/QuotaWidgetCardsSkeleton/QuotaCardsSkeleton.d.ts +6 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/components/Grid/components/QuotaWidgetCardsSkeleton/QuotaCardsSkeleton.js +16 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/components/Grid/components/QuotaWidgetCardsSkeleton/index.d.ts +1 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/components/Grid/components/QuotaWidgetCardsSkeleton/index.js +17 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/components/Grid/components/QuotaWidgetCardsSkeleton/styles.module.css +10 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/components/Grid/index.d.ts +1 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/components/Grid/index.js +17 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/components/Grid/styles.module.css +9 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/components/QuotaError/QuotaError.d.ts +5 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/components/QuotaError/QuotaError.js +12 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/components/QuotaError/index.d.ts +1 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/components/QuotaError/index.js +17 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/index.d.ts +1 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/index.js +17 -0
- package/dist/cjs/helperComponents/QuotaCardsGrid/styles.module.css +16 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/locale/index.d.ts +91 -0
- package/dist/cjs/locale/index.js +50 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/style.css +260 -0
- package/dist/cjs/types.d.ts +34 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/utils/checkIsExceeded.d.ts +2 -0
- package/dist/cjs/utils/checkIsExceeded.js +5 -0
- package/dist/cjs/utils/formatNumber.d.ts +1 -0
- package/dist/cjs/utils/formatNumber.js +6 -0
- package/dist/cjs/utils/getPercent.d.ts +2 -0
- package/dist/cjs/utils/getPercent.js +9 -0
- package/dist/cjs/utils/index.d.ts +3 -0
- package/dist/cjs/utils/index.js +19 -0
- package/dist/esm/components/QuotaWidget/QuotaIncreaseButton.d.ts +4 -0
- package/dist/esm/components/QuotaWidget/QuotaIncreaseButton.js +9 -0
- package/dist/esm/components/QuotaWidget/QuotaMobileHeader.d.ts +4 -0
- package/dist/esm/components/QuotaWidget/QuotaMobileHeader.js +9 -0
- package/dist/esm/components/QuotaWidget/QuotaWidget.d.ts +12 -0
- package/dist/esm/components/QuotaWidget/QuotaWidget.js +41 -0
- package/dist/esm/components/QuotaWidget/QuotaWidgetContent.d.ts +27 -0
- package/dist/esm/components/QuotaWidget/QuotaWidgetContent.js +27 -0
- package/dist/esm/components/QuotaWidget/components/ProjectHeader/ProjectHeader.d.ts +7 -0
- package/dist/esm/components/QuotaWidget/components/ProjectHeader/ProjectHeader.js +13 -0
- package/dist/esm/components/QuotaWidget/components/ProjectHeader/index.d.ts +1 -0
- package/dist/esm/components/QuotaWidget/components/ProjectHeader/index.js +1 -0
- package/dist/esm/components/QuotaWidget/components/ProjectHeader/styles.module.css +30 -0
- package/dist/esm/components/QuotaWidget/index.d.ts +2 -0
- package/dist/esm/components/QuotaWidget/index.js +2 -0
- package/dist/esm/components/QuotaWidget/styles.module.css +49 -0
- package/dist/esm/components/QuotaWidgetCard/QuotaWidgetCard.d.ts +13 -0
- package/dist/esm/components/QuotaWidgetCard/QuotaWidgetCard.js +47 -0
- package/dist/esm/components/QuotaWidgetCard/components/QuotaTooltip/QuotaTooltip.d.ts +6 -0
- package/dist/esm/components/QuotaWidgetCard/components/QuotaTooltip/QuotaTooltip.js +17 -0
- package/dist/esm/components/QuotaWidgetCard/components/QuotaTooltip/index.d.ts +1 -0
- package/dist/esm/components/QuotaWidgetCard/components/QuotaTooltip/index.js +1 -0
- package/dist/esm/components/QuotaWidgetCard/components/QuotaTooltip/styles.module.css +34 -0
- package/dist/esm/components/QuotaWidgetCard/index.d.ts +1 -0
- package/dist/esm/components/QuotaWidgetCard/index.js +1 -0
- package/dist/esm/components/QuotaWidgetCard/styles.module.css +97 -0
- package/dist/esm/components/QuotaWidgetMini/QuotaWidgetMini.d.ts +7 -0
- package/dist/esm/components/QuotaWidgetMini/QuotaWidgetMini.js +21 -0
- package/dist/esm/components/QuotaWidgetMini/index.d.ts +1 -0
- package/dist/esm/components/QuotaWidgetMini/index.js +1 -0
- package/dist/esm/components/QuotaWidgetMini/styles.module.css +15 -0
- package/dist/esm/components/index.d.ts +3 -0
- package/dist/esm/components/index.js +3 -0
- package/dist/esm/constants.d.ts +17 -0
- package/dist/esm/constants.js +17 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/QuotaCardsGrid.d.ts +6 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/QuotaCardsGrid.js +26 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/components/Grid/Grid.d.ts +6 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/components/Grid/Grid.js +24 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/components/Grid/components/QuotaWidgetCardsSkeleton/QuotaCardsSkeleton.d.ts +6 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/components/Grid/components/QuotaWidgetCardsSkeleton/QuotaCardsSkeleton.js +10 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/components/Grid/components/QuotaWidgetCardsSkeleton/index.d.ts +1 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/components/Grid/components/QuotaWidgetCardsSkeleton/index.js +1 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/components/Grid/components/QuotaWidgetCardsSkeleton/styles.module.css +10 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/components/Grid/index.d.ts +1 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/components/Grid/index.js +1 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/components/Grid/styles.module.css +9 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/components/QuotaError/QuotaError.d.ts +5 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/components/QuotaError/QuotaError.js +9 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/components/QuotaError/index.d.ts +1 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/components/QuotaError/index.js +1 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/index.d.ts +1 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/index.js +1 -0
- package/dist/esm/helperComponents/QuotaCardsGrid/styles.module.css +16 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/locale/index.d.ts +91 -0
- package/dist/esm/locale/index.js +47 -0
- package/dist/esm/style.css +260 -0
- package/dist/esm/types.d.ts +34 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/utils/checkIsExceeded.d.ts +2 -0
- package/dist/esm/utils/checkIsExceeded.js +1 -0
- package/dist/esm/utils/formatNumber.d.ts +1 -0
- package/dist/esm/utils/formatNumber.js +3 -0
- package/dist/esm/utils/getPercent.d.ts +2 -0
- package/dist/esm/utils/getPercent.js +6 -0
- package/dist/esm/utils/index.d.ts +3 -0
- package/dist/esm/utils/index.js +3 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/package.json +63 -0
- package/src/components/QuotaWidget/QuotaIncreaseButton.tsx +21 -0
- package/src/components/QuotaWidget/QuotaMobileHeader.tsx +18 -0
- package/src/components/QuotaWidget/QuotaWidget.tsx +109 -0
- package/src/components/QuotaWidget/QuotaWidgetContent.tsx +91 -0
- package/src/components/QuotaWidget/components/ProjectHeader/ProjectHeader.tsx +59 -0
- package/src/components/QuotaWidget/components/ProjectHeader/index.ts +1 -0
- package/src/components/QuotaWidget/components/ProjectHeader/styles.module.scss +29 -0
- package/src/components/QuotaWidget/index.ts +2 -0
- package/src/components/QuotaWidget/styles.module.scss +52 -0
- package/src/components/QuotaWidgetCard/QuotaWidgetCard.tsx +127 -0
- package/src/components/QuotaWidgetCard/components/QuotaTooltip/QuotaTooltip.tsx +48 -0
- package/src/components/QuotaWidgetCard/components/QuotaTooltip/index.ts +1 -0
- package/src/components/QuotaWidgetCard/components/QuotaTooltip/styles.module.scss +30 -0
- package/src/components/QuotaWidgetCard/index.ts +1 -0
- package/src/components/QuotaWidgetCard/styles.module.scss +97 -0
- package/src/components/QuotaWidgetMini/QuotaWidgetMini.tsx +93 -0
- package/src/components/QuotaWidgetMini/index.ts +1 -0
- package/src/components/QuotaWidgetMini/styles.module.scss +18 -0
- package/src/components/index.ts +3 -0
- package/src/constants.ts +17 -0
- package/src/helperComponents/QuotaCardsGrid/QuotaCardsGrid.tsx +54 -0
- package/src/helperComponents/QuotaCardsGrid/components/Grid/Grid.tsx +47 -0
- package/src/helperComponents/QuotaCardsGrid/components/Grid/components/QuotaWidgetCardsSkeleton/QuotaCardsSkeleton.tsx +24 -0
- package/src/helperComponents/QuotaCardsGrid/components/Grid/components/QuotaWidgetCardsSkeleton/index.ts +1 -0
- package/src/helperComponents/QuotaCardsGrid/components/Grid/components/QuotaWidgetCardsSkeleton/styles.module.scss +15 -0
- package/src/helperComponents/QuotaCardsGrid/components/Grid/index.ts +1 -0
- package/src/helperComponents/QuotaCardsGrid/components/Grid/styles.module.scss +12 -0
- package/src/helperComponents/QuotaCardsGrid/components/QuotaError/QuotaError.tsx +31 -0
- package/src/helperComponents/QuotaCardsGrid/components/QuotaError/index.ts +1 -0
- package/src/helperComponents/QuotaCardsGrid/index.ts +1 -0
- package/src/helperComponents/QuotaCardsGrid/styles.module.scss +16 -0
- package/src/index.ts +5 -0
- package/src/locale/index.ts +51 -0
- package/src/types.ts +35 -0
- package/src/utils/checkIsExceeded.ts +3 -0
- package/src/utils/formatNumber.ts +3 -0
- package/src/utils/getPercent.ts +9 -0
- package/src/utils/index.ts +3 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2023 Cloud technology Limited (Ltd.)
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
# Quota
|
|
2
|
+
|
|
3
|
+
`@cloud-ru/ds-uikit-product-quota` — Виджеты квот проекта — выпадающий QuotaWidget, аккордеон QuotaWidgetMini и карточка квоты QuotaWidgetCard с прогрессом и состояниями loading/error.
|
|
4
|
+
|
|
5
|
+
Пакет `@cloud-ru/ds-uikit-product-quota` предоставляет три компонента для отображения квот проекта. Все три используют общую модель данных `QuotaItem` (`name`, `limit`, `usage`, `remains`, `unitDisplayName`) и общие состояния загрузки и ошибки.
|
|
6
|
+
|
|
7
|
+
- ****QuotaWidget**** — кнопка-триггер с выпадающим списком карточек квот, для шапки продуктовых страниц.
|
|
8
|
+
- ****QuotaWidgetMini**** — компактный аккордеон со списком квот, для сайдбаров и узких layout'ов.
|
|
9
|
+
- ****QuotaWidgetCard**** — карточка одной квоты с прогресс-баром, tooltip-расшифровкой и состояниями `loading` / `noData`.
|
|
10
|
+
|
|
11
|
+
Карточки внутри `QuotaWidget` и `QuotaWidgetMini` — те же `QuotaWidgetCard`; исчерпанные квоты (`remains <= 0`) поднимаются в начало списка и подсчитываются в counter триггера.
|
|
12
|
+
|
|
13
|
+
Отдельно доступен ****QuotaWidgetContent**** — содержимое `QuotaWidget` без кнопки-триггера и выпадающего списка, для случаев, когда раскрытие даёт контейнер снаружи.
|
|
14
|
+
|
|
15
|
+
## Установка
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @cloud-ru/ds-uikit-product-quota
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { QuotaWidget, QuotaWidgetMini, QuotaWidgetCard } from '@cloud-ru/ds-uikit-product-quota'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Figma
|
|
26
|
+
|
|
27
|
+
Все три компонента живут на одной странице `Quota` файла Product UI Kit. Ссылки на конкретные узлы — на страницах компонентов.
|
|
28
|
+
|
|
29
|
+
## QuotaWidget
|
|
30
|
+
|
|
31
|
+
Кнопка-триггер с выпадающим списком карточек квот проекта — counter исчерпанных квот, ссылка на страницу квот и кнопка увеличения.
|
|
32
|
+
|
|
33
|
+
Кнопка «Квоты» с counter'ом исчерпанных квот, по клику открывающая **`Dropdown`** с шапкой проекта и сеткой карточек **`QuotaWidgetCard`**. Шапка содержит название проекта, ссылку на страницу квот (`quotasUrl`) и кнопку «Увеличить квоты» (при `canEditQuota`).
|
|
34
|
+
|
|
35
|
+
### Когда использовать
|
|
36
|
+
|
|
37
|
+
- Шапка продуктовой страницы или toolbar, где квоты — вторичная информация и раскрываются по требованию.
|
|
38
|
+
- Нужен индикатор исчерпанных квот без постоянного места под список.
|
|
39
|
+
- Узкий сайдбар, где список квот должен быть виден без портала:
|
|
40
|
+
- используйте **`QuotaWidgetMini`**.
|
|
41
|
+
- Одна конкретная квота на странице ресурса:
|
|
42
|
+
- используйте **`QuotaWidgetCard`**.
|
|
43
|
+
|
|
44
|
+
- ✅ Оборачивайте страницу в `PortalContextProvider` — контент рендерится в портал `Dropdown`.
|
|
45
|
+
- ❌ Рендерить виджет без portal-контекста — выпадающий список не появится.
|
|
46
|
+
|
|
47
|
+
- ✅ Переключайте `error` обратно после успешного `onRefresh` — кнопка повтора в состоянии ошибки.
|
|
48
|
+
- ❌ Оставлять `error` без рабочего `onRefresh` — пользователь не сможет восстановить список.
|
|
49
|
+
|
|
50
|
+
### Анатомия
|
|
51
|
+
|
|
52
|
+
#### Триггер
|
|
53
|
+
|
|
54
|
+
`Button view='function'` с label «Квоты» и chevron-иконкой; counter показывает число исчерпанных квот (`remains <= 0`). Внешний вид настраивается через `buttonProps` (`size`, `appearance`, `label`, `fullWidth`, `disabled`, `className`).
|
|
55
|
+
|
|
56
|
+
#### Шапка проекта
|
|
57
|
+
|
|
58
|
+
- `projectName` — название проекта.
|
|
59
|
+
- `quotasUrl` + `onQuotasUrlClick` — ссылка на страницу квот.
|
|
60
|
+
- `canEditQuota` + `onIncreaseQuotaClick` — кнопка «Увеличить квоты»; скрывается `hideIncreaseQuotaButton`.
|
|
61
|
+
|
|
62
|
+
#### Список квот
|
|
63
|
+
|
|
64
|
+
Сетка карточек `QuotaWidgetCard`. Исчерпанные квоты поднимаются в начало (отключается `disableSorting`). Состояния:
|
|
65
|
+
|
|
66
|
+
- `loading` — skeleton-карточки.
|
|
67
|
+
- `error` — блок ошибки с кнопкой повтора (`onRefresh`).
|
|
68
|
+
|
|
69
|
+
#### Контент без триггера — `QuotaWidgetContent`
|
|
70
|
+
|
|
71
|
+
Шапка проекта и сетка карточек без кнопки-триггера и без `Dropdown`. Нужен, когда раскрытие даёт контейнер снаружи — например `sideBlock` формы, который на mobile уже открывает `BottomSheet`. Принимает те же данные и состояния, что `QuotaWidget`.
|
|
72
|
+
|
|
73
|
+
На mobile `QuotaWidget` выносит шапку и кнопку «Увеличить квоты» в pinned-слоты `title` и `footer` листа, чтобы они не скроллились вместе с карточками. За это отвечают два пропа:
|
|
74
|
+
|
|
75
|
+
- `hideMobileHeader` — не рендерить мобильную шапку внутри контента.
|
|
76
|
+
- `hideMobileIncreaseButton` — не рендерить мобильную кнопку расширения внутри контента.
|
|
77
|
+
|
|
78
|
+
Оба влияют только на mobile-раскладку. Включайте их, когда сами кладёте заголовок и кнопку в слоты своего контейнера, иначе элементы отрисуются дважды.
|
|
79
|
+
|
|
80
|
+
### Примеры использования
|
|
81
|
+
|
|
82
|
+
#### Базовый случай
|
|
83
|
+
|
|
84
|
+
Counter исчерпанных квот на триггере, сетка карточек в dropdown
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
import { QuotaItem, QuotaWidget } from '@cloud-ru/ds-uikit-product-quota';
|
|
88
|
+
import { useState } from 'react';
|
|
89
|
+
|
|
90
|
+
const QUOTAS: QuotaItem[] = [
|
|
91
|
+
{ name: 'vCPU', limit: 100, usage: 42, remains: 58, unitDisplayName: 'cores' },
|
|
92
|
+
{ name: 'RAM', limit: 256, usage: 230, remains: 26, unitDisplayName: 'GB' },
|
|
93
|
+
{ name: 'SSD', limit: 1000, usage: 1000, remains: 0, unitDisplayName: 'GB' },
|
|
94
|
+
{ name: 'Public IP', limit: 10, usage: 9, remains: 1, unitDisplayName: 'pcs' },
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
export function QuotaWidgetBasic() {
|
|
98
|
+
const [loading, setLoading] = useState(false);
|
|
99
|
+
|
|
100
|
+
const reload = () => {
|
|
101
|
+
setLoading(true);
|
|
102
|
+
setTimeout(() => setLoading(false), 800);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
// В продукте виджет живёт у правого края страницы — dropdown прижат к правому краю триггера
|
|
107
|
+
<div style={{ display: 'flex', justifyContent: 'flex-end', width: '100%' }}>
|
|
108
|
+
<QuotaWidget
|
|
109
|
+
quotas={QUOTAS}
|
|
110
|
+
projectName='ml-platform-production'
|
|
111
|
+
quotasUrl='#'
|
|
112
|
+
canEditQuota={false}
|
|
113
|
+
loading={loading}
|
|
114
|
+
error={false}
|
|
115
|
+
onRefresh={reload}
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### Ошибка загрузки и повтор
|
|
123
|
+
|
|
124
|
+
error показывает блок ошибки; onRefresh переключает в loading и восстанавливает список
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
import { QuotaItem, QuotaWidget } from '@cloud-ru/ds-uikit-product-quota';
|
|
128
|
+
import { useState } from 'react';
|
|
129
|
+
|
|
130
|
+
const QUOTAS: QuotaItem[] = [
|
|
131
|
+
{ name: 'vCPU', limit: 100, usage: 42, remains: 58, unitDisplayName: 'cores' },
|
|
132
|
+
{ name: 'RAM', limit: 256, usage: 230, remains: 26, unitDisplayName: 'GB' },
|
|
133
|
+
];
|
|
134
|
+
|
|
135
|
+
export function QuotaWidgetError() {
|
|
136
|
+
const [error, setError] = useState(true);
|
|
137
|
+
const [loading, setLoading] = useState(false);
|
|
138
|
+
|
|
139
|
+
const handleRefresh = () => {
|
|
140
|
+
setLoading(true);
|
|
141
|
+
setTimeout(() => {
|
|
142
|
+
setLoading(false);
|
|
143
|
+
setError(false);
|
|
144
|
+
}, 800);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
// В продукте виджет живёт у правого края страницы — dropdown прижат к правому краю триггера
|
|
149
|
+
<div style={{ display: 'flex', justifyContent: 'flex-end', width: '100%' }}>
|
|
150
|
+
<QuotaWidget
|
|
151
|
+
quotas={QUOTAS}
|
|
152
|
+
projectName='ml-platform-production'
|
|
153
|
+
quotasUrl='#'
|
|
154
|
+
canEditQuota={false}
|
|
155
|
+
loading={loading}
|
|
156
|
+
error={error}
|
|
157
|
+
onRefresh={handleRefresh}
|
|
158
|
+
/>
|
|
159
|
+
</div>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Props
|
|
165
|
+
|
|
166
|
+
#### QuotaWidget
|
|
167
|
+
|
|
168
|
+
**QuotaWidgetProps**
|
|
169
|
+
|
|
170
|
+
| Prop | Type | Default | Description |
|
|
171
|
+
|------|------|---------|-------------|
|
|
172
|
+
| `buttonProps` | `ButtonProps` | — | Свойства кнопки открытия виджета |
|
|
173
|
+
| `canEditQuota` | `boolean` | — | Флаг наличия прав на редактирование квот |
|
|
174
|
+
| `data-test-id` | `string` | — | |
|
|
175
|
+
| `disableSorting` | `boolean` | — | Флаг отключения сортировки квот |
|
|
176
|
+
| `error` | `boolean` | — | Флаг ошибки при загрузке квот |
|
|
177
|
+
| `hideIncreaseQuotaButton` | `boolean` | — | Флаг скрытия кнопки увеличения квоты |
|
|
178
|
+
| `loading` | `boolean` | — | Флаг загрузки квот |
|
|
179
|
+
| `onIncreaseQuotaClick` | `(() => void)` | — | Колбек нажатия на кнопку увеличения квот |
|
|
180
|
+
| `onQuotasUrlClick` | `(() => void)` | — | Колбек клика по ссылке на страницу квот по проекту |
|
|
181
|
+
| `onRefresh` | `() => void` | — | Колбек на обновление списка квот при ошибке |
|
|
182
|
+
| `onWidgetOpen` | `(() => void)` | — | Колбек открытия виджета квот |
|
|
183
|
+
| `projectName` | `string` | — | Название проекта, по которому отображаются квоты |
|
|
184
|
+
| `quotas` | `QuotaItem` | — | Список квот для отображения |
|
|
185
|
+
| `quotasUrl` | `string` | — | Ссылка на страницу квот по проекту |
|
|
186
|
+
|
|
187
|
+
##### Related types
|
|
188
|
+
|
|
189
|
+
**QuotaItem**
|
|
190
|
+
|
|
191
|
+
| Prop | Type | Default | Description |
|
|
192
|
+
|------|------|---------|-------------|
|
|
193
|
+
| `limit` | `number` | — | Лимит квоты |
|
|
194
|
+
| `name` | `string` | — | Название квоты |
|
|
195
|
+
| `remains` | `number` | — | Остаток квоты |
|
|
196
|
+
| `unitDisplayName` | `string` | — | Единица измерения квоты |
|
|
197
|
+
| `usage` | `number` | — | Потребление квоты |
|
|
198
|
+
|
|
199
|
+
#### QuotaWidgetContent
|
|
200
|
+
|
|
201
|
+
**QuotaWidgetContentProps**
|
|
202
|
+
|
|
203
|
+
| Prop | Type | Default | Description |
|
|
204
|
+
|------|------|---------|-------------|
|
|
205
|
+
| `canEditQuota` | `boolean` | — | Флаг наличия прав на редактирование квот |
|
|
206
|
+
| `data-test-id` | `string` | — | |
|
|
207
|
+
| `disableSorting` | `boolean` | — | Флаг отключения сортировки квот |
|
|
208
|
+
| `error` | `boolean` | — | Флаг ошибки при загрузке квот |
|
|
209
|
+
| `hideIncreaseQuotaButton` | `boolean` | — | Флаг скрытия кнопки увеличения квоты |
|
|
210
|
+
| `hideMobileHeader` | `boolean` | `false` | Не рендерить мобильную шапку (её выносят в pinned-`title` контейнера, напр. BottomSheet). <br/> На desktop не влияет. |
|
|
211
|
+
| `hideMobileIncreaseButton` | `boolean` | `false` | Не рендерить мобильную кнопку расширения (её выносят в pinned-`footer` контейнера). <br/> На desktop не влияет. |
|
|
212
|
+
| `loading` | `boolean` | — | Флаг загрузки квот |
|
|
213
|
+
| `onIncreaseQuotaClick` | `(() => void)` | — | Колбек нажатия на кнопку увеличения квот |
|
|
214
|
+
| `onQuotasUrlClick` | `(() => void)` | — | Колбек клика по ссылке на страницу квот по проекту |
|
|
215
|
+
| `onRefresh` | `() => void` | — | Колбек на обновление списка квот при ошибке |
|
|
216
|
+
| `onWidgetOpen` | `(() => void)` | — | Колбек открытия виджета квот |
|
|
217
|
+
| `projectName` | `string` | — | Название проекта, по которому отображаются квоты |
|
|
218
|
+
| `quotas` | `QuotaItem` | — | Список квот для отображения |
|
|
219
|
+
| `quotasUrl` | `string` | — | Ссылка на страницу квот по проекту |
|
|
220
|
+
|
|
221
|
+
##### Related types
|
|
222
|
+
|
|
223
|
+
**QuotaItem**
|
|
224
|
+
|
|
225
|
+
| Prop | Type | Default | Description |
|
|
226
|
+
|------|------|---------|-------------|
|
|
227
|
+
| `limit` | `number` | — | Лимит квоты |
|
|
228
|
+
| `name` | `string` | — | Название квоты |
|
|
229
|
+
| `remains` | `number` | — | Остаток квоты |
|
|
230
|
+
| `unitDisplayName` | `string` | — | Единица измерения квоты |
|
|
231
|
+
| `usage` | `number` | — | Потребление квоты |
|
|
232
|
+
|
|
233
|
+
### Смотри также
|
|
234
|
+
|
|
235
|
+
- **QuotaWidgetMini** — тот же список в аккордеоне без портала.
|
|
236
|
+
- **QuotaWidgetCard** — карточка одной квоты.
|
|
237
|
+
- **Dropdown** — нижележащий портальный примитив.
|
|
238
|
+
|
|
239
|
+
## QuotaWidgetMini
|
|
240
|
+
|
|
241
|
+
Компактный аккордеон со списком квот проекта — counter исчерпанных квот в заголовке и кнопка увеличения квот.
|
|
242
|
+
|
|
243
|
+
Сворачиваемый блок на базе **`Accordion`**: заголовок «Квоты» с counter'ом исчерпанных квот и названием проекта в подзаголовке, внутри — вертикальный список карточек **`QuotaWidgetCard`** и кнопка «Увеличить квоты». Портал не используется — контент раскрывается в потоке документа.
|
|
244
|
+
|
|
245
|
+
### Когда использовать
|
|
246
|
+
|
|
247
|
+
- Сайдбары и узкие панели, где список квот должен раскрываться на месте, без overlay.
|
|
248
|
+
- Mobile / adaptive layout'ы — аккордеон не требует позиционирования портала.
|
|
249
|
+
- Шапка широкой страницы с раскрытием по клику:
|
|
250
|
+
- используйте **`QuotaWidget`**.
|
|
251
|
+
|
|
252
|
+
- ✅ Используйте `defaultExpanded`, если квоты — ключевой контент экрана и должны быть видны сразу.
|
|
253
|
+
- ❌ Контролировать раскрытие снаружи — аккордеон uncontrolled, публичного controlled-API нет.
|
|
254
|
+
|
|
255
|
+
### Анатомия
|
|
256
|
+
|
|
257
|
+
#### Заголовок
|
|
258
|
+
|
|
259
|
+
`Accordion.CollapseBlockSecondary`: title «Квоты», после него `Counter appearance='critical'` с числом исчерпанных квот (скрыт при `loading` / `error`), в подзаголовке — `projectName` с truncate.
|
|
260
|
+
|
|
261
|
+
#### Содержимое
|
|
262
|
+
|
|
263
|
+
- Вертикальный список `QuotaWidgetCard`; исчерпанные квоты поднимаются в начало (`disableSorting` отключает).
|
|
264
|
+
- `loading` — skeleton-карточки; `error` — блок ошибки с кнопкой повтора (`onRefresh`).
|
|
265
|
+
- Кнопка «Увеличить квоты» (`canEditQuota`, `onIncreaseQuotaClick`, скрывается `hideIncreaseQuotaButton`).
|
|
266
|
+
|
|
267
|
+
### Примеры использования
|
|
268
|
+
|
|
269
|
+
#### Раскрыт по умолчанию
|
|
270
|
+
|
|
271
|
+
defaultExpanded + counter исчерпанной квоты в заголовке
|
|
272
|
+
|
|
273
|
+
```tsx
|
|
274
|
+
import { QuotaItem, QuotaWidgetMini } from '@cloud-ru/ds-uikit-product-quota';
|
|
275
|
+
import { useState } from 'react';
|
|
276
|
+
|
|
277
|
+
const QUOTAS: QuotaItem[] = [
|
|
278
|
+
{ name: 'SSD', limit: 1000, usage: 1000, remains: 0, unitDisplayName: 'GB' },
|
|
279
|
+
{ name: 'RAM', limit: 256, usage: 230, remains: 26, unitDisplayName: 'GB' },
|
|
280
|
+
{ name: 'vCPU', limit: 100, usage: 42, remains: 58, unitDisplayName: 'cores' },
|
|
281
|
+
];
|
|
282
|
+
|
|
283
|
+
export function QuotaWidgetMiniExpanded() {
|
|
284
|
+
const [loading, setLoading] = useState(false);
|
|
285
|
+
|
|
286
|
+
const reload = () => {
|
|
287
|
+
setLoading(true);
|
|
288
|
+
setTimeout(() => setLoading(false), 800);
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
return (
|
|
292
|
+
<QuotaWidgetMini
|
|
293
|
+
quotas={QUOTAS}
|
|
294
|
+
projectName='ml-platform-production'
|
|
295
|
+
canEditQuota={false}
|
|
296
|
+
defaultExpanded
|
|
297
|
+
loading={loading}
|
|
298
|
+
error={false}
|
|
299
|
+
onRefresh={reload}
|
|
300
|
+
/>
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Props
|
|
306
|
+
|
|
307
|
+
**QuotaWidgetMiniProps**
|
|
308
|
+
|
|
309
|
+
| Prop | Type | Default | Description |
|
|
310
|
+
|------|------|---------|-------------|
|
|
311
|
+
| `canEditQuota` | `boolean` | — | Флаг наличия прав на редактирование квот |
|
|
312
|
+
| `data-test-id` | `string` | — | |
|
|
313
|
+
| `defaultExpanded` | `boolean` | — | Флаг раскрытия аккордиона по умолчанию |
|
|
314
|
+
| `disableSorting` | `boolean` | — | Флаг отключения сортировки квот |
|
|
315
|
+
| `error` | `boolean` | — | Флаг ошибки при загрузке квот |
|
|
316
|
+
| `hideIncreaseQuotaButton` | `boolean` | — | Флаг скрытия кнопки увеличения квоты |
|
|
317
|
+
| `loading` | `boolean` | — | Флаг загрузки квот |
|
|
318
|
+
| `onIncreaseQuotaClick` | `(() => void)` | — | Колбек нажатия на кнопку увеличения квот |
|
|
319
|
+
| `onRefresh` | `() => void` | — | Колбек на обновление списка квот при ошибке |
|
|
320
|
+
| `onWidgetOpen` | `(() => void)` | — | Колбек открытия виджета квот |
|
|
321
|
+
| `projectName` | `string` | — | Название проекта, по которому отображаются квоты |
|
|
322
|
+
| `quotas` | `QuotaItem` | — | Список квот для отображения |
|
|
323
|
+
|
|
324
|
+
##### Related types
|
|
325
|
+
|
|
326
|
+
**QuotaItem**
|
|
327
|
+
|
|
328
|
+
| Prop | Type | Default | Description |
|
|
329
|
+
|------|------|---------|-------------|
|
|
330
|
+
| `limit` | `number` | — | Лимит квоты |
|
|
331
|
+
| `name` | `string` | — | Название квоты |
|
|
332
|
+
| `remains` | `number` | — | Остаток квоты |
|
|
333
|
+
| `unitDisplayName` | `string` | — | Единица измерения квоты |
|
|
334
|
+
| `usage` | `number` | — | Потребление квоты |
|
|
335
|
+
|
|
336
|
+
### Смотри также
|
|
337
|
+
|
|
338
|
+
- **QuotaWidget** — выпадающий вариант для шапки страницы.
|
|
339
|
+
- **QuotaWidgetCard** — карточка одной квоты.
|
|
340
|
+
- **Accordion** — нижележащий примитив раскрытия.
|
|
341
|
+
|
|
342
|
+
## QuotaWidgetCard
|
|
343
|
+
|
|
344
|
+
Карточка одной квоты — прогресс-бар потребления с цветовыми порогами, tooltip-расшифровка и состояния loading/noData.
|
|
345
|
+
|
|
346
|
+
Карточка одной квоты `QuotaItem`: название, остаток в единицах измерения, **`ProgressBar`** потребления и **`Tooltip`** с расшифровкой «лимит / потреблено / остаток». Используется внутри **`QuotaWidget`** и **`QuotaWidgetMini`**, но доступна и отдельно.
|
|
347
|
+
|
|
348
|
+
### Когда использовать
|
|
349
|
+
|
|
350
|
+
- Страница ресурса или дашборд, где нужно показать одну конкретную квоту.
|
|
351
|
+
- Собственная раскладка квот, не покрываемая `QuotaWidget` / `QuotaWidgetMini`.
|
|
352
|
+
- Список квот проекта целиком:
|
|
353
|
+
- используйте **`QuotaWidget`** или **`QuotaWidgetMini`**.
|
|
354
|
+
|
|
355
|
+
- ✅ Оборачивайте карточку в `PortalContextProvider` — tooltip рендерится в портал.
|
|
356
|
+
- ❌ Передавать `noData` без `onRefresh` — состояние ошибки останется без кнопки восстановления.
|
|
357
|
+
|
|
358
|
+
### Анатомия
|
|
359
|
+
|
|
360
|
+
#### Прогресс потребления
|
|
361
|
+
|
|
362
|
+
Цвет `ProgressBar` зависит от процента потребления (`usage / limit`):
|
|
363
|
+
|
|
364
|
+
- `< 70%` — зелёный.
|
|
365
|
+
- `70–90%` — жёлтый.
|
|
366
|
+
- `>= 90%` — красный; при `remains <= 0` квота считается исчерпанной.
|
|
367
|
+
|
|
368
|
+
#### Состояния
|
|
369
|
+
|
|
370
|
+
- `loading` — skeleton вместо значений.
|
|
371
|
+
- `noData` — `InfoBlock` с текстом ошибки и кнопкой «Обновить» (`onRefresh`).
|
|
372
|
+
|
|
373
|
+
### Примеры использования
|
|
374
|
+
|
|
375
|
+
#### Уровни потребления
|
|
376
|
+
|
|
377
|
+
Зелёный, жёлтый, красный пороги и исчерпанная квота
|
|
378
|
+
|
|
379
|
+
```tsx
|
|
380
|
+
import { QuotaWidgetCard } from '@cloud-ru/ds-uikit-product-quota';
|
|
381
|
+
|
|
382
|
+
export function QuotaCardLevels() {
|
|
383
|
+
return (
|
|
384
|
+
<div style={{ display: 'flex', gap: 12, flexWrap: 'wrap', alignItems: 'center' }}>
|
|
385
|
+
<QuotaWidgetCard quota={{ name: 'Network', limit: 100, usage: 30, remains: 70, unitDisplayName: 'GB' }} />
|
|
386
|
+
<QuotaWidgetCard quota={{ name: 'RAM', limit: 100, usage: 75, remains: 25, unitDisplayName: 'GB' }} />
|
|
387
|
+
<QuotaWidgetCard quota={{ name: 'vCPU', limit: 100, usage: 95, remains: 5, unitDisplayName: 'cores' }} />
|
|
388
|
+
<QuotaWidgetCard quota={{ name: 'SSD', limit: 100, usage: 100, remains: 0, unitDisplayName: 'GB' }} />
|
|
389
|
+
</div>
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
#### Loading
|
|
395
|
+
|
|
396
|
+
```tsx
|
|
397
|
+
import { QuotaWidgetCard } from '@cloud-ru/ds-uikit-product-quota';
|
|
398
|
+
|
|
399
|
+
export function QuotaCardLoading() {
|
|
400
|
+
return (
|
|
401
|
+
<QuotaWidgetCard loading quota={{ name: 'Network', limit: 100, usage: 30, remains: 70, unitDisplayName: 'GB' }} />
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
#### Нет данных и повтор
|
|
407
|
+
|
|
408
|
+
noData показывает InfoBlock; onRefresh возвращает карточку к данным
|
|
409
|
+
|
|
410
|
+
```tsx
|
|
411
|
+
import { QuotaWidgetCard } from '@cloud-ru/ds-uikit-product-quota';
|
|
412
|
+
import { useState } from 'react';
|
|
413
|
+
|
|
414
|
+
const QUOTA = { name: 'Network', limit: 100, usage: 30, remains: 70, unitDisplayName: 'GB' };
|
|
415
|
+
|
|
416
|
+
export function QuotaCardNoData() {
|
|
417
|
+
const [noData, setNoData] = useState(true);
|
|
418
|
+
const [loading, setLoading] = useState(false);
|
|
419
|
+
|
|
420
|
+
const handleRefresh = () => {
|
|
421
|
+
setLoading(true);
|
|
422
|
+
setNoData(false);
|
|
423
|
+
setTimeout(() => setLoading(false), 800);
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
return <QuotaWidgetCard quota={QUOTA} noData={noData} loading={loading} onRefresh={handleRefresh} />;
|
|
427
|
+
}
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
### Props
|
|
431
|
+
|
|
432
|
+
**QuotaWidgetCardProps**
|
|
433
|
+
|
|
434
|
+
| Prop | Type | Default | Description |
|
|
435
|
+
|------|------|---------|-------------|
|
|
436
|
+
| `data-test-id` | `string` | — | |
|
|
437
|
+
| `loading` | `boolean` | `false` | Состояние загрузки (Figma: loading=true) |
|
|
438
|
+
| `noData` | `boolean` | `false` | Состояние «не удалось загрузить данные» (Figma: noData=true) |
|
|
439
|
+
| `onRefresh` | `(() => void)` | — | Колбек кнопки «Обновить» в состоянии noData |
|
|
440
|
+
| `quota` | `QuotaItem` | — | Отображаемая квота |
|
|
441
|
+
|
|
442
|
+
##### Related types
|
|
443
|
+
|
|
444
|
+
**QuotaItem**
|
|
445
|
+
|
|
446
|
+
| Prop | Type | Default | Description |
|
|
447
|
+
|------|------|---------|-------------|
|
|
448
|
+
| `limit` | `number` | — | Лимит квоты |
|
|
449
|
+
| `name` | `string` | — | Название квоты |
|
|
450
|
+
| `remains` | `number` | — | Остаток квоты |
|
|
451
|
+
| `unitDisplayName` | `string` | — | Единица измерения квоты |
|
|
452
|
+
| `usage` | `number` | — | Потребление квоты |
|
|
453
|
+
|
|
454
|
+
### Смотри также
|
|
455
|
+
|
|
456
|
+
- **QuotaWidget** — выпадающий список карточек.
|
|
457
|
+
- **QuotaWidgetMini** — аккордеон с карточками.
|
|
458
|
+
- **ProgressBar** — нижележащий индикатор потребления.
|