Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit aee67f9

Browse files
committedAug 26, 2022
fix(Storage): properly display usage for 0 storage
1 parent ac145b3 commit aee67f9

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed
 

‎src/containers/Storage/StorageGroups/StorageGroups.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,19 @@ function StorageGroups({data, tableSettings, visibleEntities, nodes}: StorageGro
126126
width: 100,
127127
render: ({row}) => {
128128
const usage = getUsage(row, 5);
129-
return (
129+
// without a limit the usage can be evaluated as 0,
130+
// but the absence of a value is more clear
131+
return row.Limit ? (
130132
<Label
131133
theme={getUsageSeverity(usage)}
132134
className={b('usage-label', {overload: usage >= 100})}
133135
>
134136
{usage}%
135137
</Label>
136-
);
138+
) : '-';
137139
},
138-
sortAccessor: getUsage,
140+
// without a limit exclude usage from sort to display at the bottom
141+
sortAccessor: (row) => row.Limit ? getUsage(row) : null,
139142
align: DataTable.LEFT,
140143
},
141144
{

‎src/containers/Storage/utils/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ export const getDegradedSeverity = (group: IStoragePoolGroup) => {
4444
export const getUsageSeverity = generateEvaluator(80, 85);
4545

4646
export const getUsage = (data: IStoragePoolGroup, step = 1) => {
47-
const usage = Math.round((data.Used * 100) / data.Limit);
47+
// if limit is 0, display 0
48+
const usage = Math.round((data.Used * 100) / data.Limit) || 0;
4849

4950
return Math.floor(usage / step) * step;
5051
};

0 commit comments

Comments
 (0)
Please sign in to comment.