Skip to content

Commit 1aa8634

Browse files
new: STORIF-183 - Quotas table modified to show throughputs.
1 parent 5faffaa commit 1aa8634

File tree

5 files changed

+37
-5
lines changed

5 files changed

+37
-5
lines changed

packages/api-v4/src/quotas/types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ export interface Quota {
1010
*/
1111
description: string;
1212

13+
/**
14+
* Defines if the quota should be visible in the table of quotas.
15+
*
16+
*/
17+
display_mode: 'hidden' | 'visible';
18+
1319
/**
1420
* The OBJ endpoint type to which this limit applies.
1521
*
@@ -52,6 +58,11 @@ export interface Quota {
5258
* For OBJ limits only.
5359
*/
5460
s3_endpoint?: string;
61+
62+
/**
63+
* Sets usage column to be n/a when value is "none".
64+
*/
65+
usage_mode: 'none' | 'normal';
5566
}
5667

5768
/**

packages/manager/src/factories/quotas.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export const quotaFactory = Factory.Sync.makeFactory<Quota>({
99
quota_name: 'Linode Dedicated vCPUs',
1010
region_applied: 'us-east',
1111
resource_metric: 'CPU',
12+
display_mode: 'visible',
13+
usage_mode: 'normal',
1214
});
1315

1416
export const quotaUsageFactory = Factory.Sync.makeFactory<QuotaUsage>({

packages/manager/src/features/Account/Quotas/QuotasTable.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,13 @@ export const QuotasTable = (props: QuotasTableProps) => {
7272
);
7373

7474
// Quota Usage Queries
75-
// For each quota, fetch the usage in parallel
75+
// For each quota with usage_mode == normal,
76+
// fetch the usage in parallel
7677
// This will only fetch for the paginated set
77-
const quotaIds = quotas?.data.map((quota) => quota.quota_id) ?? [];
78+
const quotaIds =
79+
quotas?.data
80+
.filter((quota) => quota.usage_mode === 'normal')
81+
.map((quota) => quota.quota_id) ?? [];
7882
const quotaUsageQueries = useQueries({
7983
queries: quotaIds.map((quotaId) =>
8084
quotaQueries.service(selectedService.value)._ctx.usage(quotaId)
@@ -147,7 +151,10 @@ export const QuotasTable = (props: QuotasTableProps) => {
147151
/>
148152
) : (
149153
quotasWithUsage.map((quota, index) => {
150-
const hasQuotaUsage = quota.usage?.usage !== null;
154+
const hasQuotaUsage =
155+
quota.usage_mode === 'normal' && quota.usage?.usage !== null;
156+
157+
if (quota.display_mode === 'hidden') return null;
151158

152159
return (
153160
<QuotasTableRow

packages/manager/src/features/Account/Quotas/QuotasTableRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export const QuotasTableRow = (props: QuotasTableRowProps) => {
129129
usage={quota.usage?.usage ?? 0}
130130
/>
131131
) : (
132-
<Typography>Data not available</Typography>
132+
<Typography>n/a</Typography>
133133
)}
134134
</Box>
135135
</TableCell>

packages/manager/src/features/Account/Quotas/utils.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { useRegionsQuery } from '@linode/queries';
2-
import { capitalize, readableBytes } from '@linode/utilities';
2+
import {
3+
capitalize,
4+
convertStorageUnit,
5+
readableBytes,
6+
} from '@linode/utilities';
37
import { object, string } from 'yup';
48

59
import { regionSelectGlobalOption } from 'src/components/RegionSelect/constants';
@@ -193,6 +197,14 @@ export const convertResourceMetric = ({
193197
};
194198
}
195199

200+
if (initialResourceMetric === 'byte_per_second') {
201+
return {
202+
convertedUsage: 0,
203+
convertedResourceMetric: 'Gbps',
204+
convertedLimit: convertStorageUnit('B', initialLimit, 'GB'),
205+
};
206+
}
207+
196208
return {
197209
convertedUsage: initialUsage,
198210
convertedLimit: initialLimit,

0 commit comments

Comments
 (0)