From 29fc62caa19592ca5f123da3d9a29aeefbe1ec26 Mon Sep 17 00:00:00 2001 From: cyril-ui-developer Date: Mon, 8 Dec 2025 15:28:15 -0500 Subject: [PATCH] '0 B' is shown on details page when create pvc with 'EiB' unit. --- frontend/public/components/__tests__/units.spec.js | 6 +++++- frontend/public/components/utils/units.js | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/public/components/__tests__/units.spec.js b/frontend/public/components/__tests__/units.spec.js index f930e4d533f..1cdcb5a9688 100644 --- a/frontend/public/components/__tests__/units.spec.js +++ b/frontend/public/components/__tests__/units.spec.js @@ -181,6 +181,7 @@ describe('units', () => { test_(1073741824, '1 GiB'); test_(1099511627776, '1 TiB'); test_(1125899906842624, '1 PiB'); + test_(1152921504606846976, '1 EiB'); }); describe('should humanize binaryBytesWithoutB values', () => { @@ -219,6 +220,7 @@ describe('units', () => { test_(1073741824, '1 Gi'); test_(1099511627776, '1 Ti'); test_(1125899906842624, '1 Pi'); + test_(1152921504606846976, '1 Ei'); }); describe('should de-humanize binaryBytesWithoutB values', () => { @@ -257,6 +259,7 @@ describe('units', () => { test_('1Gi', 1073741824); test_('1Ti', 1099511627776); test_('1Pi', 1125899906842624); + test_('1Ei', 1152921504606846976); test_('100 i', 100); test_('100 Ki', 102400); }); @@ -283,7 +286,7 @@ describe('units', () => { describe('validate', () => { it('memory', () => { - ['32', '32M', '32Mi'].forEach((v) => { + ['32', '32M', '32Mi', '1Ei'].forEach((v) => { expect(validate.memory(v)).toEqual(undefined); }); @@ -357,6 +360,7 @@ describe('convert to base value', () => { test_('1Gi', 1073741824); test_('1Ti', 1099511627776); test_('1Pi', 1125899906842624); + test_('1Ei', 1152921504606846976); // decimal memory units test_('1k', 1000); diff --git a/frontend/public/components/utils/units.js b/frontend/public/components/utils/units.js index 97725d2ba47..4d2569666ce 100644 --- a/frontend/public/components/utils/units.js +++ b/frontend/public/components/utils/units.js @@ -20,7 +20,7 @@ const TYPES = { divisor: 1000, }, binaryBytes: { - units: ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB'], + units: ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB'], space: true, divisor: 1024, }, @@ -103,7 +103,8 @@ const convertValueWithUnitsToBaseValue = (value, unitArray, divisor) => { } return false; }); - if (startingUnitIndex <= 0) { + + if (startingUnitIndex < 0) { // can't parse return defaultReturn; } @@ -302,7 +303,7 @@ validate.CPU = (value = '') => { return validateNumber(number) || validateCPUUnit(unit); }; -const validMemUnits = new Set(['E', 'P', 'T', 'G', 'M', 'k', 'Pi', 'Ti', 'Gi', 'Mi', 'Ki']); +const validMemUnits = new Set(['E', 'P', 'T', 'G', 'M', 'k', 'Ei', 'Pi', 'Ti', 'Gi', 'Mi', 'Ki']); const validateMemUnit = (value = '') => { if (validMemUnits.has(value)) { return;