-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Refactor editor 'feature' preferences to interface package #33774
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
Merged
talldan
merged 35 commits into
trunk
from
refactor/editor-preferences-to-interface-package
Aug 18, 2021
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
3827a18
Add basic store state for preferences
talldan c52bf90
Add more menu component
talldan 23f7920
Persist preferences
talldan f9fb645
Fix translator comment
talldan 2a3073d
Add a few refinements to the dropdown menu component
talldan e19f5e2
Add dropdown menu styles
talldan 5a27418
Use more menu for edit widgets
talldan 0b67393
Update edit widgets to use feature toggles
talldan 8b664e2
Remove some dead code
talldan d5497d1
Allow setting default feature values
talldan 6329f05
Update some newer preferences after rebase
talldan ed0bba4
Remove invalid tests
talldan 2891d29
Update package.json
talldan 1704f95
Migrate editor preferences to edit-widgets
talldan b98850a
Update e2e test code for disabling the welcome guide
talldan 6a2e2c7
Move preference defaults to a separate reducer to avoid persistence
talldan 51442e1
Fix - export defaults reducer
talldan 5f4e4c0
Add component docs and missing selector doc
talldan 6d50c38
Add main readme docs
talldan 9dd1b0e
Addthe example to the component docs as well
talldan a6e40c8
Update changelogs
talldan fcdbb3d
Add tests for selector
talldan 0fcaf7c
Ensure toggling takes into account the default value
talldan f44f392
Rename MoreMenuDropdown to OptionsMenuDropdown
talldan 4e6b560
Rename MoreMenuFeatureToggle to OptionsMenuFeatureTogle
talldan 4b48a36
Rename OptionsMenuDropdown to OptionsMenu
talldan 0b2b8c0
Fix style import
talldan b0f879b
Fix migration handling for multiple stores
talldan ef7da49
Update docs for migration function
talldan 028565d
Fix store name
talldan e9c80c4
Revert "Fix style import"
talldan 9931b6d
Revert "Rename OptionsMenuDropdown to OptionsMenu"
talldan b9e6fd3
Revert "Rename MoreMenuFeatureToggle to OptionsMenuFeatureTogle"
talldan 5067fc2
Revert "Rename MoreMenuDropdown to OptionsMenuDropdown"
talldan 9f58d3a
Remove setFeatureDefaults as an API
talldan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Rename MoreMenuFeatureToggle to OptionsMenuFeatureTogle
- Loading branch information
commit 4e6b560e025a215f69b864df43f4bcec72c6ccb4
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having to define
core/edit-widgetseverywhere gets a bit repetitive. An option could be aScopeProvideras part of the interface package.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A local component might help, too:
I think that it's how this issue is mitigated in the edit post package. It had some backward compatiblity considerations, so we can explore other ideas, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of using a Provider. We can embed the provider inside
<InterfaceSkeleton>seamlessly unless there're needs to use the components outside the tree.An alternative could be to use hook-like API to re-implement this.
So that all descendent components can use the hook to automatically get the preference data without having to specify
scope.A downside of this API is that it's not an idiomatic
@wordpress/data-style selector we're used to, so it might be harder for third-party developers to hook into.I'm in favor of the current approach, just want to throw out some alternative approaches to see if it can bring up some ideas from others.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is exactly what I was thinking. It would still be possible for scope to be overridden if a prop is provided to a context using component, but I wouldn't see that being a common use case.
There are other components within the interface package that use
scope, so I'd have to double-check how they work, but I can work on a separate proof of concept.I also think it's worth seeing how this will work for editors that have more settings,
edit/widgetsisn't really a great example of this being a challenge, it may be that @gziolo's suggestion is easier and makes more sense in the post editor.One point on that is that
contextwon't help for the selectors or actions, the solutions there would be a custom react hook, or alternatively registry selectors / generator actions. There's existing evidence of that here in the edit-post package:gutenberg/packages/edit-post/src/store/actions.js
Lines 31 to 51 in 5a610d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If some of the options are shared across editors, we'll be using more than one scope here. Defining the scope manually might the best way to go until we've got this working everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd still be ok with any of the approaches. It could be a separate component that doesn't use the context (
GlobalFeatureToggle), or a prop that overrides the scope from context.