Skip to content

Conversation

@mdperez86
Copy link
Contributor

@mdperez86 mdperez86 commented Mar 8, 2023

All Submissions:

Changes proposed in this Pull Request:

Closes #36989

How to test the changes in this Pull Request:

  1. Visiting /wp-admin/admin.php?page=wc-admin&path=/add-product or /wp-admin/admin.php?page=wc-admin&path=/product/{productId} you should see the previous product experience.
  2. After enabled the setting New product management experience in WooCommerce -> Settings -> Advanced -> Features and visiting back the urls of point 1, you should see the new product editor blocks. And the previous product experience remains accessible using /wp-admin/admin.php?page=wc-admin&path=/add-product-old or /wp-admin/admin.php?page=wc-admin&path=/product-old/{productId} routes.
  3. After disabled the setting you should see the same as in point 1.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you created a changelog file for each project being changed, ie pnpm --filter=<project> changelog add?
  • Have you included testing instructions?

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

@mdperez86 mdperez86 requested a review from a team March 8, 2023 13:10
@mdperez86 mdperez86 self-assigned this Mar 8, 2023
@github-actions github-actions bot added focus: react admin [team:Ghidorah] plugin: woocommerce Issues related to the WooCommerce Core plugin. labels Mar 8, 2023
@mdperez86 mdperez86 force-pushed the add/36989 branch 3 times, most recently from 27b55cb to 35b22fe Compare March 8, 2023 13:26
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2023

Test Results Summary

Commit SHA: 4dbbe54

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests26700202691m 2s
E2E Tests1940010020417m 14s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

@codecov
Copy link

codecov bot commented Mar 8, 2023

Codecov Report

Merging #37122 (87f51d9) into trunk (34dd147) will decrease coverage by 4.9%.
The diff coverage is n/a.

❗ Current head 87f51d9 differs from pull request most recent head 4dbbe54. Consider uploading reports for the commit 4dbbe54 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             trunk   #37122      +/-   ##
===========================================
- Coverage     51.6%    46.7%    -4.9%     
+ Complexity   17444    17187     -257     
===========================================
  Files          440      429      -11     
  Lines        80297    64824   -15473     
===========================================
- Hits         41401    30255   -11146     
+ Misses       38896    34569    -4327     

see 358 files with indirect coverage changes

Copy link
Contributor

@louwie17 louwie17 left a comment

Choose a reason for hiding this comment

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

Nice work @mdperez86, in the end I do think it makes sense to keep the original feature flag around (as users did have the opportunity to enable it).
I think it would be beneficial to add a banner component to that screen that it will be replaced by the other block component in the near future (maybe one release).

I also left a couple other code suggestions to update some logic in a couple places and to also keep this feature flag disabled by default (for now).

'disable_ui' => false,
),
'new_product_management' => array(
'new_product_management' => array(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could remove this feature now, given it was disabled anyway and just replace it with the one below.

Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned above, on second thought I think it would be better to keep it for at-least one release.

'name' => __( 'New product management experience', 'woocommerce' ),
'description' => __( 'Try the new product management experience with Gutenberg Blocks (Alpha)', 'woocommerce' ),
'is_experimental' => true,
),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think on line 417:

} elseif ( 'new_product_management' === $feature_id ) {
return NewProductManagementExperience::TOGGLE_OPTION_NAME;
}

You either want to update that condition to use new_product_management_blocks or add an or case. At-least that way the current feature flag that we toggle using the beta tester still works.

Copy link
Contributor

Choose a reason for hiding this comment

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

We probably also want to update this condition:

if ( 'new_product_management' === $feature_id ) {
$disabled = true;
$desc_tip = __( '⚠ This feature will be available soon. Stay tuned!', 'woocommerce' );
}

So the blocks feature is also disabled by default (for now).

}
} else if (
window.wcAdminFeatures[ 'new-product-management-experience' ]
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could remove this else if condition if we just replace the current feature flag with the other one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm on second thought, users are able to enable it in the last released WooCommerce version, so we probably do want to keep this around for at-least one release.
We may want to add a big banner to the old UI also that it will be replace by the other feature in the next release?

@mdperez86 mdperez86 force-pushed the add/36989 branch 2 times, most recently from db12e28 to d05cc89 Compare March 8, 2023 16:35
@mdperez86
Copy link
Contributor Author

This PR is OnHold for now. See this #37128 for more details.


if ( window.wcAdminFeatures[ 'new-product-management-experience' ] ) {
pages.push( {
if ( isFeatureEnabled( 'new_product_management_blocks' ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noting that I have a PR waiting review that updates the feature name. #37339

$settings['connectNonce'] = wp_create_nonce( 'connect' );
$settings['wcpay_welcome_page_connect_nonce'] = wp_create_nonce( 'wcpay-connect' );

$settings['features'] = $this->get_features();
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels like we have 2 sources of truth for features now between this and wcAdminFeatures.

I like that this new set includes more information around the feature, but curious if the plan to eventually phase the old one out?

@louwie17
Copy link
Contributor

@mdperez86 could we update this PR to replace the new_product_management feature with the blocks editor? Removing the other experience?
We did also want to add an additional check if we are on the WordPress 6.2 or higher. We could do something similar as this:

$needs_update = version_compare( get_bloginfo( 'version' ), '5.6', '<' );
if ( $needs_update && current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
$update_text = sprintf(
// translators: 1: line break tag, 2: open link to WordPress update link, 3: close link tag.
__( '%1$s %2$sUpdate WordPress to enable the new navigation%3$s', 'woocommerce' ),
'<br/>',
'<a href="' . self_admin_url( 'update-core.php' ) . '" target="_blank">',
'</a>'
);
$disabled = true;
}

Let me know if it is easier to close this PR and start a new?

@github-actions
Copy link
Contributor

Hi @louwie17,

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:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

@mdperez86
Copy link
Contributor Author

@louwie17 I have 2 questions here.

  1. Since the new features flag system does not use the Features approach we don't have a place to initialize/setup the configuration that is related to a particular flag. In this case what it's under this class \Automattic\WooCommerce\Admin\Features\ProductBlockEditor\Init(). So I initialized this configuration within the Loader class because I don't know where should be a right place to put this. Do you have an answer for this?
  2. The configuration classes under this namespace \Automattic\WooCommerce\Admin\Features\ProductBlockEditor are not part of the old Features implementation anymore so. Where should we put them then?

@louwie17
Copy link
Contributor

Since the new features flag system does not use the Features approach we don't have a place to initialize/setup the configuration that is related to a particular flag. In this case what it's under this class \Automattic\WooCommerce\Admin\Features\ProductBlockEditor\Init(). So I initialized this configuration within the Loader

Hmm yeah, that wasn't quite what I intended. This is still technically a feature, so we can just enable it within the core config now as well. This means it is always enabled, and we can just check for the new feature flag within that (as you have already done within the Init function ).

class because I don't know where should be a right place to put this. Do you have an answer for this?
The configuration classes under this namespace \Automattic\WooCommerce\Admin\Features\ProductBlockEditor are not part of the old Features implementation anymore so. Where should we put them then?

In relation to the first question and answer, we can keep this here and not move this. Once the product editor isn't a feature anymore (not toggle able in settings) we can remove it from the Features folder.
We can however start removing the NewProductManagementExperience class within the Features folder.

@louwie17
Copy link
Contributor

@mdperez86 just a heads up that I did update your PR a slight bit, by keeping the product-block-editor feature within the development and core configs, but just enabling it in core now.

…elper, and enable product block editor feature.
Copy link
Contributor

@joshuatf joshuatf left a comment

Choose a reason for hiding this comment

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

This tests well for me and approving so we can get this in before the code freeze.

/wp-admin/admin.php?page=wc-admin&path=/add-product-old

Noting that the old editor does not show up here, but I don't think we should be showing the "old new editor" since we're considering this an iteration on that experience and it never left beta.

Also as mentioned earlier, I don't like that we have 2 very similar but slightly different APIs for features on both the frontend and backend now. These two are semantically indistinguishable so we should either move towards separating them further if they really are different or consolidating them if they house similar logic. Let's get some issues open to address this technical debt before it becomes a bigger issue.

@mdperez86
Copy link
Contributor Author

@joshuatf here is the issue #38365 to tackle what you mention. Thanks for your suggestions here.

@mdperez86 mdperez86 dismissed louwie17’s stale review May 19, 2023 16:53

Previous in meeting agreement on this

@mdperez86 mdperez86 merged commit ebf0b92 into trunk May 19, 2023
@mdperez86 mdperez86 deleted the add/36989 branch May 19, 2023 16:53
@github-actions github-actions bot added this to the 7.8.0 milestone May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin: woocommerce Issues related to the WooCommerce Core plugin.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Verify that all experimental product editor work is behind a feature flag

4 participants