ydb-embedded-ui 1.10.2 → 1.10.3

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.10.3](https://github.com/ydb-platform/ydb-embedded-ui/compare/v1.10.2...v1.10.3) (2022-08-23)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **Overview:** format undefined values to empty string, not 0 ([1a37c27](https://github.com/ydb-platform/ydb-embedded-ui/commit/1a37c278328ad8eb4397d9507566829f01a9c872))
9
+
3
10
  ## [1.10.2](https://github.com/ydb-platform/ydb-embedded-ui/compare/v1.10.1...v1.10.2) (2022-08-17)
4
11
 
5
12
 
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import cn from 'bem-cn-lite';
4
4
  import './SchemaInfoViewer.scss';
5
5
 
6
- import {formatCPU, formatBytes, formatNumber, formatBps} from '../../../../utils';
6
+ import {formatCPU, formatBytes, formatNumber, formatBps, formatDateTime} from '../../../../utils';
7
7
 
8
8
  import {InfoViewer, createInfoFormatter} from '../../../../components/InfoViewer';
9
9
 
@@ -38,8 +38,8 @@ const formatTableStatsItem = createInfoFormatter({
38
38
  values: {
39
39
  DataSize: formatBytes,
40
40
  IndexSize: formatBytes,
41
- LastAccessTime: (value) => value > 0 ? new Date(Number(value)).toUTCString() : 'N/A',
42
- LastUpdateTime: (value) => value > 0 ? new Date(Number(value)).toUTCString() : 'N/A',
41
+ LastAccessTime: formatDateTime,
42
+ LastUpdateTime: formatDateTime,
43
43
  },
44
44
  defaultValueFormatter: formatNumber,
45
45
  });
@@ -1,14 +1,18 @@
1
1
  import numeral from 'numeral';
2
+ import locales from 'numeral/locales'; // eslint-disable-line no-unused-vars
2
3
  import _ from 'lodash';
3
4
 
4
5
  import {i18n} from './i18n';
5
6
  import {MEGABYTE, TERABYTE, DAY_IN_SECONDS, GIGABYTE} from './constants';
6
-
7
- import locales from 'numeral/locales'; // eslint-disable-line no-unused-vars
7
+ import {isNumeric} from './utils';
8
8
 
9
9
  numeral.locale(i18n.lang);
10
10
 
11
11
  export const formatBytes = (bytes) => {
12
+ if (!isNumeric(bytes)) {
13
+ return '';
14
+ }
15
+
12
16
  // by agreement, display byte values in decimal scale
13
17
  return numeral(bytes).format('0 b');
14
18
  };
@@ -53,13 +57,29 @@ export const formatThroughput = (value, total) => {
53
57
  };
54
58
 
55
59
  export const formatNumber = (number) => {
60
+ if (!isNumeric(number)) {
61
+ return '';
62
+ }
63
+
56
64
  return numeral(number).format();
57
65
  };
58
66
 
59
67
  export const formatCPU = (value) => {
68
+ if (!isNumeric(value)) {
69
+ return '';
70
+ }
71
+
60
72
  return numeral(value / 1000000).format('0.00');
61
73
  };
62
74
 
75
+ export const formatDateTime = (value) => {
76
+ if (!isNumeric(value)) {
77
+ return '';
78
+ }
79
+
80
+ return value > 0 ? new Date(Number(value)).toUTCString() : 'N/A';
81
+ };
82
+
63
83
  export const calcUptime = (milliseconds) => {
64
84
  const currentDate = new Date();
65
85
  return formatUptime((currentDate - Number(milliseconds)) / 1000);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-embedded-ui",
3
- "version": "1.10.2",
3
+ "version": "1.10.3",
4
4
  "files": [
5
5
  "dist"
6
6
  ],