Skip to content

Commit 7e2c3ef

Browse files
ref: STORIF-187 - Pagination removed from quotas.
1 parent bc68b80 commit 7e2c3ef

File tree

6 files changed

+17
-66
lines changed

6 files changed

+17
-66
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ vi.mock('./utils', () => ({
4343
useGetLocationsForQuotaService: queryMocks.useGetLocationsForQuotaService,
4444
convertResourceMetric: queryMocks.convertResourceMetric,
4545
pluralizeMetric: queryMocks.pluralizeMetric,
46+
QUOTA_ROW_MIN_HEIGHT: 58,
4647
}));
4748

4849
describe('Quotas', () => {

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const queryMocks = vi.hoisted(() => ({
1616
},
1717
useQueries: vi.fn().mockReturnValue([]),
1818
useQuotaUsageQuery: vi.fn().mockReturnValue({}),
19-
useQuotasQuery: vi.fn().mockReturnValue({}),
19+
useAllQuotasQuery: vi.fn().mockReturnValue({}),
2020
}));
2121

2222
vi.mock('@linode/queries', async () => {
@@ -25,7 +25,7 @@ vi.mock('@linode/queries', async () => {
2525
...actual,
2626
quotaQueries: queryMocks.quotaQueries,
2727
useQuotaUsageQuery: queryMocks.useQuotaUsageQuery,
28-
useQuotasQuery: queryMocks.useQuotasQuery,
28+
useAllQuotasQuery: queryMocks.useAllQuotasQuery,
2929
};
3030
});
3131

@@ -81,13 +81,8 @@ describe('QuotasTable', () => {
8181
isLoading: false,
8282
},
8383
]);
84-
queryMocks.useQuotasQuery.mockReturnValue({
85-
data: {
86-
data: quotas,
87-
page: 1,
88-
pages: 1,
89-
results: 1,
90-
},
84+
queryMocks.useAllQuotasQuery.mockReturnValue({
85+
data: quotas,
9186
isFetching: false,
9287
});
9388
queryMocks.useQuotaUsageQuery.mockReturnValue({

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Dialog, ErrorState } from '@linode/ui';
22
import { useNavigate } from '@tanstack/react-router';
33
import * as React from 'react';
44

5-
import { PaginationFooter } from 'src/components/PaginationFooter/PaginationFooter';
65
import { Table } from 'src/components/Table/Table';
76
import { TableBody } from 'src/components/TableBody';
87
import { TableCell } from 'src/components/TableCell/TableCell';
@@ -46,16 +45,12 @@ export const QuotasTable = (props: QuotasTableProps) => {
4645

4746
const {
4847
data: quotasWithUsage,
49-
quotas,
5048
errorMessage: quotasErrorMessage,
5149
queries: quotaUsageQueries,
5250
isFetching: isFetchingQuotas,
53-
pagination,
5451
} = useGetQuotas(
5552
selectedLocation?.value,
5653
selectedService.value,
57-
'/quotas',
58-
`${collectionName}-table`,
5954
collectionName,
6055
isGlobalScope ? true : hasSelectedLocation
6156
);
@@ -137,18 +132,6 @@ export const QuotasTable = (props: QuotasTableProps) => {
137132
</TableBody>
138133
</Table>
139134

140-
{selectedLocation && !isFetchingQuotas && (
141-
<PaginationFooter
142-
count={quotas?.results ?? 0}
143-
eventCategory="quotas_table"
144-
handlePageChange={pagination.handlePageChange}
145-
handleSizeChange={pagination.handlePageSizeChange}
146-
page={pagination.page}
147-
pageSize={pagination.pageSize}
148-
sx={{ '&.MuiBox-root': { marginTop: 0 } }}
149-
/>
150-
)}
151-
152135
<Dialog
153136
onClose={() => setSupportModalOpen(false)}
154137
open={supportModalOpen}
Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
1-
import { quotaQueries, useQueries, useQuotasQuery } from '@linode/queries';
1+
import { quotaQueries, useAllQuotasQuery, useQueries } from '@linode/queries';
22
import * as React from 'react';
33

44
import {
55
getQuotasFilters,
66
getQuotaVisibilityFilter,
77
} from 'src/features/Account/Quotas/utils';
8-
import { usePaginationV2 } from 'src/hooks/usePaginationV2';
98

109
import type { Filter, QuotaType } from '@linode/api-v4';
11-
import type { ToSubOptions } from '@tanstack/react-router';
1210

1311
export const useGetQuotas = (
1412
selectedLocation: string,
1513
selectedService: QuotaType,
16-
currentRoute: ToSubOptions['to'],
17-
paginationPreferenceKey: string,
1814
collectionName: string,
1915
enabled = true
2016
) => {
21-
const pagination = usePaginationV2({
22-
currentRoute,
23-
initialPage: 1,
24-
preferenceKey: paginationPreferenceKey,
25-
});
26-
2717
const filters: Filter = getQuotasFilters({
2818
location: { label: '', value: selectedLocation },
2919
service: { label: '', value: selectedService },
@@ -36,24 +26,15 @@ export const useGetQuotas = (
3626
error: quotasError,
3727
isError: isQuotasError,
3828
isFetching: isFetchingQuotas,
39-
} = useQuotasQuery(
40-
selectedService,
41-
collectionName,
42-
{
43-
page: pagination.page,
44-
page_size: pagination.pageSize,
45-
},
46-
filters,
47-
enabled
48-
);
29+
} = useAllQuotasQuery(selectedService, collectionName, {}, filters, enabled);
4930

5031
// Quota Usage Queries
5132
// For each quota with has_usage == true,
5233
// fetch the usage in parallel
5334
// This will only fetch for the paginated set
5435
const quotaIdsHavingUsage =
55-
quotas?.data
56-
.filter(
36+
quotas
37+
?.filter(
5738
(quota) => quota.has_usage === true || quota.has_usage === undefined
5839
)
5940
.map((quota) => quota.quota_id) ?? [];
@@ -66,8 +47,8 @@ export const useGetQuotas = (
6647
// Combine the quotas with their usage
6748
const filteredQuotasWithUsage = React.useMemo(
6849
() =>
69-
quotas?.data
70-
.filter((quota) => visiblityFilter.isVisible(quota))
50+
quotas
51+
?.filter((quota) => visiblityFilter.isVisible(quota))
7152
.map((quota, index) => ({
7253
...quota,
7354
usage: quotaUsageQueries?.[index]?.data,
@@ -77,14 +58,12 @@ export const useGetQuotas = (
7758

7859
return {
7960
data: filteredQuotasWithUsage,
80-
quotas,
8161
queries: quotaUsageQueries,
8262
errorMessage:
8363
(quotasError && quotasError[0]?.reason) ||
8464
quotaUsageQueries.find((query) => query.isError)?.error.message,
8565
isError: isQuotasError || quotaUsageQueries.some((query) => query.isError),
8666
isFetching:
8767
isFetchingQuotas || quotaUsageQueries.some((query) => query.isFetching),
88-
pagination,
8968
};
9069
};

packages/manager/src/features/ObjectStorage/SummaryLanding/Partials/EndpointSummaryRow.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ const queryMocks = vi.hoisted(() => ({
1616
}),
1717
},
1818
useQueries: vi.fn().mockReturnValue([]),
19-
useQuotasQuery: vi.fn().mockReturnValue({}),
19+
useAllQuotasQuery: vi.fn().mockReturnValue({}),
2020
}));
2121

2222
vi.mock('@linode/queries', async () => {
2323
const actual = await vi.importActual('@linode/queries');
2424
return {
2525
...actual,
2626
quotaQueries: queryMocks.quotaQueries,
27-
useQuotasQuery: queryMocks.useQuotasQuery,
27+
useAllQuotasQuery: queryMocks.useAllQuotasQuery,
2828
};
2929
});
3030

@@ -98,7 +98,7 @@ describe('EndpointSummaryRow', () => {
9898
},
9999
]);
100100

101-
queryMocks.useQuotasQuery.mockReturnValue({
101+
queryMocks.useAllQuotasQuery.mockReturnValue({
102102
data: {
103103
data: quotasMock,
104104
page: 1,
@@ -138,7 +138,7 @@ describe('EndpointSummaryRow', () => {
138138
},
139139
]);
140140

141-
queryMocks.useQuotasQuery.mockReturnValue({
141+
queryMocks.useAllQuotasQuery.mockReturnValue({
142142
isFetching: false,
143143
isError: true,
144144
error: errorMock,
@@ -172,7 +172,7 @@ describe('EndpointSummaryRow', () => {
172172
},
173173
]);
174174

175-
queryMocks.useQuotasQuery.mockReturnValue({
175+
queryMocks.useAllQuotasQuery.mockReturnValue({
176176
data: {
177177
data: quotasMock,
178178
page: 1,

packages/manager/src/features/ObjectStorage/SummaryLanding/Partials/EndpointSummaryRow.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,7 @@ export const EndpointSummaryRow = ({ endpoint }: Props) => {
1919
data: quotaWithUsage,
2020
isFetching,
2121
isError,
22-
} = useGetQuotas(
23-
endpoint,
24-
'object-storage',
25-
'/object-storage/summary',
26-
'object-storage-summary-table',
27-
'quotas',
28-
Boolean(endpoint)
29-
);
22+
} = useGetQuotas(endpoint, 'object-storage', 'quotas', Boolean(endpoint));
3023

3124
if (isFetching) {
3225
return <TableRowLoading columns={3} />;

0 commit comments

Comments
 (0)