-
Notifications
You must be signed in to change notification settings - Fork 4.7k
PostPublishButton: Disable if saving non-post entities #33140
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
Changes from all commits
a085c04
c979ca3
8245031
50e896f
dc72ccb
ff1ca28
73c59c2
61d0634
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -802,6 +802,29 @@ export const isSavingPost = createRegistrySelector( ( select ) => ( state ) => { | |||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||
| * Returns true if non-post entities are currently being saved, or false otherwise. | ||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||
| * @param {Object} state Global application state. | ||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||
| * @return {boolean} Whether non-post entities are being saved. | ||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||
| export const isSavingNonPostEntityChanges = createRegistrySelector( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that selector name is a bit confusing, it doesn't match what it's actually doing. Because in theory, you could be saving other posts (think query block) that are different from the main one being edited in the page. So it's more like
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes me wonder though whether we should just check that we're saving any entity including the "post" one. I mean do we need the distinction in the component where we call the selector? Maybe the selector could be simpler if we just check whether there's an entity save in progress (regardless of which entity it is)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's true, but I modeled gutenberg/packages/editor/src/store/selectors.js Lines 150 to 172 in 0216850
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any thoughts about my second comment here, it makes the first one irrelevant because maybe the selector is not needed at all
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It seems like in the context of the Now if we're going to keep In the long run, it might make sense to replace
FWIW, that would basically just be
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense to me yeah. I have a feeling that our saving flow UI bits are way too complex and very hard to maintain for what they really are meant to do. they are also very old components that didn't see a lot of improvements over time aside the addition of adhoc multi-entities saving flow related changes but without rethinking the components themselves . I do think we need to check there for simplification/refactoring opportunities soon.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed! Coincidentally, here's a related UX issue: #33223 |
||||||||||||||||||||||||||||||||||||||||||||||||
| ( select ) => ( state ) => { | ||||||||||||||||||||||||||||||||||||||||||||||||
| const entitiesBeingSaved = select( | ||||||||||||||||||||||||||||||||||||||||||||||||
| coreStore | ||||||||||||||||||||||||||||||||||||||||||||||||
| ).__experimentalGetEntitiesBeingSaved(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| const { type, id } = getCurrentPost( state ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| return some( | ||||||||||||||||||||||||||||||||||||||||||||||||
| entitiesBeingSaved, | ||||||||||||||||||||||||||||||||||||||||||||||||
| ( entityRecord ) => | ||||||||||||||||||||||||||||||||||||||||||||||||
| entityRecord.kind !== 'postType' || | ||||||||||||||||||||||||||||||||||||||||||||||||
| entityRecord.name !== type || | ||||||||||||||||||||||||||||||||||||||||||||||||
| entityRecord.key !== id | ||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
ockham marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||
| * Returns true if a previous post save was attempted successfully, or false | ||||||||||||||||||||||||||||||||||||||||||||||||
| * otherwise. | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.