Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [M3-8936] - Add Date Presets Functionality to Date Picker component. #11395

Merged
merged 98 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from 96 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
b274baf
unit test coverage for HostNameTableCell
cpathipa Jun 19, 2024
f958dab
Revert "unit test coverage for HostNameTableCell"
cpathipa Jun 19, 2024
5d0a476
Merge branch 'linode:develop' into develop
cpathipa Jun 25, 2024
93aab07
Merge branch 'linode:develop' into develop
cpathipa Jun 25, 2024
d7deb4f
Merge branch 'linode:develop' into develop
cpathipa Jul 1, 2024
a550f05
Merge branch 'linode:develop' into develop
cpathipa Jul 3, 2024
de0f63e
Merge branch 'linode:develop' into develop
cpathipa Jul 5, 2024
426c42c
Merge branch 'linode:develop' into develop
cpathipa Jul 17, 2024
3fb49a6
Merge branch 'linode:develop' into develop
cpathipa Jul 22, 2024
6c76508
Merge branch 'linode:develop' into develop
cpathipa Jul 24, 2024
1653a6b
Merge branch 'linode:develop' into develop
cpathipa Jul 25, 2024
00421cf
Merge branch 'linode:develop' into develop
cpathipa Jul 29, 2024
959730a
Merge branch 'linode:develop' into develop
cpathipa Jul 31, 2024
d9bd490
Merge branch 'linode:develop' into develop
cpathipa Jul 31, 2024
960415e
Merge branch 'linode:develop' into develop
cpathipa Aug 1, 2024
b9f4745
Merge branch 'linode:develop' into develop
cpathipa Aug 2, 2024
b0b9264
Merge branch 'linode:develop' into develop
cpathipa Aug 21, 2024
6c70559
Merge branch 'linode:develop' into develop
cpathipa Aug 28, 2024
96eb34d
Merge branch 'linode:develop' into develop
cpathipa Sep 3, 2024
74b1635
Merge branch 'linode:develop' into develop
cpathipa Sep 4, 2024
70d1422
Merge branch 'linode:develop' into develop
cpathipa Sep 5, 2024
342fd96
Merge branch 'linode:develop' into develop
cpathipa Sep 9, 2024
bfed239
Merge branch 'linode:develop' into develop
cpathipa Sep 13, 2024
8a19f9b
Merge branch 'linode:develop' into develop
cpathipa Sep 17, 2024
9e9c14f
Merge branch 'linode:develop' into develop
cpathipa Sep 17, 2024
a25728e
Merge branch 'linode:develop' into develop
cpathipa Sep 18, 2024
3196f2a
Merge branch 'linode:develop' into develop
cpathipa Sep 19, 2024
4794d04
Merge branch 'linode:develop' into develop
cpathipa Sep 23, 2024
e977a94
Merge branch 'linode:develop' into develop
cpathipa Sep 24, 2024
add3f10
Merge branch 'linode:develop' into develop
cpathipa Sep 24, 2024
2fafd33
Merge branch 'linode:develop' into develop
cpathipa Sep 25, 2024
b3463ae
Merge branch 'linode:develop' into develop
cpathipa Sep 26, 2024
a325e30
Merge branch 'linode:develop' into develop
cpathipa Sep 30, 2024
b1e2a51
chore: [M3-8662] - Update Github Actions actions (#11009)
bnussman-akamai Sep 26, 2024
1b0931b
Merge branch 'develop' of github.com:cpathipa/manager into develop
cpathipa Sep 30, 2024
9b2de1d
Merge branch 'linode:develop' into develop
cpathipa Sep 30, 2024
ff89c50
Merge branch 'linode:develop' into develop
cpathipa Oct 9, 2024
4dbe28d
Merge branch 'linode:develop' into develop
cpathipa Oct 11, 2024
b2b7d97
Merge branch 'linode:develop' into develop
cpathipa Oct 14, 2024
04514de
Merge branch 'linode:develop' into develop
cpathipa Oct 16, 2024
e343821
Merge branch 'linode:develop' into develop
cpathipa Oct 21, 2024
7fd4fa5
Merge branch 'linode:develop' into develop
cpathipa Oct 22, 2024
81ec4f8
Merge branch 'linode:develop' into develop
cpathipa Oct 22, 2024
4e25a94
Basci date picker component
cpathipa Oct 23, 2024
52a7276
Merge remote-tracking branch 'origin/develop' into M3-8611
cpathipa Oct 24, 2024
423f4b7
Test coverage for date picker component
cpathipa Oct 25, 2024
34f03e3
Merge remote-tracking branch 'origin/develop' into M3-8611
cpathipa Oct 30, 2024
f87fbce
DatePicker Stories
cpathipa Oct 31, 2024
f47f919
Custom DateTimePicker component
cpathipa Oct 31, 2024
2578b83
Reusable TimeZone Select Component
cpathipa Oct 31, 2024
43810e7
Create custom DateTimeRangePicker component
cpathipa Oct 31, 2024
fa7bd52
Merge remote-tracking branch 'origin/develop' into M3-8611
cpathipa Nov 6, 2024
3b6f981
Storybook for DateTimePicker
cpathipa Nov 6, 2024
9b10623
Fix tests and remove console warnings
cpathipa Nov 7, 2024
9d32d3d
Merge remote-tracking branch 'origin/develop' into M3-8611
cpathipa Nov 18, 2024
11d8780
changeset
cpathipa Nov 18, 2024
862134f
Merge remote-tracking branch 'origin/develop' into M3-8611
cpathipa Nov 19, 2024
2643bd6
Merge remote-tracking branch 'origin/develop' into M3-8611
cpathipa Nov 20, 2024
7aec8c9
Update packages/manager/src/components/DatePicker/DateTimeRangePicker…
cpathipa Nov 20, 2024
0c379a2
Adjust styles for DatePicker
cpathipa Nov 21, 2024
73e0a20
Merge branch 'M3-8611' of github.com:cpathipa/manager into M3-8611
cpathipa Nov 21, 2024
194b0d2
Adjust styles for DateTimePicker
cpathipa Nov 22, 2024
0ffaade
Merge remote-tracking branch 'origin/develop' into M3-8611
cpathipa Dec 2, 2024
b2d591f
update imports
cpathipa Dec 2, 2024
efcfe5c
Render time and timezone conditionally in DateTimePicker component
cpathipa Dec 2, 2024
2ca7adf
Move DatePicker to UI package
cpathipa Dec 3, 2024
31dc03e
Add DatePicker dependencies
cpathipa Dec 3, 2024
cd875be
Code cleanup
cpathipa Dec 4, 2024
5f35d70
PR feedback
cpathipa Dec 4, 2024
208b2a0
code cleanup
cpathipa Dec 4, 2024
d1c3fa1
Move DatePicker back to src/components
cpathipa Dec 4, 2024
6186d26
Reverting changes
cpathipa Dec 4, 2024
2cd8366
Code cleanup
cpathipa Dec 4, 2024
b8f2d73
Adjust broken tests
cpathipa Dec 4, 2024
51b1a29
Merge remote-tracking branch 'origin/develop' into M3-8611
cpathipa Dec 4, 2024
e523043
Update TimeZoneSelect.tsx
cpathipa Dec 4, 2024
f0dd5c0
Code cleanup
cpathipa Dec 9, 2024
9abec60
Add validation for start date agains end date.
cpathipa Dec 9, 2024
fa3e186
Adjust styles for TimePicker component.
cpathipa Dec 10, 2024
de2097b
Merge remote-tracking branch 'origin/M3-8611' into M3-8936
cpathipa Dec 10, 2024
006371e
Add the functionality to support Date Presets
cpathipa Dec 10, 2024
bf1133f
Merge remote-tracking branch 'origin/develop' into M3-8936
cpathipa Dec 13, 2024
8c465b2
Update presets functionality and add test coverage.
cpathipa Dec 16, 2024
ac59703
Merge remote-tracking branch 'origin/develop' into M3-8936
cpathipa Dec 16, 2024
555a0be
Added changeset: Add Date Presets Functionality to Date Picker component
cpathipa Dec 16, 2024
b5c3606
Persist the preset value
cpathipa Dec 16, 2024
bea7bac
Show the start date and end date fields only when custom is selected
cpathipa Dec 17, 2024
4ff411b
Add calendar icon to DateTimePicker component
cpathipa Dec 18, 2024
510485a
code cleanup and adjust tests
cpathipa Dec 18, 2024
0cf080f
Update packages/manager/src/components/DatePicker/DateTimeRangePicker…
cpathipa Dec 18, 2024
729c184
update components
cpathipa Dec 18, 2024
727c59c
Organize and additional prop support to DateTimeRangePicker component
cpathipa Dec 18, 2024
9ebfb7f
Code cleanup
cpathipa Dec 18, 2024
25dc1e5
Merge remote-tracking branch 'origin/develop' into M3-8936
cpathipa Jan 7, 2025
e856275
PR feedback - @coliu-akamai
cpathipa Jan 7, 2025
15d9134
Move styles to theme level
cpathipa Jan 8, 2025
132ed74
Revert "Move styles to theme level"
cpathipa Jan 8, 2025
69355ac
code cleanup
cpathipa Jan 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11395-added-1734381247482.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Added
---

Add Date Presets Functionality to Date Picker component ([#11395](https://github.com/linode/manager/pull/11395))
3 changes: 3 additions & 0 deletions packages/manager/src/assets/icons/calendar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 31 additions & 57 deletions packages/manager/src/components/DatePicker/DateTimePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { InputAdornment, TextField } from '@linode/ui';
import { Divider } from '@linode/ui';
import { Box } from '@linode/ui';
import { TextField } from '@linode/ui';
import { Grid, Popover } from '@mui/material';
import { Grid, Popover, useTheme } from '@mui/material';
import { AdapterLuxon } from '@mui/x-date-pickers/AdapterLuxon';
import { DateCalendar } from '@mui/x-date-pickers/DateCalendar';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { TimePicker } from '@mui/x-date-pickers/TimePicker';
import React, { useEffect, useState } from 'react';

import Calendar from 'src/assets/icons/calendar.svg';
import { ActionsPanel } from 'src/components/ActionsPanel/ActionsPanel';

import { TimeZoneSelect } from './TimeZoneSelect';
Expand Down Expand Up @@ -66,22 +67,33 @@ export const DateTimePicker = ({
onApply,
onCancel,
onChange,
placeholder = 'yyyy-MM-dd HH:mm',
placeholder = 'Select Date',
showTime = true,
showTimeZone = true,
sx,
timeSelectProps = {},
timeZoneSelectProps = {},
value = null,
}: DateTimePickerProps) => {
const theme = useTheme<Theme>();

const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);

// Current and original states
const [selectedDateTime, setSelectedDateTime] = useState<DateTime | null>(
value
);
const [selectedTimeZone, setSelectedTimeZone] = useState<null | string>(
timeZoneSelectProps.value || null
);

const [originalDateTime, setOriginalDateTime] = useState<DateTime | null>(
value
);
const [originalTimeZone, setOriginalTimeZone] = useState<null | string>(
timeZoneSelectProps.value || null
);

const TimePickerFieldProps: TextFieldProps = {
label: timeSelectProps?.label ?? 'Select Time',
noMarginTop: true,
Expand Down Expand Up @@ -115,6 +127,8 @@ export const DateTimePicker = ({

const handleApply = () => {
setAnchorEl(null);
setOriginalDateTime(selectedDateTime);
setOriginalTimeZone(selectedTimeZone);
onChange(selectedDateTime);

if (onApply) {
Expand All @@ -124,6 +138,9 @@ export const DateTimePicker = ({

const handleClose = () => {
setAnchorEl(null);
setSelectedDateTime(originalDateTime);
setSelectedTimeZone(originalTimeZone);

if (onCancel) {
onCancel();
}
Expand All @@ -139,16 +156,25 @@ export const DateTimePicker = ({
<LocalizationProvider dateAdapter={AdapterLuxon}>
<Box sx={{ minWidth: '300px', ...sx }}>
<TextField
InputProps={{
readOnly: true,
startAdornment: (
<InputAdornment position="start">
<Calendar />
</InputAdornment>
),
sx: { paddingLeft: theme.spacing() },
}}
value={
selectedDateTime
? `${selectedDateTime.toFormat(format)}${
selectedTimeZone ? ` (${selectedTimeZone})` : ''
}`
: ''
}
InputProps={{ readOnly: true }}
errorText={errorText}
label={label}
noMarginTop
onClick={(event) => setAnchorEl(event.currentTarget)}
placeholder={placeholder}
/>
Expand All @@ -165,29 +191,6 @@ export const DateTimePicker = ({
onChange={handleDateChange}
value={selectedDateTime || null}
{...dateCalendarProps}
// TODO: Move styling customization to global theme styles.
sx={(theme: Theme) => ({
'& .MuiDayCalendar-weekContainer, & .MuiDayCalendar-header': {
justifyContent: 'space-between',
},
'& .MuiDayCalendar-weekDayLabel': {
fontSize: '0.875rem',
},
'& .MuiPickersCalendarHeader-label': {
fontFamily: theme.font.bold,
},
'& .MuiPickersCalendarHeader-root': {
borderBottom: `1px solid ${theme.borderColors.divider}`,
fontSize: '0.875rem',
paddingBottom: theme.spacing(1),
},
'& .MuiPickersDay-root': {
fontSize: '0.875rem',
margin: `${theme.spacing(0.5)}px`,
},
borderRadius: `${theme.spacing(2)}`,
borderWidth: '0px',
})}
/>
<Grid
container
Expand All @@ -198,32 +201,6 @@ export const DateTimePicker = ({
<Grid item xs={4}>
<TimePicker
slotProps={{
actionBar: {
sx: (theme: Theme) => ({
justifyContent: 'center',
marginBottom: theme.spacing(1 / 2),
marginTop: theme.spacing(1 / 2),
padding: 0,
}),
},
layout: {
sx: (theme: Theme) => ({
'& .MuiPickersLayout-contentWrapper': {
borderBottom: `1px solid ${theme.borderColors.divider}`,
},
border: `1px solid ${theme.borderColors.divider}`,
}),
},
openPickerButton: {
sx: { padding: 0 },
},
popper: {
sx: (theme: Theme) => ({
ul: {
borderColor: `${theme.borderColors.divider} !important`,
},
}),
},
textField: TimePickerFieldProps,
}}
onChange={handleTimeChange}
Expand All @@ -247,10 +224,6 @@ export const DateTimePicker = ({
<Divider />
<Box display="flex" justifyContent="flex-end">
<ActionsPanel
primaryButtonProps={{
label: 'Apply',
onClick: handleApply,
}}
secondaryButtonProps={{
buttonType: 'outlined',
label: 'Cancel',
Expand All @@ -260,6 +233,7 @@ export const DateTimePicker = ({
marginBottom: theme.spacing(1),
marginRight: theme.spacing(2),
})}
primaryButtonProps={{ label: 'Apply', onClick: handleApply }}
/>
</Box>
</Popover>
Expand Down
Loading
Loading