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

Conversation

cpathipa
Copy link
Contributor

@cpathipa cpathipa commented Dec 10, 2024

Description 📝

Add Date Presets Functionality to Date Range Picker component.

Changes 🔄

List any change(s) relevant to the reviewer.

  • Add Date Presets to DateRangePicker component.
  • Test coverage to DateRangePicker

Target release date 🗓️

N/A

Preview 📷

DateTimeRangePicker-v3.mov

How to test 🧪

Verification steps

(How to verify changes)

  • Checkout the branch and run locally
  • Import the DateRangePicker component in any CM page
  • You can use below example usage
 <DateTimeRangePicker
        onChange={({ end, preset, start }) => {
        }}
        endDateProps={{ label: 'End Date and Time', value: null }}
        format="yyyy-MM-dd HH:mm"
        presetsProps={{ enablePresets: true }}
        startDateProps={{ label: 'Start Date and Time', value: null }}
      />
Author Checklists

As an Author, to speed up the review process, I considered 🤔

👀 Doing a self review
❔ Our contribution guidelines
🤏 Splitting feature into small PRs
➕ Adding a changeset
🧪 Providing/improving test coverage
🔐 Removing all sensitive information from the code and PR description
🚩 Using a feature flag to protect the release
👣 Providing comprehensive reproduction steps
📑 Providing or updating our documentation
🕛 Scheduling a pair reviewing session
📱 Providing mobile support
♿ Providing accessibility support


  • I have read and considered all applicable items listed above.

As an Author, before moving this PR from Draft to Open, I confirmed ✅

  • All unit tests are passing
  • TypeScript compilation succeeded without errors
  • Code passes all linting rules

cpathipa added 30 commits June 19, 2024 09:06
@nikhagra-akamai
Copy link
Contributor

Screenshot 2024-12-18 at 4 19 18 PM

Warning are coming up in console while changing drop down values

Copy link
Contributor Author

@cpathipa cpathipa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed all the feedback and PR is ready for review.

import { Box } from '@linode/ui';
import { TextField } from '@linode/ui';
import CalendarTodayIcon from '@mui/icons-material/CalendarToday';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the MUI calendar icon is being used, but it will be replaced with the SVG provided by the UX.

Comment on lines +162 to +166
sx={{
color: '#c2c2ca !important',
fontSize: '20px !important',
left: '8px',
position: 'absolute',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will be removed when replacing MUI calendar icon with give SVG.


beforeEach(() => {
// Mock DateTime.now to return a fixed datetime
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mocked the time instance for reliable tests.

Copy link
Contributor

@coliu-akamai coliu-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks Chandra! Looking good so far, left a few comments

did you get a change to investigate the storybook issue? Interestingly, for LinodeSelect and ImageSelect, I'm only seeing issues locally, not on design.linode.com

Comment on lines 287 to 298
<Box alignContent="flex-end">
<StyledActionButton
onClick={() => {
setShowPresets(true);
setPresetValue(presetsDefaultValue);
}}
style={{ alignSelf: 'flex-start' }}
variant="text"
>
Presets
</StyledActionButton>
</Box>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's an error, the Presets button doesn't align properly:

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want the custom inputs and the error here to clear if we click on 'Presets' again and select a different preset? I can see a case for either

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the alignment in error scenario e856275

/>
</InputAdornment>
),
sx: { paddingLeft: '32px' },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to use theme spacing instead of hardcoding values? eg theme.spacing(4)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpathipa Let's use the Calendar design tokens for all the styling here. You will have to add it to the light/dark theme index files and expose it here if you need to use those tokens at the component level. You could also apply them at the theme level under MuiDateField

null
);
// Check if the onChange function is called with the expected value
expect(onChangeMock).toHaveBeenCalledWith({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heads up, this test fails (see github actions comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the test with dynamic month and year e856275

let newEndDateTime: DateTime | null = null;

switch (value) {
case '24hours':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have a type for this, rather than using strings? something like type DatePresetType = '24hours' | or an enum

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, e856275

@linode-gh-bot
Copy link
Collaborator

Cloud Manager UI test results

🎉 474 passing tests on test run #13 ↗︎

❌ Failing✅ Passing↪️ Skipped🕐 Duration
0 Failing474 Passing2 Skipped95m 0s

@nikhagra-akamai
Copy link
Contributor

@cpathipa / @jaalah-akamai / @coliu-akamai I've enhance the component on top of Chandra's PR. Give it a look.

cpathipa#3

@nikhagra-akamai
Copy link
Contributor

@cpathipa / @jaalah-akamai / @coliu-akamai I've enhance the component on top of Chandra's PR. Give it a look.

cpathipa#3

Screen.Recording.2025-01-08.at.4.49.35.PM.mov

Screenshot 2025-01-08 at 4 42 58 PM

Copy link
Contributor

@coliu-akamai coliu-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we plan to merge in @nikhagra-akamai's changes to this PR? Left a couple of comments on there

spoke async about additional styling work + other stuff - thanks Chandra!

@coliu-akamai coliu-akamai added the Approved Multiple approvals and ready to merge! label Jan 8, 2025
@cpathipa
Copy link
Contributor Author

cpathipa commented Jan 8, 2025

@coliu-akamai we could point @nikhagra-akamai PR to develop once it is merged.

@cpathipa cpathipa merged commit e97ff2f into linode:develop Jan 8, 2025
20 of 23 checks passed
Copy link

cypress bot commented Jan 8, 2025

Cloud Manager E2E    Run #7059

Run Properties:  status check failed Failed #7059  •  git commit e97ff2f18e: feat: [M3-8936] - Add Date Presets Functionality to Date Picker component. (#113...
Project Cloud Manager E2E
Branch Review develop
Run status status check failed Failed #7059
Run duration 08m 43s
Commit git commit e97ff2f18e: feat: [M3-8936] - Add Date Presets Functionality to Date Picker component. (#113...
Committer cpathipa
View all properties for this run ↗︎

Test results
Tests that failed  Failures 36
Tests that were flaky  Flaky 1
Tests that did not run due to a developer annotating a test with .skip  Pending 2
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 438
View all changes introduced in this branch ↗︎

Tests for review

Failed  databases/resize-database.spec.ts • 6 failed tests

View Output Video

Test Artifacts
Resizing existing clusters > Resizes a g6-standard-6 MySQL v8.x 3-node cluster (legacy DBaaS) > Can resize active database clusters Screenshots Video
Resizing existing clusters > Resizes a g6-standard-6 MySQL v8.x 3-node cluster (legacy DBaaS) > Can resize active database clusters from g6-standard-6 type and switch plan type Screenshots Video
Resizing existing clusters > Resizes a g6-standard-6 MySQL v8.x 3-node cluster (legacy DBaaS) > Cannot resize database clusters while they are not in active state Screenshots Video
Resizing existing clusters > Resizes a g6-dedicated-16 MySQL v5.x 3-node cluster (legacy DBaaS) > Can resize active database clusters Screenshots Video
Resizing existing clusters > Resizes a g6-dedicated-16 MySQL v5.x 3-node cluster (legacy DBaaS) > Can resize active database clusters from g6-dedicated-16 type and switch plan type Screenshots Video
Resizing existing clusters > Resizes a g6-dedicated-16 MySQL v5.x 3-node cluster (legacy DBaaS) > Cannot resize database clusters while they are not in active state Screenshots Video
Failed  databases/delete-database.spec.ts • 6 failed tests

View Output Video

Test Artifacts
Delete database clusters > Deletes a g6-nanode-1 MySQL v8.x 1-node cluster > Can delete active database clusters Screenshots Video
Delete database clusters > Deletes a g6-nanode-1 MySQL v8.x 1-node cluster > Cannot delete provisioning database clusters Screenshots Video
Delete database clusters > Deletes a g6-dedicated-2 MySQL v5.x 3-node cluster > Can delete active database clusters Screenshots Video
Delete database clusters > Deletes a g6-dedicated-2 MySQL v5.x 3-node cluster > Cannot delete provisioning database clusters Screenshots Video
Delete database clusters > Deletes a g6-nanode-1 PostgreSQL v13.x 3-node cluster > Can delete active database clusters Screenshots Video
Delete database clusters > Deletes a g6-nanode-1 PostgreSQL v13.x 3-node cluster > Cannot delete provisioning database clusters Screenshots Video
Failed  objectStorageGen2/bucket-create-gen2.spec.ts • 4 failed tests

View Output Video

Test Artifacts
Object Storage Gen2 create bucket tests > can create a bucket with E0 endpoint type Screenshots Video
Object Storage Gen2 create bucket tests > can create a bucket with E1 endpoint type Screenshots Video
Object Storage Gen2 create bucket tests > can create a bucket with E2 endpoint type Screenshots Video
Object Storage Gen2 create bucket tests > can create a bucket with E3 endpoint type Screenshots Video
Failed  linodes/smoke-delete-linode.spec.ts • 4 failed tests

View Output Video

Test Artifacts
delete linode > deletes linode from linode details page Screenshots Video
delete linode > deletes linode from setting tab in linode details page Screenshots Video
delete linode > deletes linode from linode landing page Screenshots Video
delete linode > deleting multiple linodes with action menu Screenshots Video
Failed  objectStorage/object-storage.e2e.spec.ts • 2 failed tests

View Output Video

Test Artifacts
object storage end-to-end tests > can create and delete object storage buckets Screenshots Video
object storage end-to-end tests > can upload, access, and delete objects Screenshots Video

The first 5 failed specs are shown, see all 13 specs in Cypress Cloud.

Flakiness  cypress/e2e/core/linodes/clone-linode.spec.ts • 1 flaky test

View Output Video

Test Artifacts
clone linode > can clone a Linode from Linode details page Screenshots Video

dmcintyr-akamai pushed a commit to dmcintyr-akamai/manager that referenced this pull request Jan 9, 2025
…nent. (linode#11395)

* unit test coverage for HostNameTableCell

* Revert "unit test coverage for HostNameTableCell"

This reverts commit b274baf.

* chore: [M3-8662] - Update Github Actions actions (linode#11009)

* update actions

* add changeset

---------

Co-authored-by: Banks Nussman <[email protected]>

* Basci date picker component

* Test coverage for date picker component

* DatePicker Stories

* Custom DateTimePicker component

* Reusable TimeZone Select Component

* Create custom DateTimeRangePicker component

* Storybook for DateTimePicker

* Fix tests and remove console warnings

* changeset

* Update packages/manager/src/components/DatePicker/DateTimeRangePicker.tsx

Co-authored-by: Connie Liu <[email protected]>

* Adjust styles for DatePicker

* Adjust styles for DateTimePicker

* update imports

* Render time and timezone conditionally in DateTimePicker component

* Move DatePicker to UI package

* Add DatePicker dependencies

* Code cleanup

* PR feedback

* code cleanup

* Move DatePicker back to src/components

* Reverting changes

* Code cleanup

* Adjust broken tests

* Update TimeZoneSelect.tsx

* Code cleanup

* Add validation for start date agains end date.

* Adjust styles for TimePicker component.

* Add the functionality to support Date Presets

* Update presets functionality and add test coverage.

* Added changeset: Add Date Presets Functionality to Date Picker component

* Persist the preset value

* Show the start date and end date fields only when custom is selected

* Add calendar icon to DateTimePicker component

* code cleanup and adjust tests

* Update packages/manager/src/components/DatePicker/DateTimeRangePicker.tsx

Co-authored-by: Nikhil Agrawal <[email protected]>

* update components

* Organize and additional prop support to DateTimeRangePicker component

* Code cleanup

* PR feedback - @coliu-akamai

* Move styles to theme level

* Revert "Move styles to theme level"

This reverts commit 15d9134.

* code cleanup

---------

Co-authored-by: Banks Nussman <[email protected]>
Co-authored-by: Banks Nussman <[email protected]>
Co-authored-by: Connie Liu <[email protected]>
Co-authored-by: Nikhil Agrawal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge! Date Range Picker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants