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
Various improvements to HPOS settings #47370
Conversation
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. Test this pull request with WordPress Playground. Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit. |
Hi @naman03malhotra, Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
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.
$error_class = ( ! empty( $value['description_is_error'] ) ) ? 'is-error' : ''; | ||
|
||
if ( $description && in_array( $value['type'], array( 'textarea', 'radio' ), true ) ) { | ||
$description = '<p style="margin-top:0">' . wp_kses_post( $description ) . '</p>'; | ||
} elseif ( $description && in_array( $value['type'], array( 'checkbox' ), true ) ) { | ||
$description = wp_kses_post( $description ); | ||
} elseif ( $description ) { | ||
$description = '<p class="description"' . $extra_description_style . '>' . wp_kses_post( $description ) . '</p>'; | ||
$description = '<p class="description ' . $error_class . '">' . wp_kses_post( $description ) . '</p>'; | ||
} | ||
|
||
if ( $tooltip_html && in_array( $value['type'], array( 'checkbox' ), true ) ) { | ||
$tooltip_html = '<p class="description"' . $extra_description_style . '>' . $tooltip_html . '</p>'; | ||
$tooltip_html = '<p class="description ' . $error_class . '">' . $tooltip_html . '</p>'; |
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.
Great work cleaning this up. Can you please clarify the instructions on how to test this change? It would also be helpful when Solaris or our external partners tests this PR.
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've updated the testing instructions with a section on this specific change.
plugins/woocommerce/src/Internal/DataStores/Orders/CustomOrdersTableController.php
Show resolved
Hide resolved
"There's %s order pending sync. <strong>Switching data storage while sync is incomplete is dangerous and can lead to order data corruption or loss!</strong>", | ||
'There are %s orders pending sync. <strong>Switching data storage while sync is incomplete is dangerous and can lead to order data corruption or loss!</strong>', |
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.
Maybewe can extract the common message out, wdyt? For a moment, I was confused as to why we had two similar messages, and then I realized.
Seems duplicate, can be extracted out.
<strong>Switching data storage while sync is incomplete is dangerous and can lead to order data corruption or loss!</strong>
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 guess there might be some i18n issues with separating the strings, but I did it anyways in d55c61c. We can reassess later if this ever becomes a problem for translations, which it most likely won't.
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.
Hey @naman03malhotra! Thanks for the review. I've responded / addressed your comments. Please let me know what you think!
I agree that this isn't the ideal UI, but this would require some changes that are probably not worth the effort right now for a screen that is seldom used. Polling (or similar) to get an updated count is not necessarily the most problematic aspect (though it does involve some heavy queries), but we would also need to properly update all the UI depending on the result (which is much more involved as you see there are a ton of different messages that can appear and interactions between the different settings). There's also the issue of nonce invalidation, etc. |
@jorgeatorres just to confirm this is fine correct? the duplicates of individual query shouldn't happen. |
@naman03malhotra: Yep. That's correct. |
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.
Thanks for making all the imporant changes as part of this PR. I've tested and it works well. I've left some comments none of which are blocking for this PR to be merged.
Submission Review Guidelines:
Changes proposed in this Pull Request:
This PR makes a few changes to the HPOS settings screen (and some related functions). This is based on feedback we've received, but also things we've been notices (such as duplicate queries, unused functions, etc.).
Some of the changes contained in this PR:
In 902e1ec, we remove a hard-coded style for settings and make it a CSS class instead, which is more flexible and also plays better with colors defined elsewhere. This might seem unrelated to HPOS, but was added specifically in the context of HPOS settings, so seems reasonable to update that here too.
Removal of an internal sync option (
woocommerce_initial_orders_pending_sync_count
) that is not used at all in the sync code. This allows us to deprecateDataSynchronizer::get_sync_status()
, which at this point, is nothing but an unnecessary wrapper over methods counting the number of orders pending sync.When generating settings/labels for HPOS, we now use the "cached" version of the orders pending sync count function, which removes query duplication on this screen.
Some UI changes such as removal of an unnecessary tooltip, and proper formatting for numbers. Also, screens were tweaked as described below:
Closes #43268.
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
If necessary, use
wp wc hpos sync
to first sync orders so that all options become available.Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer
.trunk
where duplication is reported:wp wc hpos cleanup all
so that order storage is no longer in sync.i. On WC > Settings > Advanced > Features click "Sync orders now" to start a manual order sync.
ii. Confirm that after the page refreshes, you see a message about orders being synced and there's a link to "Stop sync".
iii. Refresh the page until you see number of unsynced orders go down (might take a bit depending on when A-S runs).
iv. Quickly click "Stop sync".
v. Refresh the page and confirm that orders have stopped syncing and that "Sync orders now" appears once again.
wp wc hpos cleanup all
again to make sure the datastores are not in sync.Test
description_is_error
This PR also introduces a change in how settings with
description_is_error
are treated. Instead of hardcoding the styles in the HTML tags, we now use a CSS class that uses the color defined via SCSS.wp wc hpos cleanup all
if necessary.Changelog entry
Significance
Type
Message
Comment