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

Feature: save lock control via actions #10649

Merged
merged 20 commits into from
Oct 26, 2018
Merged

Conversation

adamsilverstein
Copy link
Member

@adamsilverstein adamsilverstein commented Oct 16, 2018

Description

Add a post save locking feature. Plugins can add and remove locks and when any locks are present the publish and update buttons are disabled.

Supersedes #10115
Fixes #7020

How has this been tested?

Load gutenberg and make some edits. In the console, type:
wp.data.dispatch( 'core/editor' ).lockPostSaving( 'mylock' );
Note: the publish or update button becomes disabled.
Remove the post lock with:
wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'mylock' );

  • Test adding multiple locks: the button will remain disabled until all locks are removed.

Types of changes

  • Add actions for lock and unlock post saving.
  • Add an isPostSavingLocked selector
  • Check isPostSavingLocked in post publish button

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@adamsilverstein adamsilverstein added this to the 4.2 - API freeze milestone Oct 16, 2018
@adamsilverstein adamsilverstein added the [Type] Technical Prototype Offers a technical exploration into an idea as an example of what's possible label Oct 16, 2018
Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

Do we need to consider the post lock for autosaving?

We should have unit tests for at least selectors and reducer.

You need to run and commit changed files from npm run docs:build.

packages/editor/src/store/reducer.js Show resolved Hide resolved
packages/editor/src/store/selectors.js Outdated Show resolved Hide resolved
@adamsilverstein
Copy link
Member Author

Do we need to consider the post lock for autosaving?

I don't think so, these should fire as usual. Autosaves protect the user from lost content.

We should have unit tests for at least selectors and reducer.

I can add these, wanted to make sure approach was acceptable first.

You need to run and commit changed files from npm run docs:build.

Ah, ok will do.

@adamsilverstein
Copy link
Member Author

@aduth I have addressed your feedback and this is ready for review.

@gziolo gziolo added the [Feature] Extensibility The ability to extend blocks or the editing experience label Oct 19, 2018
@gziolo
Copy link
Member

gziolo commented Oct 19, 2018

All the changes look great.

We should have unit tests for at least selectors and reducer.

Let's do that ☝️

We also need to start a new document with UI extensibility for the editor and provide some examples on how to use it in action.

packages/editor/src/store/reducer.js Outdated Show resolved Hide resolved
@adamsilverstein
Copy link
Member Author

@aduth - I addressed your feedback.

@adamsilverstein
Copy link
Member Author

I'll work on some tests.

@gziolo gziolo removed the [Type] Technical Prototype Offers a technical exploration into an idea as an example of what's possible label Oct 26, 2018
@gziolo
Copy link
Member

gziolo commented Oct 26, 2018

Thanks @adamsilverstein, great to see we have it finally sorted out 🎉

@gziolo gziolo merged commit ac81cf7 into master Oct 26, 2018
@gziolo gziolo deleted the feature/save-lock-control branch October 26, 2018 08:14
@gziolo
Copy link
Member

gziolo commented Oct 26, 2018

I will open a follow-up with CHANGELOG update, I missed it.

daniloercoli added a commit that referenced this pull request Oct 26, 2018
…rnmobile/merge-blocks-on-backspace

* 'master' of https://github.com/WordPress/gutenberg:
  Do not add isDirty prop to DOM (#11093)
  Format API (#10209)
  Remove 4.2 deprecated features (#10952)
  Update `@wordpress/hooks` README to include namespace mention (#11061)
  Feature: save lock control via actions (#10649)
  Fix usage of `preg_quote()` (#10998)
  Update plugin version to 4.1.1 (#11078)
  Improve preloading request code (#11007)
  Fix dynamic blocks not rendering in the frontend (#11050)
  Media & Text: Fixing vertical alignment of the image (#11025)
  Date: Mark getSettings as experimental (#10636)
  Improve handling of centered 1-col galleries with small images (#11040)
  Use better help text for ALT text input; fixes #8391. (#11052)

# Conflicts:
#	packages/editor/src/components/rich-text/index.native.js
@chrisvanpatten
Copy link
Contributor

chrisvanpatten commented Nov 9, 2018

@adamsilverstein We've had a few requests for documentation on this so I'm digging in to try to understand how this was implemented. One question I have is why was this implemented just as a save lock, vs separate publish and save locks? Just curious from a conceptual level. I have read the original ticket and the other related closed PRs, but still not sure I understand.

@jaboi
Copy link

jaboi commented Nov 24, 2018

@chrisvanpatten Any update on documentation for this? I have a theme that requires a featured image to be horizontal, and the hooks I used to handle the validation and error messaging for this do not work at all with Gutenberg. I think this "save locking" feature is what I'm looking for, but need some kind of documentation to implement. Any feedback would be helpful. Thanks!

@jaboi
Copy link

jaboi commented Nov 27, 2018

Does anyone have a working example of this save lock control action for a publish/update conditional?

@adamsilverstein
Copy link
Member Author

We've had a few requests for documentation on this so I'm digging in to try to understand how this was implemented. One question I have is why was this implemented just as a save lock, vs separate publish and save locks? Just curious from a conceptual level. I have read the original ticket and the other related closed PRs, but still not sure I understand.

@chrisvanpatten missed this earlier. likely we chose this approach because this is how the buttons were already architected in regards to other conditionals. plugins should be able to control each button (publish vs update) individually still, happy to help with some example code here.

@bryanbartow
Copy link

Any update on documentation and/or example(s) for this? Can't seem to find anything here, on the codex, nor stack exchange.

@adamsilverstein adamsilverstein mentioned this pull request Jun 23, 2019
5 tasks
@adamsilverstein
Copy link
Member Author

Any update on documentation and/or example(s) for this? Can't seem to find anything here, on the codex, nor stack exchange.

Happy to add some documentation, where should this go?

@aduth
Copy link
Member

aduth commented Jun 25, 2019

Happy to add some documentation, where should this go?

Since this was merged, enhancements were made to the data documentation workflow, so we could include examples for actions (like the ones introduced here) using @example JSDoc tags.

See also:

@adamsilverstein
Copy link
Member Author

so we could include examples for actions (like the ones introduced here) using @example JSDoc tags.

Excellent, thanks for the tip. I'll work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pre-publish Checkup Extensibility - add a publish/update conditional
7 participants