Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/api-v4/src/quotas/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export interface Quota {
*/
quota_name: string;

/**
* Customer facing id describing the quota.
*/
quota_type_id: string;

/**
* The region slug to which this limit applies.
*
Expand All @@ -52,6 +57,11 @@ export interface Quota {
* For OBJ limits only.
*/
s3_endpoint?: string;

/**
* Sets usage column to be n/a when value is "none".
*/
usage_mode: 'none' | 'normal';
}

/**
Expand Down
2 changes: 2 additions & 0 deletions packages/manager/src/factories/quotas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ export const quotaFactory = Factory.Sync.makeFactory<Quota>({
quota_id: Factory.each((id) => id.toString()),
quota_limit: 50,
quota_name: 'Linode Dedicated vCPUs',
quota_type_id: 'linode-dedicated-cpus',
region_applied: 'us-east',
resource_metric: 'CPU',
usage_mode: 'normal',
});

export const quotaUsageFactory = Factory.Sync.makeFactory<QuotaUsage>({
Expand Down
20 changes: 17 additions & 3 deletions packages/manager/src/features/Account/Quotas/QuotasTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ import type { AttachmentError } from 'src/features/Support/SupportTicketDetail/S

const quotaRowMinHeight = 58;

const EXCLUDED_QUOTA_TYPE_IDS = [
'obj-per-ip-upload-throughput',
'obj-per-ip-download-throughput',
'obj-per-ip-concurrent-requests',
];

interface QuotasTableProps {
selectedLocation: null | SelectOption<Quota['region_applied']>;
selectedService: SelectOption<QuotaType>;
Expand Down Expand Up @@ -72,9 +78,13 @@ export const QuotasTable = (props: QuotasTableProps) => {
);

// Quota Usage Queries
// For each quota, fetch the usage in parallel
// For each quota with usage_mode == normal,
// fetch the usage in parallel
// This will only fetch for the paginated set
const quotaIds = quotas?.data.map((quota) => quota.quota_id) ?? [];
const quotaIds =
quotas?.data
.filter((quota) => quota.usage_mode === 'normal')
.map((quota) => quota.quota_id) ?? [];
const quotaUsageQueries = useQueries({
queries: quotaIds.map((quotaId) =>
quotaQueries.service(selectedService.value)._ctx.usage(quotaId)
Expand Down Expand Up @@ -147,7 +157,11 @@ export const QuotasTable = (props: QuotasTableProps) => {
/>
) : (
quotasWithUsage.map((quota, index) => {
const hasQuotaUsage = quota.usage?.usage !== null;
const hasQuotaUsage =
quota.usage_mode === 'normal' && quota.usage?.usage !== null;
if (EXCLUDED_QUOTA_TYPE_IDS.includes(quota.quota_type_id)) {
return null;
}

return (
<QuotasTableRow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const QuotasTableRow = (props: QuotasTableRowProps) => {
usage={quota.usage?.usage ?? 0}
/>
) : (
<Typography>Data not available</Typography>
<Typography>n/a</Typography>
)}
</Box>
</TableCell>
Expand Down
14 changes: 13 additions & 1 deletion packages/manager/src/features/Account/Quotas/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { useRegionsQuery } from '@linode/queries';
import { capitalize, readableBytes } from '@linode/utilities';
import {
capitalize,
convertStorageUnit,
readableBytes,
} from '@linode/utilities';
import { object, string } from 'yup';

import { regionSelectGlobalOption } from 'src/components/RegionSelect/constants';
Expand Down Expand Up @@ -193,6 +197,14 @@ export const convertResourceMetric = ({
};
}

if (initialResourceMetric === 'byte_per_second') {
return {
convertedUsage: 0,
convertedResourceMetric: 'Gbps',
convertedLimit: convertStorageUnit('B', initialLimit, 'GB'),
};
}

return {
convertedUsage: initialUsage,
convertedLimit: initialLimit,
Expand Down