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

[PoC][Product Block Editor]: introduce custom Block Binding API #44524

Draft
wants to merge 26 commits into
base: trunk
Choose a base branch
from

Conversation

retrofox
Copy link
Contributor

@retrofox retrofox commented Feb 9, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

This PR introduces the Block Binding API in the product editor app.
Considering that the API is in full development in core, we have introduced an alternative implementation fully aligned with what the core API dictates.
Ideally, when the API is available in core we could switch without any problem.

Additionally, a source handler will be added that connects the block's attributes with the product's entities.

Finally, as an example of use, the product name field is connected to the entity.

Closes # .

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

Basic

  1. Go to the block editor
  2. Go to the General tab, Basic details section
  3. Confirm you can edit the product name as usual (edit, save, hard-refresh, ...)

Inspect the Name field block

  1. Use the React dev tool
  2. Identify the Name field block
  3. Inspect its attributes
  4. Confirm you see the new metadata attribute there
Screenshot 2024-02-09 at 17 47 57

Pro: dispatching an action to update the product property

  1. Open the dev console
  2. Identify the product ID (it's part of the URL)
  3. Run the following code (replace <post-id> with your testing product
wp.data.dispatch( 'core' ).editEntityRecord(
    'postType',
    'product',
    <post-id>,
    {
	  'name': 'The best product ever',
	}
);
  1. Confirm the app updates the product title with the value defined above (The best product ever')

Pro: dispatching an action to update the block property

  1. Focus the Product Name field (very important)
  2. Run the following code
wp.data.dispatch( 'core/block-editor' ).updateBlockAttributes(
    wp.data.select( 'core/block-editor' ).getSelectedBlock()?.clientId,
    {
        name: 'Mate de primera calidad'
    }
)
  1. Confirm the app updates the product title
  2. Save the product
  3. Hard refresh
  4. Confirm the product name was properly saved
Screen.Recording.2024-02-09.at.17.57.26.mov

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Comment

@retrofox retrofox added the focus: new product ux revamped product management experience label Feb 9, 2024
@retrofox retrofox requested a review from a team February 9, 2024 20:08
@retrofox retrofox self-assigned this Feb 9, 2024
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Feb 9, 2024
Copy link
Contributor

github-actions bot commented Feb 9, 2024

Hi , @woocommerce/mothra

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

@retrofox retrofox force-pushed the introduce/custom-block-binding-api branch from dd1c823 to 05ffa69 Compare February 9, 2024 20:24
Copy link
Contributor

github-actions bot commented Feb 9, 2024

Test Results Summary

Commit SHA: eb0d061

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 37s
E2E Tests3151123034014m 48s

⚠️ Warning

Please address the following issues prior to merging this pull request:
  • FAILED/BROKEN TESTS. There were failed and/or broken API and E2E tests.

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.

@retrofox retrofox force-pushed the introduce/custom-block-binding-api branch from 05ffa69 to 10e74ed Compare February 19, 2024 16:14
@retrofox retrofox changed the title [Product Block Editor]: introduce custom Block Binding API [PoC][Product Block Editor]: introduce custom Block Binding API Mar 18, 2024
@retrofox retrofox marked this pull request as draft March 26, 2024 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: new product ux revamped product management experience plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant