ydb-embedded-ui 4.19.0 → 4.19.2

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.19.2](https://github.com/ydb-platform/ydb-embedded-ui/compare/v4.19.1...v4.19.2) (2023-10-12)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * add default data formatter to ProgressViewer ([#552](https://github.com/ydb-platform/ydb-embedded-ui/issues/552)) ([ac372a4](https://github.com/ydb-platform/ydb-embedded-ui/commit/ac372a415e67e7126518d9c5a8d04594b82cf485))
9
+ * **Tenant:** fix tree not fully collapsed bug ([#551](https://github.com/ydb-platform/ydb-embedded-ui/issues/551)) ([8469307](https://github.com/ydb-platform/ydb-embedded-ui/commit/8469307b67d463ed2aafd17b2c0319ea40c1f8d5))
10
+
11
+ ## [4.19.1](https://github.com/ydb-platform/ydb-embedded-ui/compare/v4.19.0...v4.19.1) (2023-10-11)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * add storage value to tb formatter ([#547](https://github.com/ydb-platform/ydb-embedded-ui/issues/547)) ([f1e4377](https://github.com/ydb-platform/ydb-embedded-ui/commit/f1e4377443be493a7072aca33a62b51e381f6841))
17
+
3
18
  ## [4.19.0](https://github.com/ydb-platform/ydb-embedded-ui/compare/v4.18.0...v4.19.0) (2023-10-11)
4
19
 
5
20
 
@@ -1,6 +1,8 @@
1
1
  import cn from 'bem-cn-lite';
2
2
 
3
3
  import type {ValueOf} from '../../types/common';
4
+ import {isNumeric} from '../../utils/utils';
5
+ import {formatNumber, roundToPrecision} from '../../utils/dataFormatters/dataFormatters';
4
6
 
5
7
  import './ProgressViewer.scss';
6
8
 
@@ -18,6 +20,14 @@ export const PROGRESS_VIEWER_SIZE_IDS = {
18
20
 
19
21
  type ProgressViewerSize = ValueOf<typeof PROGRESS_VIEWER_SIZE_IDS>;
20
22
 
23
+ const formatValue = (value?: number) => {
24
+ return formatNumber(roundToPrecision(Number(value), 2));
25
+ };
26
+
27
+ const defaultFormatValues = (value?: number, total?: number) => {
28
+ return [formatValue(value), formatValue(total)];
29
+ };
30
+
21
31
  /*
22
32
 
23
33
  Props description:
@@ -47,7 +57,7 @@ interface ProgressViewerProps {
47
57
  export function ProgressViewer({
48
58
  value,
49
59
  capacity,
50
- formatValues,
60
+ formatValues = defaultFormatValues,
51
61
  percents,
52
62
  className,
53
63
  size = PROGRESS_VIEWER_SIZE_IDS.xs,
@@ -58,15 +68,15 @@ export function ProgressViewer({
58
68
  }: ProgressViewerProps) {
59
69
  let fillWidth = Math.round((parseFloat(String(value)) / parseFloat(String(capacity))) * 100);
60
70
  fillWidth = fillWidth > 100 ? 100 : fillWidth;
61
- let valueText: number | string | undefined = Math.round(Number(value)),
71
+ let valueText: number | string | undefined = value,
62
72
  capacityText: number | string | undefined = capacity,
63
73
  divider = '/';
64
- if (formatValues) {
65
- [valueText, capacityText] = formatValues(Number(value), Number(capacity));
66
- } else if (percents) {
74
+ if (percents) {
67
75
  valueText = fillWidth + '%';
68
76
  capacityText = '';
69
77
  divider = '';
78
+ } else if (formatValues) {
79
+ [valueText, capacityText] = formatValues(Number(value), Number(capacity));
70
80
  }
71
81
 
72
82
  let bg = inverseColorize ? 'scarlet' : 'apple';
@@ -85,14 +95,14 @@ export function ProgressViewer({
85
95
  const text = fillWidth > 60 ? 'contrast0' : 'contrast70';
86
96
 
87
97
  const renderContent = () => {
88
- if (capacityText) {
98
+ if (isNumeric(capacity)) {
89
99
  return `${valueText} ${divider} ${capacityText}`;
90
100
  }
91
101
 
92
102
  return valueText;
93
103
  };
94
104
 
95
- if (!isNaN(Number(value))) {
105
+ if (isNumeric(value)) {
96
106
  return (
97
107
  <div className={b({size}, className)}>
98
108
  <div className={b('line', {bg})} style={lineStyle}></div>
@@ -58,14 +58,14 @@ import './ObjectSummary.scss';
58
58
 
59
59
  const b = cn('object-summary');
60
60
 
61
- const getInitialIsSummaryCollapsed = () => {
62
- return Boolean(localStorage.getItem(DEFAULT_IS_TENANT_COMMON_INFO_COLLAPSED));
63
- };
61
+ const getTenantCommonInfoState = () => {
62
+ const collapsed = Boolean(localStorage.getItem(DEFAULT_IS_TENANT_COMMON_INFO_COLLAPSED));
64
63
 
65
- const initialTenantCommonInfoState = {
66
- triggerExpand: false,
67
- triggerCollapse: false,
68
- collapsed: getInitialIsSummaryCollapsed(),
64
+ return {
65
+ triggerExpand: false,
66
+ triggerCollapse: false,
67
+ collapsed,
68
+ };
69
69
  };
70
70
 
71
71
  function prepareOlapTableSchema(tableSchema: TColumnTableDescription = {}) {
@@ -109,7 +109,8 @@ export function ObjectSummary({
109
109
  const dispatch = useDispatch();
110
110
  const [commonInfoVisibilityState, dispatchCommonInfoVisibilityState] = useReducer(
111
111
  paneVisibilityToggleReducerCreator(DEFAULT_IS_TENANT_COMMON_INFO_COLLAPSED),
112
- initialTenantCommonInfoState,
112
+ undefined,
113
+ getTenantCommonInfoState,
113
114
  );
114
115
  const {
115
116
  data,
@@ -27,14 +27,14 @@ import './Tenant.scss';
27
27
 
28
28
  const b = cn('tenant-page');
29
29
 
30
- const getInitialIsSummaryCollapsed = () => {
31
- return Boolean(localStorage.getItem(DEFAULT_IS_TENANT_SUMMARY_COLLAPSED));
32
- };
30
+ const getTenantSummaryState = () => {
31
+ const collapsed = Boolean(localStorage.getItem(DEFAULT_IS_TENANT_SUMMARY_COLLAPSED));
33
32
 
34
- const initialTenantSummaryState = {
35
- triggerExpand: false,
36
- triggerCollapse: false,
37
- collapsed: getInitialIsSummaryCollapsed(),
33
+ return {
34
+ triggerExpand: false,
35
+ triggerCollapse: false,
36
+ collapsed,
37
+ };
38
38
  };
39
39
 
40
40
  interface TenantProps {
@@ -45,7 +45,8 @@ interface TenantProps {
45
45
  function Tenant(props: TenantProps) {
46
46
  const [summaryVisibilityState, dispatchSummaryVisibilityAction] = useReducer(
47
47
  paneVisibilityToggleReducerCreator(DEFAULT_IS_TENANT_SUMMARY_COLLAPSED),
48
- initialTenantSummaryState,
48
+ undefined,
49
+ getTenantSummaryState,
49
50
  );
50
51
 
51
52
  const {currentSchemaPath, currentSchema: currentItem = {}} = useSelector(
@@ -86,6 +86,10 @@ export const formatStorageValuesToGb = (value?: number, total?: number) => {
86
86
  return formatStorageValues(value, total, 'gb');
87
87
  };
88
88
 
89
+ export const formatStorageValuesToTb = (value?: number, total?: number) => {
90
+ return formatStorageValues(value, total, 'tb');
91
+ };
92
+
89
93
  export const formatNumber = (number?: unknown) => {
90
94
  if (!isNumeric(number)) {
91
95
  return '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-embedded-ui",
3
- "version": "4.19.0",
3
+ "version": "4.19.2",
4
4
  "files": [
5
5
  "dist"
6
6
  ],