-
Notifications
You must be signed in to change notification settings - Fork 69
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
Apply User-Defined Date Formatting Settings to WP Admin React Components #9635
base: develop
Are you sure you want to change the base?
Apply User-Defined Date Formatting Settings to WP Admin React Components #9635
Conversation
I have requested an optional review from Helix. Dates/Timezones have been on our radar recently. |
…g-arent-respected-in-react-components
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments.
…g-arent-respected-in-react-components
…g-arent-respected-in-react-components
…g-arent-respected-in-react-components
…g-arent-respected-in-react-components
…g-arent-respected-in-react-components
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes mostly LGTM but have a question around data integrity for older plugins updating to a future version with these changes.
@@ -958,6 +958,8 @@ private function get_js_settings(): array { | |||
'lifetimeTPV' => $this->account->get_lifetime_total_payment_volume(), | |||
'defaultExpressCheckoutBorderRadius' => WC_Payments_Express_Checkout_Button_Handler::DEFAULT_BORDER_RADIUS_IN_PX, | |||
'isWooPayGlobalThemeSupportEligible' => WC_Payments_Features::is_woopay_global_theme_support_eligible(), | |||
'dateFormat' => wc_date_format(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For older plugins that don't have these - will there be any issues during updation? That is for reports or other places that folks might be downloading, will there be discrepancies in data format due to this? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I focused on limiting changes to only the areas of code where dates are displayed to the user, so I don't expect any major issues. Additionally, the fact that the unit tests and snapshots passed with minimal adjustments gives me further confidence.
However, there is a chance that merchants might be confused, as the way dates and times are presented will change without any direct action from them. This includes the dates in downloaded files, which, as you mentioned, could potentially impact automated processes on their end (just thinking about a possible scenario). While the default WordPress date format (F j, Y) isn’t drastically different from the previously hard-coded format (M j, Y), which was the most commonly used before this change, there could still be some adjustments.
I'm not entirely sure how to assess the potential negative impact on merchants, to be honest. Overall, though, I see this as a welcome improvement, as it adapts date formats to user-selected settings, making them feel more intuitive. For example, the MM-DD-YYYY format can be confusing for Spanish speakers like myself, as we typically use the DD-MM-YYYY format. There’s also an option for merchants to use a custom format, allowing them to keep the previous date style if desired. However, it's worth noting that we weren’t using formats consistently across the WooPayments plugin codebase before this update.
But I may be wrong, so I'm wondering if I should gather more feedback in a p2 before going ahead with this change. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel we could make this a setting maybe in WooPayments that allows merchants to sync the date format with the WP admin settings maybe and default it to false. That way merchants can explicitly opt-in to if needed and would expect the change to be reflected from the toggle onwards. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for sharing this idea @deepakpathania; it’s definitely a possible solution, though I’m not entirely convinced. My concern is that there’s already a place to manage date and time formats in Settings > General
. Adding a similar option under the WooPayments settings might create confusion. Additionally, the current behavior of ignoring user preferences is inconsistent, and introducing a setting here feels somewhat like a workaround for the core issue. That said, as you pointed out, this could help reduce potential confusion for merchants by giving them control over format changes.
I'm considering an alternative approach: we could inform merchants that they can select their preferred formats through WordPress settings. This could be done with an admin notice or a tooltip, perhaps in places like the date column in tables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be done with an admin notice or a tooltip, perhaps in places like the date column in tables.
Something like this:
Screen.Recording.2024-11-05.at.14.03.38.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds worth consulting designers about! @mgascam I love the idea of leaning into WordPress core settings and simplifying things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me but as Rua mentioned, maybe let's consult someone from Design about this before shipping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds worth consulting designers about!
Thanks for your insights, @deepakpathania and @haszari! I think consulting designers is a great idea.
@rogermattic, I noticed your recent post on table design, so I thought you might have some relevant context here. However, please feel free to redirect me if needed. To summarize, this PR aims to remove the hardcoded date & time formats currently in use in the WooPayments plugin, instead aligning them with WordPress General settings. While I believe this is the right direction, we’re aware this change could potentially inconvenience some merchants, as it will be applied automatically with the update.
To minimize disruption, we’re exploring a few options (see comments above). One approach we’re leaning towards is adding a tooltip in the relevant column headers to inform merchants of the change. The tooltip could guide users to the General settings where they can manage date & time formats. Do you think this is a suitable solution? Any additional insights or ideas would be much appreciated. 🙇
…g-arent-respected-in-react-components
…g-arent-respected-in-react-components
Thanks for tagging me @mgascam !
Thanks for the TLDR; ! I think it is a great idea!
A tooltip might be less noticeable than a notice, especially if we're aiming to introduce this change smoothly and reduce potential user frustration. However, a tooltip could work well as a secondary guide, pointing out where to adjust settings and perhaps disappearing eventually after some time when the users get familiar with the flow. To start, I’d suggest exploring either the admin notice or spotlight options. What do you think? If you’re on board, I can mock up two mini proposals for us to review. Also, what will be the default view that the user sees after the update? Will it be something like this (from the Storybook)?: Also, am I understanding this correctly, to adjust the settings the users will need to follow exactly the steps that you listed above as testing instructions?
|
Thanks for your quick response @rogermattic 🙇 I loved your perspective and I feel we are aligned. Let's discuss the next steps 😄
Yes I agree that the admin notice and/or the spotlight options can work. Please share the mocks and, in the meantime, I'll look into how those components work from a code point of view (never used them yet)
After the update, they will see the date & times formatted according to their saved preferences. The defaults are
Yes, this is where date and time settings live in the WordPress Admin. |
Hi @rogermattic 👋 , just checking in to see if you've had a chance to work on the mocks. I believe we could use the Notice component to inform merchants, but I'd prefer to hold off on any decisions until we've reviewed your proposals. For your information, I'll be on support rotation next week, but I'd like to resume work on this the following week. It would be great if we could review the mocks in the meantime. Does that work for you? Thanks in advance! |
Fixes #6567
This pull request refactors multiple components by replacing the direct usage of
dateI18n
with the newly introducedformatUserDateTime
utility function. TheformatUserDateTime
wraps thedateI18n
function and formats date and time with the user-defined settings.Changes proposed in this Pull Request
formatUserDateTime
fromwcpay/utils/date-time
to handle date formatting.formatUserDateTime
, ensuring date display that respects user preferences.Testing instructions
General Date and Time Display Testing
WP Admin > Settings > General
and set your preferred Date and Time Formats and Timezone.Component Specific Testing
Transactions
WP Admin > Payments > Transactions
.Date / Time
andDeposit Date
columns.Capital Loans
This section is hidden if your user does not have capital loans. Follow the steps in this guide to create one offer for your user. Once the offer is created, your user will get an email to confirm it. Visit the link in the email, but make sure to use your local store URL, not the server one.
WP Admin > Payments > Capital loans
Active loan overview
dates are formatted according to the user settings.All Loans
table dates are formatted according to the user settings. There are two columns that contain dates:Disbursed
andFirst Paydown
.Deposits
WP Admin > Payments > Deposits
Disputes
You can use test cards to create disputed orders.
WP Admin > Payments > Disputes
Disputed on
column (you may need to reveal it)Challenge Dispute
and verify the dates in the form are correctDocuments
In the server, you can use the cli to add a document to your account
wp wcpay add_document_for_account 236870460 vat_invoice --period_from="2024-10-01 00:00:00" --period_to="2024-10-31 23:59:59"
WP Admin > Payments > Documents
npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge