Skip to content

Conversation

@nathanss
Copy link
Contributor

@nathanss nathanss commented Nov 30, 2022

All Submissions:

Changes proposed in this Pull Request:

Creates a new component ProductForm to merge duplicated UI that existed between AddProductPage and EditProductPage.

No behavior should change.

Closes #35766.

  • This PR is a very minor change/addition and does not require testing instructions (if checked you can ignore/remove the next section).

How to test the changes in this Pull Request:

  1. Create a new product in New Product Management Experience.
  2. Fill out all fields.
  3. Click on 'Publish'.
  4. You will be redirected to the Edit Product page.
  5. Change all/some of the fields data.
  6. Click 'Update'
  7. Check if the Update occurred successfully

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?

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.

@github-actions github-actions bot added focus: react admin plugin: woocommerce Issues related to the WooCommerce Core plugin. labels Nov 30, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Nov 30, 2022

Test Results Summary

Commit SHA: eb0907f

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202611m 1s
E2E Tests186006019215m 15s

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.

@nathanss nathanss changed the title [WIP]: Create ProductForm component to merge duplicated UI Create ProductForm component to merge duplicated UI Nov 30, 2022
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.

Great work, Nathan! Left one possible addition to further cut down our duplication, but this is testing well and otherwise looks good. 😄

return (
<Form< Partial< Product > >
initialValues={
product || {
Copy link
Contributor

Choose a reason for hiding this comment

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

Love this! Clean and simple ❤️

import { ProductFormFooter } from './layout/product-form-footer';
import { ProductForm } from './product-form';

const AddProductPage: React.FC = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we merge AddProductPage and EditProductPage into a single component ProductPage? I think we could use const { productId } = useParams(); to distinguish whether or not we're creating a new product or editing one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so! Let me work on this

Copy link
Contributor

Choose a reason for hiding this comment

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

@nathanss attempted this but we ran into 2 issues:

  1. getPermalinkParts did not seem to get the parts correctly when switching between pages without a full refresh. Possibly related to encoding of slashes in the URL but I'm not entirely sure. cc @louwie17 if you have any context around this
  2. React router did not re-render properly when switching from a created product to a new product form. This may be due to them sharing the same component and caching happening on the routing level.

Since the remainder of the logic has been merged in this PR, I don't think we should let this block us from merging this one.

…duct-page: running into some issues probably with the controller
…ngle product-page: running into some issues probably with the controller"

This reverts commit bc30b67.
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.

Thanks so much for taking a stab at my initial feedback. This is testing well and LGTM!

Left a comment around the issues we ran into in case we want to update this to a single component in the future. 🚢

import { ProductFormFooter } from './layout/product-form-footer';
import { ProductForm } from './product-form';

const AddProductPage: React.FC = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

@nathanss attempted this but we ran into 2 issues:

  1. getPermalinkParts did not seem to get the parts correctly when switching between pages without a full refresh. Possibly related to encoding of slashes in the URL but I'm not entirely sure. cc @louwie17 if you have any context around this
  2. React router did not re-render properly when switching from a created product to a new product form. This may be due to them sharing the same component and caching happening on the routing level.

Since the remainder of the logic has been merged in this PR, I don't think we should let this block us from merging this one.

@nathanss nathanss merged commit 31773d4 into trunk Dec 5, 2022
@nathanss nathanss deleted the enhancement/35766 branch December 5, 2022 20:46
@github-actions github-actions bot added this to the 7.3.0 milestone Dec 5, 2022
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.

Add and edit product pages should not duplicate render logic

3 participants