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' ;
4
2
import * as React from 'react' ;
5
3
import { useHistory } from 'react-router-dom' ;
6
4
7
- import { DocsLink } from 'src/components/DocsLink/DocsLink' ;
8
5
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' ;
11
7
12
8
import { QuotasTable } from './QuotasTable' ;
13
9
import { useGetLocationsForQuotaService } from './utils' ;
14
10
15
- import type { Quota , QuotaType } from '@linode/api-v4' ;
11
+ import type { Quota } from '@linode/api-v4' ;
16
12
import type { SelectOption } from '@linode/ui' ;
17
13
import type { Theme } from '@mui/material' ;
18
14
19
15
export const Quotas = ( ) => {
20
- const flags = useFlags ( ) ;
21
- const { isGeckoLAEnabled } = useIsGeckoEnabled (
22
- flags . gecko2 ?. enabled ,
23
- flags . gecko2 ?. la
24
- ) ;
25
16
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' ) ;
41
20
42
- const { regions , s3Endpoints } = locationData ;
21
+ const { s3Endpoints } = locationData ;
43
22
const isFetchingLocations =
44
23
'isFetchingS3Endpoints' in locationData
45
24
? locationData . isFetchingS3Endpoints
46
25
: locationData . isFetchingRegions ;
47
26
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
-
59
27
return (
60
28
< >
61
29
< DocumentTitleSegment segment = "Quotas" />
62
30
< Paper
63
31
sx = { ( theme : Theme ) => ( {
64
- marginTop : theme . spacing ( 2 ) ,
32
+ marginTop : theme . spacingFunction ( 16 ) ,
65
33
} ) }
66
34
variant = "outlined"
67
35
>
68
36
< 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 >
69
48
< Stack spacing = { 1 } >
70
49
< 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 } }
76
73
/>
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
- ) }
128
74
</ Stack >
129
75
< Divider spacingBottom = { 40 } spacingTop = { 40 } />
130
76
< Stack
@@ -133,27 +79,19 @@ export const Quotas = () => {
133
79
marginBottom = { 2 }
134
80
>
135
81
< 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 >
148
82
</ Stack >
149
83
< Typography >
150
84
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 > .
152
87
</ Typography >
153
88
< Stack direction = "column" spacing = { 2 } >
154
89
< QuotasTable
155
90
selectedLocation = { selectedLocation }
156
- selectedService = { selectedService }
91
+ selectedService = { {
92
+ label : 'Object Storage' ,
93
+ value : 'object-storage' ,
94
+ } }
157
95
/>
158
96
</ Stack >
159
97
</ Stack >
0 commit comments