-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[Site Editor]: Consolidate save button functionality #60077
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
export default function useSaveEntities( { | ||
onSave, | ||
entitiesToSkip = [], | ||
close, |
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.
This doesn't seem right, but I think it's fine for now and handle in follow ups because it will require more disentanglement of how to properly call, name, etc..
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.
What's preventing this hook to be an action instead?
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.
Probably nothing. I can check and change.
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.
Updated to action
return true; | ||
} | ||
return false; | ||
return select( coreStore ).hasEditsForEntityRecord( |
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.
Not related, but had to change it since I saw it 😄
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.
cc @mcsf
variant={ isDisabled ? null : 'primary' } | ||
showTooltip={ false } | ||
icon={ isDisabled && ! isSaving ? check : null } | ||
showReviewMessage |
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.
This is the prop I mentioned in the PR's description to show a different message if there are more entities to update.
The defaultLabel
which I removed, was introduced and used for this specific case only.
Size Change: +319 B (0%) Total Size: 1.72 MB
ℹ️ View Unchanged
|
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.
Neat little change. It's working well for me.
Flaky tests detected in fbd63db. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/8388302003
|
97dc4eb
to
e4b495e
Compare
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.
Thanks for the follow-ups, @ntsekouras!
Do you mind adding more detailed testing instructions? Because unless I'm missing some obvious step, the Site Editor's saving flow works as before for single entities.
Screencast
CleanShot.2024-03-26.at.11.13.01.mp4
* @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`. | ||
*/ | ||
export const saveDirtyEntities = | ||
( { onSave, dirtyEntityRecords = [], entitiesToSkip = [], close } = {} ) => |
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.
The callback argument seems a bit odd to me. This is a pattern I've rarely seen with store actions. Do you think consumer components can handle them? Also, consumers should have all the data to generate the entitiesToSave
array.
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.
For sure close
should be consolidated probably with the onSave
and also see what will need more changing, but I was thinking of doing it separately as this is already moving a lots of stuff around and this action is private.
The end goal is the consolidation of publishing flows between editors, and this in essence is a first step towards that, by removing an extra save
button.
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.
Makes sense. Let's include cleanup/refactoring in the follow-up PR(s).
const PUBLISH_ON_SAVE_ENTITIES = [ | ||
{ kind: 'postType', name: 'wp_navigation' }, | ||
]; |
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.
Nit: I think we can move this constant at the file level.
This is true only for the home template. If we're editing any other entity it doesn't require two steps. For this PR I started with an approach of checking the |
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.
Thanks for the clarification, Nik!
I can confirm that single-step saving works as expected for entities other than the Home template.
I think the PR is in good shape as a starting point to consolidate the functionality. Let's polish the components and actions in follow-ups.
Co-authored-by: ntsekouras <[email protected]> Co-authored-by: youknowriad <[email protected]> Co-authored-by: jameskoster <[email protected]> Co-authored-by: Mamaduka <[email protected]> Co-authored-by: annezazu <[email protected]> Co-authored-by: SaxonF <[email protected]> Co-authored-by: richtabor <[email protected]>
Co-authored-by: ntsekouras <[email protected]> Co-authored-by: youknowriad <[email protected]> Co-authored-by: jameskoster <[email protected]> Co-authored-by: Mamaduka <[email protected]> Co-authored-by: annezazu <[email protected]> Co-authored-by: SaxonF <[email protected]> Co-authored-by: richtabor <[email protected]>
Just wondering if anyone who worked on this PR gets a chance, if you can take a look at the issue raised in #60650? It looks potentially related as this appears to have changed the logic for the activation button when users live preview a theme and then go to activate it, but haven't made any other changes to the state. 🤔 |
What?
Fixes: #60058
Currently we have many
save
buttons and some functionality is duplicated and adds complexity to the code. The save button in navigation sidebar sometimes uses the save button of document header and sometimes a custom one. When using the custom one, we almost duplicate the saving of the entities callback from thesave
button inEntitiesSavedStates
panel.This PR refactors the code:
review x item..
message, but we could also consolidate as well at some point(or here).EntitiesSavedStates
panelThe goal is to try to consolidate related components that will also help to the unification of publishing flows between post and site editors(issue).
Testing Instructions