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

Add admin notice on orders page for WCShipping migration #2751

Merged
merged 11 commits into from
Jun 20, 2024

Conversation

harriswong
Copy link
Contributor

@harriswong harriswong commented Jun 18, 2024

Description

Create an admin notice on the orders page (http://localhost/wp-admin/edit.php?post_type=shop_order).

The notice will have a dimissible button and a "Confirm update" button. The button does not do anything yet.

Related issue(s)

N/A

Steps to test

  1. Open wordpress/wp-content/plugins/woocommerce-services/classes/class-wc-connect-service-settings-store.php
  2. Change is_eligible_for_migration() to return true
		public function is_eligible_for_migration() {
			return true;
		}
  1. Go to orders page http://localhost/wp-admin/edit.php?post_type=shop_order
  2. Confirm that the admin notice is there
    image

Checklist

  • unit tests
  • changelog.txt entry added
  • readme.txt entry added

@@ -895,6 +895,7 @@ public function attach_hooks() {
add_filter( 'woocommerce_admin_reports', array( $this, 'reports_tabs' ) );
add_action( 'woocommerce_checkout_order_processed', array( $this, 'track_completed_order' ), 10, 3 );
add_action( 'admin_print_footer_scripts', array( $this, 'add_sift_js_tracker' ) );
add_action(' current_screen', array( $this, 'edit_orders_page_actions' ) );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to make sure get_current_screen() function is loaded.

Copy link
Contributor

Choose a reason for hiding this comment

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

there's a space before the action name:

Suggested change
add_action(' current_screen', array( $this, 'edit_orders_page_actions' ) );
add_action( 'current_screen', array( $this, 'edit_orders_page_actions' ) );

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks.

😭 Soon, #2749 will fix this for me!

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 here 9a0e90c

'https://wordpress.org/plugins/woocommerce-services/'
) .
'</p>
<button style="color:#3858E9;margin: 12px 0;border: 1px solid #3858E9;padding: 11.5px 12px 11.5px 12px;border-radius: 2px;background-color:#fff;">Confirm update</button>
Copy link
Contributor Author

@harriswong harriswong Jun 18, 2024

Choose a reason for hiding this comment

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

"Confirm update" doesn't do anything yet. I pinged design to double check on how we want to bind this action.

@@ -1801,6 +1821,20 @@ public function are_woo_shipping_and_woo_tax_active() {
public function display_woo_shipping_and_woo_tax_are_active_notice() {
echo '<div class="error"><p><strong>' . esc_html__( 'Woo Shipping and Woo Tax plugins are already active. Please deactivate WooCommerce Shipping & Tax.', 'woocommerce-services' ) . '</strong></p></div>';
}

public function display_wcst_to_wcshipping_migration_notice() {
echo wp_kses_post(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

woocommerce-services/assets/stylesheets/style.scss isn't loaded on the orders page. We could add some hooks to load a separate stylesheet for this notice, but I chose to use inline styles instead because this notice is a standalone component and its style is not reusable by others yet. If needed, we can always refactor afterwards.

Copy link
Contributor Author

@harriswong harriswong Jun 19, 2024

Choose a reason for hiding this comment

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

👋 Hey @Ferdev , based on the design feedback p1718744494706379-slack-C06FP5XT1S5 and p1718745005310189-slack-C06FP5XT1S5, I think we will have to change the "circle-x" to "x" (still confirming).

If we need to replace it, I think I would pull all these css out into its own .scss file. This will make it much easier to overwrite the button.is-dismissible class. To create a css file that loads in the order listing page, I think the work involves:

  • Add a new scss file like assets/stylesheets/wcst-migration-wcshipping.scss.
  • Figure out webpack: Webpack didn't build that .scss properly when I tried it, even though the config should build it.
  • I ended up adding an entry point in .js. Then do import '../assets/stylesheets/wcst-migration-wcshipping.scss';. This seems to work. We will then have to wp_enqueue_script and wp_enqueue_style these extra scripts for the css. I'm not sure if there is a better way.
  • Consider if we should build our own dismiss button if it's hard to overwrite the default styles.

If there is a quick fix, I am happy to add that here in this PR. Otherwise, maybe a follow-up?

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, webpack not building that css file is weird, apparently the sass-loader is looking for stuff in that path. Could be the problem the file is missing the css extension? I've seen sometimes sass preprocessors not liking filenames with just the sass extension, ie, my-css-file.scss instead of just my-css-file.css.scss.

About creating that follow up: yeah, I think it's the best approach. This way we can unlock this PR and rebase mine with it 👍

@harriswong harriswong changed the title Add/admin notices confirm update Add admin notice on orders page for WCShipping migration Jun 18, 2024
@harriswong harriswong requested review from a team and Ferdev and removed request for a team June 18, 2024 21:37
Copy link
Contributor

@Ferdev Ferdev left a comment

Choose a reason for hiding this comment

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

I doesn't load the banner in my machine. Maybe because of the WooCommerce version? Left a comment with more info

return false;
}

if ( 'edit-shop_order' !== $screen->id ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't work for me, because the $screen->id in the orders page, in my setup is called woocommerce_page_wc-orders, I'm not sure why is different? I'm using WooCommerce v8.9.3, not sure if that changes a lot in v9.0.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤔 Mine is also WC v8.9.3.

It looks like this is related to HPOS https://github.com/Automattic/woocommerce-services/pull/2692/files. I will borrow the logic there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup I can confirm HPOS returns "woocommerce_page_wc-orders" instead. Fixed in efc2229. Tested against 2 installations, one with HPOS, and the other without.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, that did not fix it completely. The modal now opens inside a single order as well. I tried updating it to

if (OrderUtil::custom_orders_table_usage_is_enabled()) {
+                                       // Orders list page when using HPOS.
+                                       if (wc_get_page_screen_id( 'shop_order' ) === $screen->id) {
+                                               $should_display_wcst_to_wcshipping_migration_notice = true;
+                                       }
+                               } else {
+                                       // Orders list page when not using HPOS.
+                                       if ('shop_order' === $screen->post_type && in_array( $screen->base, array( 'edit' ), true )) {
+                                               $should_display_wcst_to_wcshipping_migration_notice = true;
+                                       }
+                               }
+
+                               if ($should_display_wcst_to_wcshipping_migration_notice) {

But that doesn't fix it 100% either. This also makes it very complicated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I added a is_on_order_list_page() function to check if we are on the order list page. The admin notice should show only when it's on the order listing page (HPOS or not).

Fixed in 0e270e0.

@harriswong harriswong requested a review from Ferdev June 19, 2024 20:33
@harriswong
Copy link
Contributor Author

Hey @Ferdev, I fixed the condition for screen->ID. Please take another look.

Copy link
Contributor

@Ferdev Ferdev left a comment

Choose a reason for hiding this comment

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

That worked great, thanks! 🙇

@Ferdev Ferdev merged commit 3448800 into wcs-migration Jun 20, 2024
9 checks passed
@Ferdev Ferdev deleted the add/admin-notices-confirm-update branch June 20, 2024 08:31
@harriswong
Copy link
Contributor Author

Thanks for merging this for me!!

Ferdev pushed a commit that referenced this pull request Jul 29, 2024
* Use current_screen hook to trigger the add admin notice hook

* Add dimissable

* Added a button for "Upgrade now"

* Update "Confirm update" style

* Fix spaces

* Fix indentation

* Fix whitespace for linting

* Screen ID not found if using HPOS, fixed

* Update learn more link

* Add a new function is_on_order_list_page() to check order list page
Ferdev pushed a commit that referenced this pull request Jul 29, 2024
* Use current_screen hook to trigger the add admin notice hook

* Add dimissable

* Added a button for "Upgrade now"

* Update "Confirm update" style

* Fix spaces

* Fix indentation

* Fix whitespace for linting

* Screen ID not found if using HPOS, fixed

* Update learn more link

* Add a new function is_on_order_list_page() to check order list page
Ferdev pushed a commit that referenced this pull request Jul 30, 2024
* Use current_screen hook to trigger the add admin notice hook

* Add dimissable

* Added a button for "Upgrade now"

* Update "Confirm update" style

* Fix spaces

* Fix indentation

* Fix whitespace for linting

* Screen ID not found if using HPOS, fixed

* Update learn more link

* Add a new function is_on_order_list_page() to check order list page
Ferdev pushed a commit that referenced this pull request Jul 30, 2024
* Use current_screen hook to trigger the add admin notice hook

* Add dimissable

* Added a button for "Upgrade now"

* Update "Confirm update" style

* Fix spaces

* Fix indentation

* Fix whitespace for linting

* Screen ID not found if using HPOS, fixed

* Update learn more link

* Add a new function is_on_order_list_page() to check order list page
Ferdev pushed a commit that referenced this pull request Jul 30, 2024
* Use current_screen hook to trigger the add admin notice hook

* Add dimissable

* Added a button for "Upgrade now"

* Update "Confirm update" style

* Fix spaces

* Fix indentation

* Fix whitespace for linting

* Screen ID not found if using HPOS, fixed

* Update learn more link

* Add a new function is_on_order_list_page() to check order list page
Ferdev added a commit that referenced this pull request Jul 31, 2024
* Tweak/issue 2750 - WordPress 6.6 and WooCommerce 9.0 Compatibility (#2754)

* Bump tested up to version

* add changelog

* update readme file

* woorelease: Product version bump update

* Revert "woorelease: Product version bump update"

This reverts commit 122c7b3.

* woorelease: Product version bump update

* Revert "woorelease: Product version bump update"

This reverts commit 642db4f.

* woorelease: Product version bump update

* Fix/issue 2712 - Make The Tariff Number Field a Required Field when the Destination is Within EU (#2764)

* add condition for EU tariff number

* add changelog

* edit the tariff number error text

* edit changelog

* woorelease: Product version bump update

* Conditionally load shipping functionality based on if WC Shipping is active (#2761)

* Rough take

* Do not change the name, this is still called WooCommerce Shipping & Tax

* Set `wc_services_will_handle_coexistence_with_woo_shipping_and_woo_tax` hook to indicate we will handle the coexistence

* Remove WC_Connect_Note_DHL_Live_Rates_Available notice todo

My concern was about the class not existing and thereby creating PHP fatal errors, but we require the file right before using it, so there's no issue even if shipping has not been generally initiated.

* Remove outdated todos

* Status page should respect shipping conditional loading (#2776)

* Conditionally hide shipping related status data

* Satisfy tests

* Introduce new "wc_services_will_disable_shipping_logic" hook (#2775)

* Reimplement logic that completely blocks WCS&T logic from initiating

* Introduce new hook for conditional loading

---------

Co-authored-by: Gerhard <[email protected]>

* Add changelog for WC Shipping compatibility (#2779)

* Conditionally shows legacy reports shipping tab (#2780)

* woorelease: Product version bump update

* Define Feature Announcement component and open it on click [122] (#2743)

* Define Feature Announcement component and add the content

* Open the feature announcement modal when user clicks on Create shipping label

* Make the copy translatable

* Aknowledge eligibility when opening the feature announcement modal

* Add buttons and polish styling

* Disable the modal for the time being

* Add missing text and update styling

* Remove redundant argument in selector

* Add modal left column not taking 100% of the height

* Remove useCallback from stub function

* Revert code formatting back

* Fix/adjust how feature announcement looks on smaller screens (#2746)

* Fix how Feature Announcement component looks on smaller screens

* Remove excess space in closing tag

* Install and activate a list of plugins during migrations (#2745)

* Add @wordpress/api-fetch package

* Created a place holder button to test plugin activation

* Update shrinkwrap since we installed api-fetch

* Use hello-dolly to test install and activate

* Use native fetch instead of apiFetch

* Remove apiFetch package

* Fix < /p> to </p>

* Bind activation and installation to the update button

* Deactivate WCS&T after installing Woo Shipping and Woo Tax

* Disable is_eligible_for_migration

Don't enable migration yet.

* Redirect to plugins after installation

* Fix deactivateWCSTPluginAPICall to return promise

* Use relative path for the actions in feature-announcement

* Add adminPluginPath in the js global config.

* Execute each task in steps and throw exception if any fails

* Fix fill-rule to fillRule and clip-rule to clipRule (#2748)

* Set a flag to indicate migration has started or has completed (#2747)

* Add connect/migration-flag endpoint

* Set a flag "wcshipping_migrated" to indicate it is migrated

* is_eligible_for_migration() now checks for the config as well

* Add migration done API call to the update button

* Update migration flag to migration state

* Update space to tabs

* Call API to update migration status to "started"

* Update migration state to completed in plugin deactivation hook

* Default is_eligible_for_migration to return false

* Update API constants to something like an enum instead

* PHP cs fixes

* Return 200 if option updated, 304 otherwise

* Remove redundancy in condition

* Inline code comment can not be a DocBlock

* Remove redundant class_exists() check for the enum class

* Return 500 if update_option failed

* Add admin notice on orders page for WCShipping migration (#2751)

* Use current_screen hook to trigger the add admin notice hook

* Add dimissable

* Added a button for "Upgrade now"

* Update "Confirm update" style

* Fix spaces

* Fix indentation

* Fix whitespace for linting

* Screen ID not found if using HPOS, fixed

* Update learn more link

* Add a new function is_on_order_list_page() to check order list page

* Get the migration banner info from the connect server (#2752)

* Add note to README with a fix for `npm i` getting stuck

* Retrieves the migration banner info from WooCommerce Connect Server

* Address PR comments

* Get the flag to display the migration banner from the connect server (#2755)

* Refactor code checking whether or not to display a migration banner

* Address PR comments

* Change dismiss icon and behaviour [shipping-140] (#2758)

* Add is-dismissable and button label from server

* Register separate stylesheet and add stylings for the banner and buttons

* Add functionality to dismiss and remember dismissal

* Add state machine to drive migration states (#2757)

* Add state machine to drive migration states

* Rename state to better describe its name

* Refactor the API call out so the runNext function is decouple from API status check

* Update migration state enums to include all states in the machine

* Store the state in the wcshipping_migration_state option.

This allows us to remember where we were and we can always restart the
migration based on the last known state.

* Remove comment.

* Pass the wcshipping_migration_state option into the FeatureAnnouncement react component

* Fix a bug where restarting from an error state didn't proceed to the next state

* Return 304 if state is not modified instead of throwing 4xx.

* Fix 'wcshippingMigrationState' is already declared in the upper scope error

* Refactor the state machine logic into its own module

* Use wcs-client as path and re-enable redirection

* Added comments to the migration-runner module

* Apply suggestions from code review

Lint fixes.

Co-authored-by: Fernando Espinosa <[email protected]>

* Wait for the migration to finish before setting isUpdating back to false

* Return the fetch Response object instead

* Added a function to check if state exists before using it.

Throw exception otherwise.

* Update client/components/migration/migration-runner.js

* Update client/components/migration/migration-runner.js

* Update client/components/migration/migration-runner.js

---------

Co-authored-by: Fernando Espinosa <[email protected]>

* Add a "deactivated" message to the plugins list entry (#2759)

* Add a "deactivated" message to the plugins list entry

* Update woocommerce-services.php

Co-authored-by: Gerhard Potgieter <[email protected]>

* Address PR comments

* Remove redundant `esc_html`

* Customize the after_plugin_row action for this plugin only

* Fix background color of deactivated message

---------

Co-authored-by: Gerhard Potgieter <[email protected]>

* Load the FeatureAnnouncement modal to the order listing page (#2756)

* Load a new javascript file when migration admin notice shows up

* Load redux store for admin notice

The redux store inlcudes only the label shipping's reducer and the initial states.

* semi-colon gets rendered out. Removing.

* Fix style and setup initial data from the PHP's side

* Use wcs-client alias for webpack otherwise order list page can't find it

* Add baseURL and redirect URL through the proper enqueued scripts

* Move inline styles to the migration scss

* Clicking "Confirm update" will start the migration process

* Remove phpcs:ignore because it does have a version

* Use ID as the selector for the modal update button instead.

* Fix merge conflict issues with the existing css and js overlaps

* Change testing 10s back to 3 * 24 * 60 * 60

* Fix admin notice dimissible button and cleaned up jquery

* After clicking dimiss, remove itself from the DOM until 3 days later

* Add EOL to the js file.

* Change headers to a callback to retrieve getNonce() after dependencies are loaded

* Refactor cookie function to window.wpCookies

* Add tracking data for the migration process (#2760)

* Add tracking data for the migration process

* Remove debugging output

* Add update value to tracked data

* Clicking "Maybe later" will dismiss feature announcement for 3 days (#2762)

* Clicking "Maybe later" will dismiss the modal for 3 days

* Do not display modal if it's previously dismissed

* Don't show the modal if the page isn't refreshed

* EOL in new file

* Apply suggestions from code review

Lint fixes.

Co-authored-by: André Kallehauge <[email protected]>

---------

Co-authored-by: André Kallehauge <[email protected]>

* Save transients after a migration has been completed (#2763)

* Save transients after a migration has been completed

* Use general options instead of WooCommerce Shipping & Tax's options

* Cast the migration state to int now that is saved as a global option

* Remove wcshipping_migration_state as option name

* Add missing tracking data for the migration process (#2765)

* Update tracking data when the migration is completed

* Move plugin entry deactivated message to WooCommerce Shipping

* Add missing imports for tracks in a static method

* Remove db migration and deactivation (#2767)

* Skip db and deactivating plugin and finish the migration once activation is done

* Remove woocommerce-tax from the download and activation list

* Because WCS&T is no longer deactivated, we can update the migration state when it quits

* No longer need to rely on plugin_deactivation() to update the final migration state

* Adapt the migration banner popup to reusing WCS&T (#2769)

* Change copy in migration popup

* Improve copy in migration popup

* Provide public path to js entry files (#2770)

* Display migration banner on all WC settings page [shipping-152] (#2771)

* Show upgrade banner on shipping settings page as well

* Make sure clicking the confirm upgrade button doesn't refresh the page

* Show update banner on all settings pages

---------

Co-authored-by: Luthfi Bintoro <[email protected]>
Co-authored-by: Sam Najian <[email protected]>
Co-authored-by: Harris Wong <[email protected]>
Co-authored-by: André Kallehauge <[email protected]>
Co-authored-by: Gerhard <[email protected]>
Co-authored-by: Sam Najian <[email protected]>
samnajian pushed a commit that referenced this pull request Aug 7, 2024
* Use current_screen hook to trigger the add admin notice hook

* Add dimissable

* Added a button for "Upgrade now"

* Update "Confirm update" style

* Fix spaces

* Fix indentation

* Fix whitespace for linting

* Screen ID not found if using HPOS, fixed

* Update learn more link

* Add a new function is_on_order_list_page() to check order list page
samnajian added a commit that referenced this pull request Aug 7, 2024
* Tweak/issue 2750 - WordPress 6.6 and WooCommerce 9.0 Compatibility (#2754)

* Bump tested up to version

* add changelog

* update readme file

* woorelease: Product version bump update

* Revert "woorelease: Product version bump update"

This reverts commit 122c7b3.

* woorelease: Product version bump update

* Revert "woorelease: Product version bump update"

This reverts commit 642db4f.

* woorelease: Product version bump update

* Fix/issue 2712 - Make The Tariff Number Field a Required Field when the Destination is Within EU (#2764)

* add condition for EU tariff number

* add changelog

* edit the tariff number error text

* edit changelog

* woorelease: Product version bump update

* Conditionally load shipping functionality based on if WC Shipping is active (#2761)

* Rough take

* Do not change the name, this is still called WooCommerce Shipping & Tax

* Set `wc_services_will_handle_coexistence_with_woo_shipping_and_woo_tax` hook to indicate we will handle the coexistence

* Remove WC_Connect_Note_DHL_Live_Rates_Available notice todo

My concern was about the class not existing and thereby creating PHP fatal errors, but we require the file right before using it, so there's no issue even if shipping has not been generally initiated.

* Remove outdated todos

* Status page should respect shipping conditional loading (#2776)

* Conditionally hide shipping related status data

* Satisfy tests

* Introduce new "wc_services_will_disable_shipping_logic" hook (#2775)

* Reimplement logic that completely blocks WCS&T logic from initiating

* Introduce new hook for conditional loading

---------

Co-authored-by: Gerhard <[email protected]>

* Add changelog for WC Shipping compatibility (#2779)

* Conditionally shows legacy reports shipping tab (#2780)

* woorelease: Product version bump update

* Define Feature Announcement component and open it on click [122] (#2743)

* Define Feature Announcement component and add the content

* Open the feature announcement modal when user clicks on Create shipping label

* Make the copy translatable

* Aknowledge eligibility when opening the feature announcement modal

* Add buttons and polish styling

* Disable the modal for the time being

* Add missing text and update styling

* Remove redundant argument in selector

* Add modal left column not taking 100% of the height

* Remove useCallback from stub function

* Revert code formatting back

* Fix/adjust how feature announcement looks on smaller screens (#2746)

* Fix how Feature Announcement component looks on smaller screens

* Remove excess space in closing tag

* Install and activate a list of plugins during migrations (#2745)

* Add @wordpress/api-fetch package

* Created a place holder button to test plugin activation

* Update shrinkwrap since we installed api-fetch

* Use hello-dolly to test install and activate

* Use native fetch instead of apiFetch

* Remove apiFetch package

* Fix < /p> to </p>

* Bind activation and installation to the update button

* Deactivate WCS&T after installing Woo Shipping and Woo Tax

* Disable is_eligible_for_migration

Don't enable migration yet.

* Redirect to plugins after installation

* Fix deactivateWCSTPluginAPICall to return promise

* Use relative path for the actions in feature-announcement

* Add adminPluginPath in the js global config.

* Execute each task in steps and throw exception if any fails

* Fix fill-rule to fillRule and clip-rule to clipRule (#2748)

* Set a flag to indicate migration has started or has completed (#2747)

* Add connect/migration-flag endpoint

* Set a flag "wcshipping_migrated" to indicate it is migrated

* is_eligible_for_migration() now checks for the config as well

* Add migration done API call to the update button

* Update migration flag to migration state

* Update space to tabs

* Call API to update migration status to "started"

* Update migration state to completed in plugin deactivation hook

* Default is_eligible_for_migration to return false

* Update API constants to something like an enum instead

* PHP cs fixes

* Return 200 if option updated, 304 otherwise

* Remove redundancy in condition

* Inline code comment can not be a DocBlock

* Remove redundant class_exists() check for the enum class

* Return 500 if update_option failed

* Add admin notice on orders page for WCShipping migration (#2751)

* Use current_screen hook to trigger the add admin notice hook

* Add dimissable

* Added a button for "Upgrade now"

* Update "Confirm update" style

* Fix spaces

* Fix indentation

* Fix whitespace for linting

* Screen ID not found if using HPOS, fixed

* Update learn more link

* Add a new function is_on_order_list_page() to check order list page

* Get the migration banner info from the connect server (#2752)

* Add note to README with a fix for `npm i` getting stuck

* Retrieves the migration banner info from WooCommerce Connect Server

* Address PR comments

* Get the flag to display the migration banner from the connect server (#2755)

* Refactor code checking whether or not to display a migration banner

* Address PR comments

* Change dismiss icon and behaviour [shipping-140] (#2758)

* Add is-dismissable and button label from server

* Register separate stylesheet and add stylings for the banner and buttons

* Add functionality to dismiss and remember dismissal

* Add state machine to drive migration states (#2757)

* Add state machine to drive migration states

* Rename state to better describe its name

* Refactor the API call out so the runNext function is decouple from API status check

* Update migration state enums to include all states in the machine

* Store the state in the wcshipping_migration_state option.

This allows us to remember where we were and we can always restart the
migration based on the last known state.

* Remove comment.

* Pass the wcshipping_migration_state option into the FeatureAnnouncement react component

* Fix a bug where restarting from an error state didn't proceed to the next state

* Return 304 if state is not modified instead of throwing 4xx.

* Fix 'wcshippingMigrationState' is already declared in the upper scope error

* Refactor the state machine logic into its own module

* Use wcs-client as path and re-enable redirection

* Added comments to the migration-runner module

* Apply suggestions from code review

Lint fixes.

Co-authored-by: Fernando Espinosa <[email protected]>

* Wait for the migration to finish before setting isUpdating back to false

* Return the fetch Response object instead

* Added a function to check if state exists before using it.

Throw exception otherwise.

* Update client/components/migration/migration-runner.js

* Update client/components/migration/migration-runner.js

* Update client/components/migration/migration-runner.js

---------

Co-authored-by: Fernando Espinosa <[email protected]>

* Add a "deactivated" message to the plugins list entry (#2759)

* Add a "deactivated" message to the plugins list entry

* Update woocommerce-services.php

Co-authored-by: Gerhard Potgieter <[email protected]>

* Address PR comments

* Remove redundant `esc_html`

* Customize the after_plugin_row action for this plugin only

* Fix background color of deactivated message

---------

Co-authored-by: Gerhard Potgieter <[email protected]>

* Load the FeatureAnnouncement modal to the order listing page (#2756)

* Load a new javascript file when migration admin notice shows up

* Load redux store for admin notice

The redux store inlcudes only the label shipping's reducer and the initial states.

* semi-colon gets rendered out. Removing.

* Fix style and setup initial data from the PHP's side

* Use wcs-client alias for webpack otherwise order list page can't find it

* Add baseURL and redirect URL through the proper enqueued scripts

* Move inline styles to the migration scss

* Clicking "Confirm update" will start the migration process

* Remove phpcs:ignore because it does have a version

* Use ID as the selector for the modal update button instead.

* Fix merge conflict issues with the existing css and js overlaps

* Change testing 10s back to 3 * 24 * 60 * 60

* Fix admin notice dimissible button and cleaned up jquery

* After clicking dimiss, remove itself from the DOM until 3 days later

* Add EOL to the js file.

* Change headers to a callback to retrieve getNonce() after dependencies are loaded

* Refactor cookie function to window.wpCookies

* Add tracking data for the migration process (#2760)

* Add tracking data for the migration process

* Remove debugging output

* Add update value to tracked data

* Clicking "Maybe later" will dismiss feature announcement for 3 days (#2762)

* Clicking "Maybe later" will dismiss the modal for 3 days

* Do not display modal if it's previously dismissed

* Don't show the modal if the page isn't refreshed

* EOL in new file

* Apply suggestions from code review

Lint fixes.

Co-authored-by: André Kallehauge <[email protected]>

---------

Co-authored-by: André Kallehauge <[email protected]>

* Save transients after a migration has been completed (#2763)

* Save transients after a migration has been completed

* Use general options instead of WooCommerce Shipping & Tax's options

* Cast the migration state to int now that is saved as a global option

* Remove wcshipping_migration_state as option name

* Add missing tracking data for the migration process (#2765)

* Update tracking data when the migration is completed

* Move plugin entry deactivated message to WooCommerce Shipping

* Add missing imports for tracks in a static method

* Remove db migration and deactivation (#2767)

* Skip db and deactivating plugin and finish the migration once activation is done

* Remove woocommerce-tax from the download and activation list

* Because WCS&T is no longer deactivated, we can update the migration state when it quits

* No longer need to rely on plugin_deactivation() to update the final migration state

* Adapt the migration banner popup to reusing WCS&T (#2769)

* Change copy in migration popup

* Improve copy in migration popup

* Provide public path to js entry files (#2770)

* Display migration banner on all WC settings page [shipping-152] (#2771)

* Show upgrade banner on shipping settings page as well

* Make sure clicking the confirm upgrade button doesn't refresh the page

* Show update banner on all settings pages

---------

Co-authored-by: Luthfi Bintoro <[email protected]>
Co-authored-by: Sam Najian <[email protected]>
Co-authored-by: Harris Wong <[email protected]>
Co-authored-by: André Kallehauge <[email protected]>
Co-authored-by: Gerhard <[email protected]>
Co-authored-by: Sam Najian <[email protected]>
kloon added a commit that referenced this pull request Aug 27, 2024
* Define Feature Announcement component and open it on click [122] (#2743)

* Define Feature Announcement component and add the content

* Open the feature announcement modal when user clicks on Create shipping label

* Make the copy translatable

* Aknowledge eligibility when opening the feature announcement modal

* Add buttons and polish styling

* Disable the modal for the time being

* Add missing text and update styling

* Remove redundant argument in selector

* Add modal left column not taking 100% of the height

* Remove useCallback from stub function

* Revert code formatting back

* Fix/adjust how feature announcement looks on smaller screens (#2746)

* Fix how Feature Announcement component looks on smaller screens

* Remove excess space in closing tag

* Install and activate a list of plugins during migrations (#2745)

* Add @wordpress/api-fetch package

* Created a place holder button to test plugin activation

* Update shrinkwrap since we installed api-fetch

* Use hello-dolly to test install and activate

* Use native fetch instead of apiFetch

* Remove apiFetch package

* Fix < /p> to </p>

* Bind activation and installation to the update button

* Deactivate WCS&T after installing Woo Shipping and Woo Tax

* Disable is_eligible_for_migration

Don't enable migration yet.

* Redirect to plugins after installation

* Fix deactivateWCSTPluginAPICall to return promise

* Use relative path for the actions in feature-announcement

* Add adminPluginPath in the js global config.

* Execute each task in steps and throw exception if any fails

* Fix fill-rule to fillRule and clip-rule to clipRule (#2748)

* Set a flag to indicate migration has started or has completed (#2747)

* Add connect/migration-flag endpoint

* Set a flag "wcshipping_migrated" to indicate it is migrated

* is_eligible_for_migration() now checks for the config as well

* Add migration done API call to the update button

* Update migration flag to migration state

* Update space to tabs

* Call API to update migration status to "started"

* Update migration state to completed in plugin deactivation hook

* Default is_eligible_for_migration to return false

* Update API constants to something like an enum instead

* PHP cs fixes

* Return 200 if option updated, 304 otherwise

* Remove redundancy in condition

* Inline code comment can not be a DocBlock

* Remove redundant class_exists() check for the enum class

* Return 500 if update_option failed

* Add admin notice on orders page for WCShipping migration (#2751)

* Use current_screen hook to trigger the add admin notice hook

* Add dimissable

* Added a button for "Upgrade now"

* Update "Confirm update" style

* Fix spaces

* Fix indentation

* Fix whitespace for linting

* Screen ID not found if using HPOS, fixed

* Update learn more link

* Add a new function is_on_order_list_page() to check order list page

* Get the migration banner info from the connect server (#2752)

* Add note to README with a fix for `npm i` getting stuck

* Retrieves the migration banner info from WooCommerce Connect Server

* Address PR comments

* Get the flag to display the migration banner from the connect server (#2755)

* Refactor code checking whether or not to display a migration banner

* Address PR comments

* Change dismiss icon and behaviour [shipping-140] (#2758)

* Add is-dismissable and button label from server

* Register separate stylesheet and add stylings for the banner and buttons

* Add functionality to dismiss and remember dismissal

* Add state machine to drive migration states (#2757)

* Add state machine to drive migration states

* Rename state to better describe its name

* Refactor the API call out so the runNext function is decouple from API status check

* Update migration state enums to include all states in the machine

* Store the state in the wcshipping_migration_state option.

This allows us to remember where we were and we can always restart the
migration based on the last known state.

* Remove comment.

* Pass the wcshipping_migration_state option into the FeatureAnnouncement react component

* Fix a bug where restarting from an error state didn't proceed to the next state

* Return 304 if state is not modified instead of throwing 4xx.

* Fix 'wcshippingMigrationState' is already declared in the upper scope error

* Refactor the state machine logic into its own module

* Use wcs-client as path and re-enable redirection

* Added comments to the migration-runner module

* Apply suggestions from code review

Lint fixes.

Co-authored-by: Fernando Espinosa <[email protected]>

* Wait for the migration to finish before setting isUpdating back to false

* Return the fetch Response object instead

* Added a function to check if state exists before using it.

Throw exception otherwise.

* Update client/components/migration/migration-runner.js

* Update client/components/migration/migration-runner.js

* Update client/components/migration/migration-runner.js

---------

Co-authored-by: Fernando Espinosa <[email protected]>

* Add a "deactivated" message to the plugins list entry (#2759)

* Add a "deactivated" message to the plugins list entry

* Update woocommerce-services.php

Co-authored-by: Gerhard Potgieter <[email protected]>

* Address PR comments

* Remove redundant `esc_html`

* Customize the after_plugin_row action for this plugin only

* Fix background color of deactivated message

---------

Co-authored-by: Gerhard Potgieter <[email protected]>

* Load the FeatureAnnouncement modal to the order listing page (#2756)

* Load a new javascript file when migration admin notice shows up

* Load redux store for admin notice

The redux store inlcudes only the label shipping's reducer and the initial states.

* semi-colon gets rendered out. Removing.

* Fix style and setup initial data from the PHP's side

* Use wcs-client alias for webpack otherwise order list page can't find it

* Add baseURL and redirect URL through the proper enqueued scripts

* Move inline styles to the migration scss

* Clicking "Confirm update" will start the migration process

* Remove phpcs:ignore because it does have a version

* Use ID as the selector for the modal update button instead.

* Fix merge conflict issues with the existing css and js overlaps

* Change testing 10s back to 3 * 24 * 60 * 60

* Fix admin notice dimissible button and cleaned up jquery

* After clicking dimiss, remove itself from the DOM until 3 days later

* Add EOL to the js file.

* Change headers to a callback to retrieve getNonce() after dependencies are loaded

* Refactor cookie function to window.wpCookies

* Add tracking data for the migration process (#2760)

* Add tracking data for the migration process

* Remove debugging output

* Add update value to tracked data

* Clicking "Maybe later" will dismiss feature announcement for 3 days (#2762)

* Clicking "Maybe later" will dismiss the modal for 3 days

* Do not display modal if it's previously dismissed

* Don't show the modal if the page isn't refreshed

* EOL in new file

* Apply suggestions from code review

Lint fixes.

Co-authored-by: André Kallehauge <[email protected]>

---------

Co-authored-by: André Kallehauge <[email protected]>

* Save transients after a migration has been completed (#2763)

* Save transients after a migration has been completed

* Use general options instead of WooCommerce Shipping & Tax's options

* Cast the migration state to int now that is saved as a global option

* Remove wcshipping_migration_state as option name

* Add missing tracking data for the migration process (#2765)

* Update tracking data when the migration is completed

* Move plugin entry deactivated message to WooCommerce Shipping

* Add missing imports for tracks in a static method

* Remove db migration and deactivation (#2767)

* Skip db and deactivating plugin and finish the migration once activation is done

* Remove woocommerce-tax from the download and activation list

* Because WCS&T is no longer deactivated, we can update the migration state when it quits

* No longer need to rely on plugin_deactivation() to update the final migration state

* Adapt the migration banner popup to reusing WCS&T (#2769)

* Change copy in migration popup

* Improve copy in migration popup

* Provide public path to js entry files (#2770)

* Display migration banner on all WC settings page [shipping-152] (#2771)

* Show upgrade banner on shipping settings page as well

* Make sure clicking the confirm upgrade button doesn't refresh the page

* Show update banner on all settings pages

* Rebase `wcs-migration` branch onto `trunk` (#2783)

* Tweak/issue 2750 - WordPress 6.6 and WooCommerce 9.0 Compatibility (#2754)

* Bump tested up to version

* add changelog

* update readme file

* woorelease: Product version bump update

* Revert "woorelease: Product version bump update"

This reverts commit 122c7b3.

* woorelease: Product version bump update

* Revert "woorelease: Product version bump update"

This reverts commit 642db4f.

* woorelease: Product version bump update

* Fix/issue 2712 - Make The Tariff Number Field a Required Field when the Destination is Within EU (#2764)

* add condition for EU tariff number

* add changelog

* edit the tariff number error text

* edit changelog

* woorelease: Product version bump update

* Conditionally load shipping functionality based on if WC Shipping is active (#2761)

* Rough take

* Do not change the name, this is still called WooCommerce Shipping & Tax

* Set `wc_services_will_handle_coexistence_with_woo_shipping_and_woo_tax` hook to indicate we will handle the coexistence

* Remove WC_Connect_Note_DHL_Live_Rates_Available notice todo

My concern was about the class not existing and thereby creating PHP fatal errors, but we require the file right before using it, so there's no issue even if shipping has not been generally initiated.

* Remove outdated todos

* Status page should respect shipping conditional loading (#2776)

* Conditionally hide shipping related status data

* Satisfy tests

* Introduce new "wc_services_will_disable_shipping_logic" hook (#2775)

* Reimplement logic that completely blocks WCS&T logic from initiating

* Introduce new hook for conditional loading

---------

Co-authored-by: Gerhard <[email protected]>

* Add changelog for WC Shipping compatibility (#2779)

* Conditionally shows legacy reports shipping tab (#2780)

* woorelease: Product version bump update

* Define Feature Announcement component and open it on click [122] (#2743)

* Define Feature Announcement component and add the content

* Open the feature announcement modal when user clicks on Create shipping label

* Make the copy translatable

* Aknowledge eligibility when opening the feature announcement modal

* Add buttons and polish styling

* Disable the modal for the time being

* Add missing text and update styling

* Remove redundant argument in selector

* Add modal left column not taking 100% of the height

* Remove useCallback from stub function

* Revert code formatting back

* Fix/adjust how feature announcement looks on smaller screens (#2746)

* Fix how Feature Announcement component looks on smaller screens

* Remove excess space in closing tag

* Install and activate a list of plugins during migrations (#2745)

* Add @wordpress/api-fetch package

* Created a place holder button to test plugin activation

* Update shrinkwrap since we installed api-fetch

* Use hello-dolly to test install and activate

* Use native fetch instead of apiFetch

* Remove apiFetch package

* Fix < /p> to </p>

* Bind activation and installation to the update button

* Deactivate WCS&T after installing Woo Shipping and Woo Tax

* Disable is_eligible_for_migration

Don't enable migration yet.

* Redirect to plugins after installation

* Fix deactivateWCSTPluginAPICall to return promise

* Use relative path for the actions in feature-announcement

* Add adminPluginPath in the js global config.

* Execute each task in steps and throw exception if any fails

* Fix fill-rule to fillRule and clip-rule to clipRule (#2748)

* Set a flag to indicate migration has started or has completed (#2747)

* Add connect/migration-flag endpoint

* Set a flag "wcshipping_migrated" to indicate it is migrated

* is_eligible_for_migration() now checks for the config as well

* Add migration done API call to the update button

* Update migration flag to migration state

* Update space to tabs

* Call API to update migration status to "started"

* Update migration state to completed in plugin deactivation hook

* Default is_eligible_for_migration to return false

* Update API constants to something like an enum instead

* PHP cs fixes

* Return 200 if option updated, 304 otherwise

* Remove redundancy in condition

* Inline code comment can not be a DocBlock

* Remove redundant class_exists() check for the enum class

* Return 500 if update_option failed

* Add admin notice on orders page for WCShipping migration (#2751)

* Use current_screen hook to trigger the add admin notice hook

* Add dimissable

* Added a button for "Upgrade now"

* Update "Confirm update" style

* Fix spaces

* Fix indentation

* Fix whitespace for linting

* Screen ID not found if using HPOS, fixed

* Update learn more link

* Add a new function is_on_order_list_page() to check order list page

* Get the migration banner info from the connect server (#2752)

* Add note to README with a fix for `npm i` getting stuck

* Retrieves the migration banner info from WooCommerce Connect Server

* Address PR comments

* Get the flag to display the migration banner from the connect server (#2755)

* Refactor code checking whether or not to display a migration banner

* Address PR comments

* Change dismiss icon and behaviour [shipping-140] (#2758)

* Add is-dismissable and button label from server

* Register separate stylesheet and add stylings for the banner and buttons

* Add functionality to dismiss and remember dismissal

* Add state machine to drive migration states (#2757)

* Add state machine to drive migration states

* Rename state to better describe its name

* Refactor the API call out so the runNext function is decouple from API status check

* Update migration state enums to include all states in the machine

* Store the state in the wcshipping_migration_state option.

This allows us to remember where we were and we can always restart the
migration based on the last known state.

* Remove comment.

* Pass the wcshipping_migration_state option into the FeatureAnnouncement react component

* Fix a bug where restarting from an error state didn't proceed to the next state

* Return 304 if state is not modified instead of throwing 4xx.

* Fix 'wcshippingMigrationState' is already declared in the upper scope error

* Refactor the state machine logic into its own module

* Use wcs-client as path and re-enable redirection

* Added comments to the migration-runner module

* Apply suggestions from code review

Lint fixes.

Co-authored-by: Fernando Espinosa <[email protected]>

* Wait for the migration to finish before setting isUpdating back to false

* Return the fetch Response object instead

* Added a function to check if state exists before using it.

Throw exception otherwise.

* Update client/components/migration/migration-runner.js

* Update client/components/migration/migration-runner.js

* Update client/components/migration/migration-runner.js

---------

Co-authored-by: Fernando Espinosa <[email protected]>

* Add a "deactivated" message to the plugins list entry (#2759)

* Add a "deactivated" message to the plugins list entry

* Update woocommerce-services.php

Co-authored-by: Gerhard Potgieter <[email protected]>

* Address PR comments

* Remove redundant `esc_html`

* Customize the after_plugin_row action for this plugin only

* Fix background color of deactivated message

---------

Co-authored-by: Gerhard Potgieter <[email protected]>

* Load the FeatureAnnouncement modal to the order listing page (#2756)

* Load a new javascript file when migration admin notice shows up

* Load redux store for admin notice

The redux store inlcudes only the label shipping's reducer and the initial states.

* semi-colon gets rendered out. Removing.

* Fix style and setup initial data from the PHP's side

* Use wcs-client alias for webpack otherwise order list page can't find it

* Add baseURL and redirect URL through the proper enqueued scripts

* Move inline styles to the migration scss

* Clicking "Confirm update" will start the migration process

* Remove phpcs:ignore because it does have a version

* Use ID as the selector for the modal update button instead.

* Fix merge conflict issues with the existing css and js overlaps

* Change testing 10s back to 3 * 24 * 60 * 60

* Fix admin notice dimissible button and cleaned up jquery

* After clicking dimiss, remove itself from the DOM until 3 days later

* Add EOL to the js file.

* Change headers to a callback to retrieve getNonce() after dependencies are loaded

* Refactor cookie function to window.wpCookies

* Add tracking data for the migration process (#2760)

* Add tracking data for the migration process

* Remove debugging output

* Add update value to tracked data

* Clicking "Maybe later" will dismiss feature announcement for 3 days (#2762)

* Clicking "Maybe later" will dismiss the modal for 3 days

* Do not display modal if it's previously dismissed

* Don't show the modal if the page isn't refreshed

* EOL in new file

* Apply suggestions from code review

Lint fixes.

Co-authored-by: André Kallehauge <[email protected]>

---------

Co-authored-by: André Kallehauge <[email protected]>

* Save transients after a migration has been completed (#2763)

* Save transients after a migration has been completed

* Use general options instead of WooCommerce Shipping & Tax's options

* Cast the migration state to int now that is saved as a global option

* Remove wcshipping_migration_state as option name

* Add missing tracking data for the migration process (#2765)

* Update tracking data when the migration is completed

* Move plugin entry deactivated message to WooCommerce Shipping

* Add missing imports for tracks in a static method

* Remove db migration and deactivation (#2767)

* Skip db and deactivating plugin and finish the migration once activation is done

* Remove woocommerce-tax from the download and activation list

* Because WCS&T is no longer deactivated, we can update the migration state when it quits

* No longer need to rely on plugin_deactivation() to update the final migration state

* Adapt the migration banner popup to reusing WCS&T (#2769)

* Change copy in migration popup

* Improve copy in migration popup

* Provide public path to js entry files (#2770)

* Display migration banner on all WC settings page [shipping-152] (#2771)

* Show upgrade banner on shipping settings page as well

* Make sure clicking the confirm upgrade button doesn't refresh the page

* Show update banner on all settings pages

---------

Co-authored-by: Luthfi Bintoro <[email protected]>
Co-authored-by: Sam Najian <[email protected]>
Co-authored-by: Harris Wong <[email protected]>
Co-authored-by: André Kallehauge <[email protected]>
Co-authored-by: Gerhard <[email protected]>
Co-authored-by: Sam Najian <[email protected]>

* Fix error launching the migration popup (#2784)

* Upgrade jetpack packages to version compatible with WCShipping (#2785)

* Use latest WP version for e2e tests

* Merge `trunk` into `wcs-migration` (#2795)

* Tweak/issue 2750 - WordPress 6.6 and WooCommerce 9.0 Compatibility (#2754)

* Bump tested up to version

* add changelog

* update readme file

* woorelease: Product version bump update

* Revert "woorelease: Product version bump update"

This reverts commit 122c7b3.

* woorelease: Product version bump update

* Revert "woorelease: Product version bump update"

This reverts commit 642db4f.

* woorelease: Product version bump update

* Fix/issue 2712 - Make The Tariff Number Field a Required Field when the Destination is Within EU (#2764)

* add condition for EU tariff number

* add changelog

* edit the tariff number error text

* edit changelog

* woorelease: Product version bump update

* Conditionally load shipping functionality based on if WC Shipping is active (#2761)

* Rough take

* Do not change the name, this is still called WooCommerce Shipping & Tax

* Set `wc_services_will_handle_coexistence_with_woo_shipping_and_woo_tax` hook to indicate we will handle the coexistence

* Remove WC_Connect_Note_DHL_Live_Rates_Available notice todo

My concern was about the class not existing and thereby creating PHP fatal errors, but we require the file right before using it, so there's no issue even if shipping has not been generally initiated.

* Remove outdated todos

* Status page should respect shipping conditional loading (#2776)

* Conditionally hide shipping related status data

* Satisfy tests

* Introduce new "wc_services_will_disable_shipping_logic" hook (#2775)

* Reimplement logic that completely blocks WCS&T logic from initiating

* Introduce new hook for conditional loading

---------

Co-authored-by: Gerhard <[email protected]>

* Add changelog for WC Shipping compatibility (#2779)

* Conditionally shows legacy reports shipping tab (#2780)

* woorelease: Product version bump update

* Update readme.txt to indicate that a new Woo Shipping plugin is available for download. (#2789)

* Update changelog

* Remove changelog and updated copy

* Make sure docker-compose command exists (#2793)

---------

Co-authored-by: Luthfi Bintoro <[email protected]>
Co-authored-by: Sam Najian <[email protected]>
Co-authored-by: Harris Wong <[email protected]>
Co-authored-by: André Kallehauge <[email protected]>
Co-authored-by: Gerhard <[email protected]>
Co-authored-by: Sam Najian <[email protected]>

* Add a new widget in settings to start the migration (#2796)

* Add a new widget in settings to start the migration

* Add tracks event for migration settings widget

* Update changelog and readme

* Update changelog.txt copy

Update the copy to "A new migration experience from this plugin to the newly released WooCommerce Shipping plugin."

Co-authored-by: André Kallehauge <[email protected]>

* Update feature announcement copy

* Do not test on SKU, woocommerce/woocommerce#47476 changed sku behaviour in tests

* Update version for migration work

---------

Co-authored-by: Sam Najian <[email protected]>
Co-authored-by: Harris Wong <[email protected]>
Co-authored-by: Gerhard Potgieter <[email protected]>
Co-authored-by: André Kallehauge <[email protected]>
Co-authored-by: Luthfi Bintoro <[email protected]>
Co-authored-by: Sam Najian <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants