Skip to content

Commit 088a9bf

Browse files
Resolve merge conflicts
1 parent f9d97e8 commit 088a9bf

File tree

2 files changed

+104
-79
lines changed

2 files changed

+104
-79
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Tech Stories
3+
---
4+
5+
DBaaS: Replace the dropdowns in Database cluster settings page with CDS select web component ([#12570](https://github.com/linode/manager/pull/12570))

packages/manager/src/features/Databases/DatabaseDetail/DatabaseSettings/MaintenanceWindow.tsx

Lines changed: 99 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import { yupResolver } from '@hookform/resolvers/yup';
22
import { useDatabaseMutation } from '@linode/queries';
33
import {
44
Autocomplete,
5+
Box,
56
FormControl,
67
FormControlLabel,
8+
InputLabel,
79
Notice,
810
Radio,
911
RadioGroup,
@@ -13,7 +15,7 @@ import {
1315
} from '@linode/ui';
1416
import { updateMaintenanceSchema } from '@linode/validation';
1517
import { styled } from '@mui/material/styles';
16-
import { Button } from 'akamai-cds-react-components';
18+
import { Button, Select } from 'akamai-cds-react-components';
1719
import { DateTime } from 'luxon';
1820
import { useSnackbar } from 'notistack';
1921
import * as React from 'react';
@@ -157,89 +159,107 @@ export const MaintenanceWindow = (props: Props) => {
157159
<Controller
158160
control={control}
159161
name="day_of_week"
160-
render={({ field, fieldState }) => (
161-
<Autocomplete
162-
autoHighlight
163-
disableClearable
164-
disabled={disabled}
165-
errorText={fieldState.error?.message}
166-
isOptionEqualToValue={(option, value) =>
167-
option.value === value.value
168-
}
169-
label="Day of Week"
170-
noMarginTop
171-
onChange={(_, day) => {
172-
field.onChange(day.value);
173-
weekSelectionModifier(day.label, weekSelectionMap);
174-
}}
175-
options={daySelectionMap}
176-
placeholder="Choose a day"
177-
renderOption={(props, option) => (
178-
<li {...props}>{option.label}</li>
179-
)}
180-
textFieldProps={{
181-
dataAttrs: {
182-
'data-qa-weekday-select': true,
183-
},
184-
}}
185-
value={daySelectionMap.find(
186-
(thisOption) => thisOption.value === dayOfWeek
187-
)}
188-
/>
162+
render={({ field }) => (
163+
<Box>
164+
<InputLabel
165+
data-qa-dropdown-label="day-of-week-select"
166+
data-qa-textfield-label="Day of Week"
167+
sx={{
168+
marginBottom: '8px',
169+
transform: 'none',
170+
}}
171+
>
172+
Day of Week
173+
</InputLabel>
174+
<Box
175+
data-qa-autocomplete="Day of Week"
176+
sx={{ width: '125px' }}
177+
>
178+
<Select
179+
autocomplete
180+
id="dayOfWeek"
181+
items={daySelectionMap}
182+
onChange={(e: CustomEvent) => {
183+
const day: { label: string; value: number } =
184+
e.detail;
185+
field.onChange(day.value);
186+
weekSelectionModifier(day.label, weekSelectionMap);
187+
}}
188+
placeholder="Choose a day"
189+
selected={daySelectionMap.find(
190+
(thisOption) => thisOption.value === dayOfWeek
191+
)}
192+
valueFn={(day: { label: string; value: number }) =>
193+
`${day.label}`
194+
}
195+
/>
196+
</Box>
197+
</Box>
189198
)}
190199
/>
191200
</FormControl>
192201
<FormControl>
193-
<div style={{ alignItems: 'center', display: 'flex' }}>
194-
<Controller
195-
control={control}
196-
name="hour_of_day"
197-
render={({ field, fieldState }) => (
198-
<Autocomplete
199-
autoHighlight
200-
defaultValue={hourSelectionMap.find(
201-
(option) => option.value === 20
202-
)}
203-
disableClearable
204-
disabled={disabled}
205-
errorText={fieldState.error?.message}
206-
label="Time"
207-
noMarginTop
208-
onChange={(_, hour) => {
209-
field.onChange(hour?.value);
210-
}}
211-
options={hourSelectionMap}
212-
placeholder="Choose a time"
213-
renderOption={(props, option) => (
214-
<li {...props}>{option.label}</li>
215-
)}
216-
textFieldProps={{
217-
dataAttrs: {
218-
'data-qa-time-select': true,
219-
},
202+
<Controller
203+
control={control}
204+
name="hour_of_day"
205+
render={({ field }) => (
206+
<Box data-qa-autocomplete="Time">
207+
<Box>
208+
<InputLabel
209+
data-qa-dropdown-label="time-select"
210+
data-qa-textfield-label="Time"
211+
htmlFor="time"
212+
sx={{
213+
marginBottom: '8px',
214+
transform: 'none',
215+
}}
216+
>
217+
Time
218+
</InputLabel>
219+
</Box>
220+
<Box
221+
sx={{
222+
display: 'flex',
220223
}}
221-
value={hourSelectionMap.find(
222-
(thisOption) => thisOption.value === hourOfDay
223-
)}
224-
/>
225-
)}
226-
/>
227-
<TooltipIcon
228-
status="info"
229-
sxTooltipIcon={{
230-
marginTop: '1.75rem',
231-
padding: '0px 8px',
232-
}}
233-
text={
234-
<Typography>
235-
UTC is {utcOffsetText(utcOffsetInHours)} hours compared
236-
to your local timezone. Click{' '}
237-
<Link to="/profile/display">here</Link> to view or
238-
change your timezone settings.
239-
</Typography>
240-
}
241-
/>
242-
</div>
224+
>
225+
<Box sx={{ width: '120px' }}>
226+
<Select
227+
autocomplete
228+
disabled={disabled}
229+
id="time"
230+
items={hourSelectionMap}
231+
onChange={(e: CustomEvent) => {
232+
const hour: { label: string; value: number } =
233+
e.detail;
234+
field.onChange(hour?.value);
235+
}}
236+
placeholder="Choose a time"
237+
selected={hourSelectionMap.find(
238+
(thisOption) => thisOption.value === hourOfDay
239+
)}
240+
valueFn={(time: { label: string }) =>
241+
`${time.label}`
242+
}
243+
/>
244+
</Box>
245+
<TooltipIcon
246+
status="info"
247+
sxTooltipIcon={{
248+
padding: '0px 8px',
249+
}}
250+
text={
251+
<Typography>
252+
UTC is {utcOffsetText(utcOffsetInHours)} hours
253+
compared to your local timezone. Click{' '}
254+
<Link to="/profile/display">here</Link> to view or
255+
change your timezone settings.
256+
</Typography>
257+
}
258+
/>
259+
</Box>
260+
</Box>
261+
)}
262+
/>
243263
</FormControl>
244264
</Stack>
245265
{isLegacy && (

0 commit comments

Comments
 (0)