Skip to content

Commit

Permalink
fix: show "0" instead of "N/A" when quota limit is 0
Browse files Browse the repository at this point in the history
Closes COPS-6589
  • Loading branch information
pierrebeitz committed Oct 26, 2020
1 parent 529055e commit a2320e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
14 changes: 4 additions & 10 deletions plugins/services/src/js/components/ServicesQuotaOverviewDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,9 @@ export interface ServicesQuotaOverviewDetailProps {
id: string;
}

function getQuotaPercentage(
group: ServiceGroup,
resource: string
): number | null {
const resourceQuota: QuotaResources | undefined = findNestedPropertyInObject(
group.quota,
resource
);
if (!resourceQuota || !resourceQuota.limit) {
function getQuotaPercentage(group: ServiceGroup, resource): number | null {
const resourceQuota = group.quota?.[resource];
if (typeof resourceQuota?.limit !== "number") {
return null;
}

Expand All @@ -61,7 +55,7 @@ function getQuotaConsumedOfLimit(
resource
);

if (!resourceQuota || !resourceQuota.limit) {
if (typeof resourceQuota?.limit !== "number") {
return null;
}
const consumed = QuotaUtil.formatQuotaValueForDisplay(
Expand Down
1 change: 0 additions & 1 deletion tests/_fixtures/quota-management/roles.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"limit": {
"cpus": 2.0,
"disk": 10.0,
"gpus": 0,
"mem": 1024.0
},
"consumed": {
Expand Down

0 comments on commit a2320e0

Please sign in to comment.