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

Reusable Blocks: Change from store name provided as a string to store definition #27094

Conversation

grzim
Copy link
Contributor

@grzim grzim commented Nov 19, 2020

Description

Regarding #27088
Change from store name provided as a string to store definition applied

How has this been tested?

Not tested yet

Types of changes

Code refactor (non-breaking change)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@adamziel adamziel added [Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) [Package] Data /packages/data labels Nov 19, 2020
@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Nov 19, 2020
@gziolo gziolo self-requested a review November 19, 2020 11:04
/**
* Internal dependencies
*/
import { store as reusableBlocksStore } from './index.js';
Copy link
Member

Choose a reason for hiding this comment

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

This is surprising to see a cyclic dependency between store/index.js and store/controls.js. Would it be possible to access somehow dispatch from the current store instead? /cc @adamziel

Copy link
Contributor

@adamziel adamziel Nov 20, 2020

Choose a reason for hiding this comment

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

@gziolo The control needs to dispatch data on its own store so it's not easily avoidable. I think the only way of avoiding circular dependency would be not refactoring this file and just leaving the core/reusable-blocks string as it was before, or perhaps using the same constant as store/index.js, only imported from e.g. store/constants.js. This is going to be a general theme in plenty of registry actions and selectors too - we should address all those cases in the same way and either accept the circular dependency (it shouldn't break anything in this case) or use string to refer to the store from the same package.

Copy link
Member

@gziolo gziolo Nov 20, 2020

Choose a reason for hiding this comment

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

True, reusing the constant (internal to the local store's implementation) sounds like a good way of handling this particular case 👍

@gziolo
Copy link
Member

gziolo commented Nov 19, 2020

It looks like we can now remove the following statements from some packages:

import '@wordpress/reusable-blocks';

Screen Shot 2020-11-19 at 14 53 39

@adamziel, is there anything I could miss that justifies those imports after the refactoring proposed?

@gziolo
Copy link
Member

gziolo commented Nov 19, 2020

@grzim, thank you for opening this PR. In general, this looks good, I had some question to @adamziel who according to git authored @wordpress/reusable-blocks package.

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

This PR is good, we can always open a follow-up to address the usage in controls.

@gziolo gziolo merged commit c10f11a into WordPress:master Nov 24, 2020
@github-actions
Copy link

Congratulations on your first merged pull request, @grzim! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts:

https://profiles.wordpress.org/me/profile/edit/

And if you don't have a WordPress.org account, you can create one on this page:

https://login.wordpress.org/register

Kudos!

@github-actions github-actions bot added this to the Gutenberg 9.5 milestone Nov 24, 2020
@gziolo gziolo changed the title Change from store name provided as a string to store definition Reusable Blocks: Change from store name provided as a string to store definition Nov 24, 2020
@gziolo gziolo added the [Type] Code Quality Issues or PRs that relate to code quality label Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Data /packages/data [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants