From 5866f43efdd1813dbdee71f374014cdd8f875053 Mon Sep 17 00:00:00 2001 From: Aurorum <43215253+Aurorum@users.noreply.github.com> Date: Mon, 8 Jan 2024 23:26:52 +0000 Subject: [PATCH 1/2] Media: Show Storage Count to 2 Decimal Places --- client/blocks/plan-storage/bar.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/blocks/plan-storage/bar.jsx b/client/blocks/plan-storage/bar.jsx index 16a5c71e880ec..37d2a82a7e082 100644 --- a/client/blocks/plan-storage/bar.jsx +++ b/client/blocks/plan-storage/bar.jsx @@ -29,8 +29,11 @@ export class PlanStorageBar extends Component { } const percent = Math.min( - Math.round( - ( ( mediaStorage.storage_used_bytes / mediaStorage.max_storage_bytes ) * 1000 ) / 10 + parseFloat( + ( + ( ( mediaStorage.storage_used_bytes / mediaStorage.max_storage_bytes ) * 1000 ) / + 10 + ).toFixed( 2 ) ), 100 ); From 8c5107b3ddbe851a8bf056539c3d0635032356c4 Mon Sep 17 00:00:00 2001 From: Aurorum <43215253+Aurorum@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:48:05 +0000 Subject: [PATCH 2/2] Only apply to <1% --- client/blocks/plan-storage/bar.jsx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/client/blocks/plan-storage/bar.jsx b/client/blocks/plan-storage/bar.jsx index 37d2a82a7e082..b6204af010df9 100644 --- a/client/blocks/plan-storage/bar.jsx +++ b/client/blocks/plan-storage/bar.jsx @@ -28,15 +28,14 @@ export class PlanStorageBar extends Component { return null; } - const percent = Math.min( - parseFloat( - ( - ( ( mediaStorage.storage_used_bytes / mediaStorage.max_storage_bytes ) * 1000 ) / - 10 - ).toFixed( 2 ) - ), - 100 - ); + const percentInteger = + ( ( mediaStorage.storage_used_bytes / mediaStorage.max_storage_bytes ) * 1000 ) / 10; + + // Format to 2 decimal places when under 1%. + const percent = + percentInteger < 1 + ? Math.min( parseFloat( percentInteger.toFixed( 2 ) ), 100 ) + : Math.min( Math.round( percentInteger ), 100 ); const classes = classNames( className, 'plan-storage__bar', { 'is-alert': percent > ALERT_PERCENT,