Skip to content

Commit 5bd0aa2

Browse files
committed
UI: volumes view: improve display for over-quota volumes
1 parent c126d4a commit 5bd0aa2

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

frontend/pages/VolumesAndMountsPage.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,12 +372,21 @@ export default class VolumesAndMountsPage extends React.Component<
372372
const volumes = volumesMaybe || [];
373373

374374
const blobCount = (vol: Volume) => thousandSeparate(vol.BlobCount);
375-
const free = (vol: Volume) => bytesToHumanReadable(vol.Quota - vol.BlobSizeTotal);
375+
const free = (vol: Volume) => {
376+
const freeBytes = vol.Quota - vol.BlobSizeTotal;
377+
return (freeBytes < 0 ? '- ' : '') + bytesToHumanReadable(Math.abs(freeBytes));
378+
};
376379
const used = (vol: Volume) =>
377380
bytesToHumanReadable(vol.BlobSizeTotal) + ' / ' + bytesToHumanReadable(vol.Quota);
378-
const progressBar = (vol: Volume) => (
379-
<ProgressBar progress={(vol.BlobSizeTotal / vol.Quota) * 100} />
380-
);
381+
const quotaUsed = (vol: Volume) => {
382+
const usedRatio = vol.BlobSizeTotal / vol.Quota;
383+
return (
384+
<ProgressBar
385+
progress={usedRatio * 100}
386+
colour={usedRatio < 1.0 ? 'info' : 'danger'}
387+
/>
388+
);
389+
};
381390

382391
const toRow = (obj: Volume) => {
383392
return (
@@ -393,7 +402,7 @@ export default class VolumesAndMountsPage extends React.Component<
393402
<td>{blobCount(obj)}</td>
394403
<td>{free(obj)}</td>
395404
<td>{used(obj)}</td>
396-
<td>{progressBar(obj)}</td>
405+
<td>{quotaUsed(obj)}</td>
397406
<td>
398407
<Dropdown>
399408
<CommandLink
@@ -508,7 +517,7 @@ export default class VolumesAndMountsPage extends React.Component<
508517
<td>{blobCount(totals)}</td>
509518
<td>{free(totals)}</td>
510519
<td>{used(totals)}</td>
511-
<td>{progressBar(totals)}</td>
520+
<td>{quotaUsed(totals)}</td>
512521
<td />
513522
</tr>
514523
</tfoot>

0 commit comments

Comments
 (0)