Skip to content

Commit 881a56f

Browse files
Added changeset: New quota properties
1 parent a428ad2 commit 881a56f

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/api-v4": Added
3+
---
4+
5+
New quota properties ([#13177](https://github.com/linode/manager/pull/13177))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface Quota {
2020
/**
2121
* Sets usage column to be n/a when value is false.
2222
*/
23-
has_usage: boolean;
23+
has_usage?: boolean;
2424

2525
/**
2626
* A unique identifier for the quota.

packages/manager/cypress/e2e/core/account/quotas-storage.spec.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ describe('Quota workflow tests', () => {
6060
const mockQuotas = [
6161
quotaFactory.build({
6262
quota_id: `obj-bytes-${selectedDomain}`,
63+
quota_type: 'obj-bytes',
6364
description: randomLabel(50),
6465
endpoint_type: mockSelectedEndpoint.endpoint_type,
6566
quota_limit: 10,
@@ -69,6 +70,7 @@ describe('Quota workflow tests', () => {
6970
}),
7071
quotaFactory.build({
7172
quota_id: `obj-buckets-${selectedDomain}`,
73+
quota_type: 'obj-buckets',
7274
description: randomLabel(50),
7375
endpoint_type: mockSelectedEndpoint.endpoint_type,
7476
quota_limit: 78,
@@ -78,6 +80,7 @@ describe('Quota workflow tests', () => {
7880
}),
7981
quotaFactory.build({
8082
quota_id: `obj-objects-${selectedDomain}`,
83+
quota_type: 'obj-objects',
8184
description: randomLabel(50),
8285
endpoint_type: mockSelectedEndpoint.endpoint_type,
8386
quota_limit: 400,
@@ -134,25 +137,32 @@ describe('Quota workflow tests', () => {
134137
},
135138
}).as('getFeatureFlags');
136139
});
140+
137141
it('Quotas and quota usages display properly', function () {
138-
cy.visitWithLogin('/account/quotas');
142+
cy.visitWithLogin('/quotas');
143+
139144
cy.wait(['@getFeatureFlags', '@getObjectStorageEndpoints']);
145+
140146
// Quotas table placeholder text is shown
141147
cy.get('[data-testid="table-row-empty"]').should('be.visible');
142148

143149
// Object Storage Endpoint field is blank
144150
cy.findByPlaceholderText(placeholderText)
145151
.should('be.visible')
146152
.should('be.enabled');
153+
147154
ui.autocomplete
148155
.findByLabel('Object Storage Endpoint')
149156
.should('be.visible')
150157
.type(this.selectedDomain);
158+
151159
ui.autocompletePopper
152160
.findByTitle(this.selectedDomain, { exact: false })
153161
.should('be.visible')
154162
.click();
163+
155164
cy.wait(['@getQuotas', '@getQuotaUsages']);
165+
156166
cy.get('table[data-testid="table-endpoint-quotas"]')
157167
.find('tbody')
158168
.within(() => {
@@ -200,6 +210,7 @@ describe('Quota workflow tests', () => {
200210
const updatedQuotas = [
201211
quotaFactory.build({
202212
quota_id: `obj-bytes-${updatedDomain}`,
213+
quota_type: 'obj-bytes',
203214
description: randomLabel(50),
204215
endpoint_type: updatedEndpoint.endpoint_type,
205216
quota_limit: 20,
@@ -209,6 +220,7 @@ describe('Quota workflow tests', () => {
209220
}),
210221
quotaFactory.build({
211222
quota_id: `obj-buckets-${updatedDomain}`,
223+
quota_type: 'obj-buckets',
212224
description: randomLabel(50),
213225
endpoint_type: updatedEndpoint.endpoint_type,
214226
quota_limit: 122,
@@ -218,6 +230,7 @@ describe('Quota workflow tests', () => {
218230
}),
219231
quotaFactory.build({
220232
quota_id: `obj-objects-${updatedDomain}`,
233+
quota_type: 'obj-objects',
221234
description: randomLabel(50),
222235
endpoint_type: updatedEndpoint.endpoint_type,
223236
quota_limit: 450,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Quotas } from './Quotas';
99

1010
const queryMocks = vi.hoisted(() => ({
1111
getQuotasFilters: vi.fn().mockReturnValue({}),
12+
getQuotaVisibilityFilter: vi.fn().mockReturnValue({}),
1213
useFlags: vi.fn().mockReturnValue({}),
1314
useGetLocationsForQuotaService: vi.fn().mockReturnValue({}),
1415
useObjectStorageEndpoints: vi.fn().mockReturnValue({}),
@@ -34,6 +35,7 @@ vi.mock('@linode/queries', async () => {
3435

3536
vi.mock('./utils', () => ({
3637
getQuotasFilters: queryMocks.getQuotasFilters,
38+
getQuotaVisibilityFilter: queryMocks.getQuotaVisibilityFilter,
3739
useGetLocationsForQuotaService: queryMocks.useGetLocationsForQuotaService,
3840
convertResourceMetric: queryMocks.convertResourceMetric,
3941
pluralizeMetric: queryMocks.pluralizeMetric,

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ export const QuotasTable = (props: QuotasTableProps) => {
7474
// This will only fetch for the paginated set
7575
const quotaIdsHavingUsage =
7676
quotas?.data
77-
.filter((quota) => quota.has_usage)
77+
.filter(
78+
(quota) => quota.has_usage === true || quota.has_usage === undefined
79+
)
7880
.map((quota) => quota.quota_id) ?? [];
7981
const quotaUsageQueries = useQueries({
8082
queries: quotaIdsHavingUsage.map((quotaId) =>
@@ -152,7 +154,9 @@ export const QuotasTable = (props: QuotasTableProps) => {
152154
filteredQuotasWithUsage.map((quota, index) => {
153155
return (
154156
<QuotasTableRow
155-
hasUsage={quota.has_usage}
157+
hasUsage={
158+
quota.has_usage === true || quota.has_usage === undefined
159+
}
156160
index={index}
157161
isDataPresent={quota.usage?.usage !== null}
158162
key={quota.quota_id}

0 commit comments

Comments
 (0)