Skip to content

Commit 72d3f0a

Browse files
Initial commit - adapt UI to OBJ only
1 parent 41ea17a commit 72d3f0a

File tree

3 files changed

+53
-120
lines changed

3 files changed

+53
-120
lines changed

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

+48-110
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,76 @@
1-
import { quotaTypes } from '@linode/api-v4';
2-
import { useIsGeckoEnabled } from '@linode/shared';
3-
import { Divider, Paper, Select, Stack, Typography } from '@linode/ui';
1+
import { Divider, Notice, Paper, Select, Stack, Typography } from '@linode/ui';
42
import * as React from 'react';
53
import { useHistory } from 'react-router-dom';
64

7-
import { DocsLink } from 'src/components/DocsLink/DocsLink';
85
import { DocumentTitleSegment } from 'src/components/DocumentTitle';
9-
import { RegionSelect } from 'src/components/RegionSelect/RegionSelect';
10-
import { useFlags } from 'src/hooks/useFlags';
6+
import { Link } from 'src/components/Link';
117

128
import { QuotasTable } from './QuotasTable';
139
import { useGetLocationsForQuotaService } from './utils';
1410

15-
import type { Quota, QuotaType } from '@linode/api-v4';
11+
import type { Quota } from '@linode/api-v4';
1612
import type { SelectOption } from '@linode/ui';
1713
import type { Theme } from '@mui/material';
1814

1915
export const Quotas = () => {
20-
const flags = useFlags();
21-
const { isGeckoLAEnabled } = useIsGeckoEnabled(
22-
flags.gecko2?.enabled,
23-
flags.gecko2?.la
24-
);
2516
const history = useHistory();
26-
const [selectedService, setSelectedService] = React.useState<
27-
SelectOption<QuotaType>
28-
>({
29-
label: 'Linodes',
30-
value: 'linode',
31-
});
32-
const [selectedLocation, setSelectedLocation] = React.useState<SelectOption<
33-
Quota['region_applied']
34-
> | null>(null);
35-
const locationData = useGetLocationsForQuotaService(selectedService.value);
36-
37-
const serviceOptions = Object.entries(quotaTypes).map(([key, value]) => ({
38-
label: value,
39-
value: key as QuotaType,
40-
}));
17+
const [selectedLocation, setSelectedLocation] =
18+
React.useState<null | SelectOption<Quota['region_applied']>>(null);
19+
const locationData = useGetLocationsForQuotaService('object-storage');
4120

42-
const { regions, s3Endpoints } = locationData;
21+
const { s3Endpoints } = locationData;
4322
const isFetchingLocations =
4423
'isFetchingS3Endpoints' in locationData
4524
? locationData.isFetchingS3Endpoints
4625
: locationData.isFetchingRegions;
4726

48-
// Handlers
49-
const onSelectServiceChange = (
50-
_event: React.SyntheticEvent<Element, Event>,
51-
value: SelectOption<QuotaType>
52-
) => {
53-
setSelectedService(value);
54-
setSelectedLocation(null);
55-
// remove search params
56-
history.push('/account/quotas');
57-
};
58-
5927
return (
6028
<>
6129
<DocumentTitleSegment segment="Quotas" />
6230
<Paper
6331
sx={(theme: Theme) => ({
64-
marginTop: theme.spacing(2),
32+
marginTop: theme.spacingFunction(16),
6533
})}
6634
variant="outlined"
6735
>
6836
<Stack>
37+
<Typography variant="h2">Object Storage</Typography>
38+
<Notice spacingTop={16} variant="info">
39+
<Typography sx={{ py: 0.5 }}>
40+
View your Object Storage quotas by applying the endpoint filter
41+
below.{' '}
42+
<Link to="https://techdocs.akamai.com/cloud-computing/docs/quotas">
43+
Learn more about quotas
44+
</Link>
45+
.
46+
</Typography>
47+
</Notice>
6948
<Stack spacing={1}>
7049
<Select
71-
label="Select a Service"
72-
onChange={onSelectServiceChange}
73-
options={serviceOptions}
74-
placeholder="Select a service"
75-
value={selectedService}
50+
disabled={isFetchingLocations}
51+
label="Object Storage Endpoint"
52+
loading={isFetchingLocations}
53+
onChange={(_event, value) => {
54+
setSelectedLocation({
55+
label: value?.label,
56+
value: value?.value,
57+
});
58+
history.push('/account/quotas');
59+
}}
60+
options={
61+
s3Endpoints?.map((location) => ({
62+
label: location.label,
63+
value: location.value,
64+
})) ?? []
65+
}
66+
placeholder={
67+
isFetchingLocations
68+
? `Loading S3 endpoints...`
69+
: 'Select an Object Storage S3 endpoint'
70+
}
71+
searchable
72+
sx={{ flexGrow: 1, mr: 2 }}
7673
/>
77-
{selectedService.value === 'object-storage' ? (
78-
<Select
79-
onChange={(_event, value) => {
80-
setSelectedLocation({
81-
label: value?.label,
82-
value: value?.value,
83-
});
84-
history.push('/account/quotas');
85-
}}
86-
options={
87-
s3Endpoints?.map((location) => ({
88-
label: location.label,
89-
value: location.value,
90-
})) ?? []
91-
}
92-
placeholder={
93-
isFetchingLocations
94-
? `Loading ${selectedService.label} S3 endpoints...`
95-
: 'Select an Object Storage S3 endpoint'
96-
}
97-
disabled={isFetchingLocations}
98-
label="Object Storage Endpoint"
99-
loading={isFetchingLocations}
100-
searchable
101-
sx={{ flexGrow: 1, mr: 2 }}
102-
/>
103-
) : (
104-
<RegionSelect
105-
onChange={(_event, region) => {
106-
setSelectedLocation({
107-
label: region.label,
108-
value: region.id,
109-
});
110-
history.push('/account/quotas');
111-
}}
112-
placeholder={
113-
isFetchingLocations
114-
? `Loading ${selectedService.label} regions...`
115-
: `Select a region for ${selectedService.label}`
116-
}
117-
currentCapability={undefined}
118-
disableClearable
119-
disabled={isFetchingLocations}
120-
isGeckoLAEnabled={isGeckoLAEnabled}
121-
loading={isFetchingLocations}
122-
noOptionsText={`No resource found for ${selectedService.label}`}
123-
regions={regions ?? []}
124-
sx={{ flexGrow: 1, mr: 2 }}
125-
value={selectedLocation?.value}
126-
/>
127-
)}
12874
</Stack>
12975
<Divider spacingBottom={40} spacingTop={40} />
13076
<Stack
@@ -133,27 +79,19 @@ export const Quotas = () => {
13379
marginBottom={2}
13480
>
13581
<Typography variant="h3">Quotas</Typography>
136-
<Stack
137-
sx={(theme) => ({
138-
position: 'relative',
139-
top: `-${theme.spacing(2)}`,
140-
})}
141-
alignItems="center"
142-
direction="row"
143-
spacing={3}
144-
>
145-
{/* TODO LIMITS_M1: update once link is available */}
146-
<DocsLink href="#" label="Learn More About Quotas" />
147-
</Stack>
14882
</Stack>
14983
<Typography>
15084
This table shows quotas and usage. If you need to increase a quota,
151-
select <strong>Request an Increase</strong> from the Actions menu.
85+
select Request Increase from the Actions menu. Usage can also be
86+
found using the <Link to="#">S3 APIs</Link>.
15287
</Typography>
15388
<Stack direction="column" spacing={2}>
15489
<QuotasTable
15590
selectedLocation={selectedLocation}
156-
selectedService={selectedService}
91+
selectedService={{
92+
label: 'Object Storage',
93+
value: 'object-storage',
94+
}}
15795
/>
15896
</Stack>
15997
</Stack>

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import type { AttachmentError } from 'src/features/Support/SupportTicketDetail/S
2626
const quotaRowMinHeight = 58;
2727

2828
interface QuotasTableProps {
29-
selectedLocation: SelectOption<Quota['region_applied']> | null;
29+
selectedLocation: null | SelectOption<Quota['region_applied']>;
3030
selectedService: SelectOption<QuotaType>;
3131
}
3232

@@ -96,7 +96,7 @@ export const QuotasTable = (props: QuotasTableProps) => {
9696
<>
9797
<Table
9898
sx={(theme) => ({
99-
marginTop: theme.spacing(2),
99+
marginTop: theme.spacingFunction(16),
100100
minWidth: theme.breakpoints.values.sm,
101101
})}
102102
>
@@ -159,13 +159,13 @@ export const QuotasTable = (props: QuotasTableProps) => {
159159
)}
160160

161161
<Dialog
162+
onClose={() => setSupportModalOpen(false)}
163+
open={supportModalOpen}
162164
sx={{
163165
'& .MuiDialog-paper': {
164166
width: '600px',
165167
},
166168
}}
167-
onClose={() => setSupportModalOpen(false)}
168-
open={supportModalOpen}
169169
title="Increase Quota"
170170
>
171171
{selectedQuota && (

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

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { useRegionsQuery } from '@linode/queries';
22
import { object, string } from 'yup';
33

4-
import {
5-
GLOBAL_QUOTA_LABEL,
6-
GLOBAL_QUOTA_VALUE,
7-
regionSelectGlobalOption,
8-
} from 'src/components/RegionSelect/constants';
4+
import { regionSelectGlobalOption } from 'src/components/RegionSelect/constants';
95
import { useObjectStorageEndpoints } from 'src/queries/object-storage/queries';
106

117
import type { QuotaIncreaseFormFields } from './QuotasIncreaseForm';
@@ -53,7 +49,6 @@ export const useGetLocationsForQuotaService = (
5349
isFetchingS3Endpoints,
5450
regions: null,
5551
s3Endpoints: [
56-
...[{ label: GLOBAL_QUOTA_LABEL, value: GLOBAL_QUOTA_VALUE }],
5752
...(s3Endpoints ?? [])
5853
.map((s3Endpoint) => {
5954
if (!s3Endpoint.s3_endpoint) {

0 commit comments

Comments
 (0)