Skip to content

DataViews: Add date field type #70657

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

Merged
merged 4 commits into from
Jul 21, 2025

Conversation

chihsuan
Copy link
Member

@chihsuan chihsuan commented Jul 9, 2025

What?

Related to Automattic/wp-calypso#104438

Added a new date field type in the dataviews package with sorting and validation functions, but have not yet implemented the edit component.

Changes:

  • Added 'date' as a new field type in the types definition.
  • Updated SpaceObject to include 'datetime' alongside 'date' in the fixtures.
  • Created a new date field type implementation with sorting and validation functions.
  • Updated field type definitions to include the new 'date' type.
  • Added a new story for rendering date fields in the component library.

Why?

Date is a very common data type in various use cases. We already have a datetime field type, but for some use cases, we only need to display/edit the data without the time. Additionally, we want to be able to filter by date using the new Calendar component. To support this, we need to add a new date field type first.

How?

To make it easier for review, this PR only adds the new date field type but not yet implemented the edit component.

I'll create a follow-up PR (https://github.com/chihsuan/gutenberg/compare/add/dateviews-date-field-type...chihsuan:gutenberg:add/dataviews-date-control?expand=1) to implement the edit component for the new date field type.

Testing Instructions

  1. Run npm run storybook:dev
  2. Go to http://localhost:50240/?path=/story/dataviews-fieldtypes--date
  3. Confirm that the date field type is rendered correctly. Only the date is displayed, not the time. Confirm that filters/edit are disabled.
  4. Go to http://localhost:50240/?path=/story/dataviews-fieldtypes--date-time
  5. Confirm that the datetime field type is still working as expected.

Testing Instructions for Keyboard

Screenshots or screencast

Date
Screenshot 2025-07-09 at 16 52 57

Datetime
Screenshot 2025-07-09 at 16 53 06

Copy link

github-actions bot commented Jul 9, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: chihsuan <chihsuan@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

chihsuan added 2 commits July 10, 2025 10:31
- Added 'date' as a new field type in the types definition.
- Updated SpaceObject to include 'datetime' alongside 'date' in the fixtures.
- Created a new date field type implementation with sorting and validation functions.
- Updated field type definitions to include the new 'date' type.
- Added a new story for rendering date fields in the component library.
@chihsuan chihsuan force-pushed the add/dateviews-date-field-type branch from 4927289 to 23e7870 Compare July 10, 2025 02:31
@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Package] DataViews /packages/dataviews labels Jul 10, 2025
@oandregal oandregal self-requested a review July 21, 2025 08:44
@@ -95,6 +100,7 @@ export const data: SpaceObject[] = [
categories: [ 'Space', 'Planet', 'Solar system' ],
satellites: 0,
date: '2020-01-02T01:00:00Z',
Copy link
Member

Choose a reason for hiding this comment

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

There's a couple of date props that have datetime data. Not a big issue, and the value is actually displayed as date. To avoid confusion in the future, I'd rather use date-only values for the date prop.

Copy link
Member

Choose a reason for hiding this comment

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

In the interest of velocity, I'm going to push these changes and merge the PR after the tests pass.

Copy link
Member

Choose a reason for hiding this comment

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

oh, it's a PR from a fork, and I don't have permissions.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed in 4b739ac.

Copy link
Member

@oandregal oandregal left a comment

Choose a reason for hiding this comment

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

This is a good first step, thanks. Are you following up with filters/edit soon?

@chihsuan
Copy link
Member Author

This is a good first step, thanks. Are you following up with filters/edit soon?

Yes, it's on my list. I'll create a PR soon! 🙌

@oandregal oandregal merged commit 2a278af into WordPress:trunk Jul 21, 2025
60 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.3 milestone Jul 21, 2025
adamsilverstein pushed a commit to adamsilverstein/gutenberg that referenced this pull request Jul 21, 2025
Co-authored-by: chihsuan <chihsuan@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
USERSATOSHI pushed a commit to USERSATOSHI/gutenberg that referenced this pull request Jul 23, 2025
Co-authored-by: chihsuan <chihsuan@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] DataViews /packages/dataviews [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants