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: Add reusable blocks UI #3378

Merged
merged 16 commits into from
Dec 8, 2017
Merged

Reusable Blocks: Add reusable blocks UI #3378

merged 16 commits into from
Dec 8, 2017

Conversation

noisysocks
Copy link
Member

@noisysocks noisysocks commented Nov 8, 2017

Adds the UI necessary for reusable blocks. This includes:

  • PHP code that renders a reusable block in a published post or page
  • The component rendered in the visual editor
  • The sidebar UI used to attach and detach reusable blocks
  • The inserter UI used to insert reusable blocks to the post

Some of this was already reviewed in #2659.

const { name, type, attributes } = getReusableBlock( getState(), id );
const content = serialize( createBlock( type, attributes ) );

new wp.api.models.ReusableBlocks( { id, name, content } ).save().then(
Copy link
Member

Choose a reason for hiding this comment

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

What is the name property? The WP REST API doesn't support a name attribute. Shouldn't it be title of the custom post type?

Copy link
Member Author

Choose a reason for hiding this comment

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

name is the name of the reusable block: https://github.com/WordPress/gutenberg/blob/master/lib/class-wp-rest-reusable-blocks-controller.php#L302-L307

I agree that naming that title is a better thing to call that, though. I'll put it on my list!

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see, thanks.

Your call. :)

@mtias mtias added [Feature] Block API API that allows to express the block paradigm. [Feature] Blocks Overall functionality of blocks Needs Design Feedback Needs general design feedback. labels Nov 8, 2017
@karmatosed
Copy link
Member

I wanted to test this to give some feedback, however I saw this:

2017-11-08 at 21 13

Is this a known issue or something I need to do to get it working?

@lamosty
Copy link
Member

lamosty commented Nov 9, 2017

@karmatosed:

I wanted to test this to give some feedback, however I saw this:

After you checkout the branch, try deleting node_modules, then npm install and npm run build again. I had the same issue.

@karmatosed
Copy link
Member

karmatosed commented Nov 10, 2017

I'm cc'ing in @jasmussen as I think we need to iterate on the design here. Currently we have this:

2017-11-10 at 20 45

This I am suggesting could be iterated by having some more friendly and informative language.

Here are some suggestions:

1

2

Overall, I think we need to think about the flow of this feature and how it could be discovered. I think where we have this is too hidden:

2017-11-10 at 20 49

Could we add this perhaps in the menu? Note, I've not added the icon and maybe we also need a tooltip to explain what this is.

3

@jasmussen
Copy link
Contributor

I think using the ellipsis menu for making reusable blocks has potential. I'm slightly concerned about putting more stuff in there as we're already looking at a few options there, with a bunch of transformations to come also. But it does feel like a good place for it.

@karmatosed
Copy link
Member

@jasmussen I have that concern myself. The current implementation feels like hiding a good feature though. Maybe we need to try it? Do we have a best guess at how many things we are going to have if everything we want gets in today? I'm thinking of a visual stress test.

@jasmussen
Copy link
Contributor

I think this may be one of those features whose full potential won't be realized until slightly later on, perhaps post phase-1, where we have more templating features and so on. Given this, perhaps we shouldn't hyper-optimize for the current UI, but instead leave room for us to learn about the feature and then find a better place. To put it differently, there seems to be agreement that it's a slick feature that deserves a better place, but perhaps it's a problem that's best solved in the future?

@noisysocks noisysocks changed the title Add reusable blocks UI Reusable Blocks: Add reusable blocks UI Nov 22, 2017
@codecov
Copy link

codecov bot commented Nov 23, 2017

Codecov Report

Merging #3378 into master will decrease coverage by 0.23%.
The diff coverage is 14.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3378      +/-   ##
==========================================
- Coverage    37.7%   37.46%   -0.24%     
==========================================
  Files         279      281       +2     
  Lines        6737     6780      +43     
  Branches     1226     1230       +4     
==========================================
  Hits         2540     2540              
- Misses       3536     3575      +39     
- Partials      661      665       +4
Impacted Files Coverage Δ
editor/components/block-settings-menu/index.js 0% <ø> (ø) ⬆️
editor/components/inserter/group.js 55% <ø> (ø) ⬆️
components/spinner/index.js 0% <0%> (-50%) ⬇️
editor/components/inserter/index.js 0% <0%> (ø) ⬆️
editor/components/block-list/block.js 2.22% <0%> (-0.02%) ⬇️
blocks/library/reusable-block/edit-panel/index.js 0% <0%> (ø)
...nents/block-settings-menu/reusable-block-toggle.js 25% <25%> (ø)
blocks/library/reusable-block/index.js 8.82% <3.12%> (-57.85%) ⬇️
editor/components/inserter/menu.js 84.26% <62.5%> (-1.28%) ⬇️
components/panel/row.js 0% <0%> (-100%) ⬇️
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 499b320...5f59ef1. Read the comment docs.

@noisysocks
Copy link
Member Author

noisysocks commented Nov 23, 2017

I rebased this PR and fixed some bugs that were introduced in the last rebase! 🙂

Since block-inspector/advanced-controls.js was removed in #3472, I had to re-implement how the 'Convert to Reusable Block' control is added to the sidebar. It now uses a hook (hooks/reusable-blocks.js) which is very similar to how hooks/custom-class-name.js works. This does the job, but it feels a little hacky to me since it involves connect()ing the InspectorControls.

The E2E tests are failing. A git bisect tells me that something in 295e025 is causing them to break, but I can't for the life of me figure out what it is. My best guess is that Cypress doesn't like it when we use Slot.Fill? 😕

@karmatosed
Copy link
Member

@jasmussen I still think it needs to move from where it is currently, I am ok if that for now is the ellipsis.

@noisysocks
Copy link
Member Author

Thanks for the 👀 @karmatosed! I'll move the controls into the ⋯ menu 🙂

@noisysocks
Copy link
Member Author

A git bisect tells me that something in 295e025 is causing them to break, but I can't for the life of me figure out what it is. My best guess is that Cypress doesn't like it when we use Slot.Fill? 😕

For posterity: turns out this was because <Editable> was being mounted twice as a result of the BlockEdit filter returning a deeply nested array rather than a flat array. 9472e0e was the fix. Thanks @youknowriad for the big hint in figuring this one out!

@noisysocks
Copy link
Member Author

screen shot 2017-11-27 at 13 12 10

I moved the button into the block settings menu. @jasmussen—are you able to whip up an icon for this?

@jasmussen
Copy link
Contributor

Nice work.

While the icon definitely could use some love, I think for now let's go with this dashicon https://developer.wordpress.org/resource/dashicons/#controls-repeat

Reusable blocks is an important interface that I expect we'll hone and polish many times in the future, but for now let's get the ball rolling!

@noisysocks
Copy link
Member Author

Icon changed!

@@ -0,0 +1,23 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

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

This component is not used anymore, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right! I've removed it.

@@ -48,7 +48,7 @@ export default class InserterGroup extends Component {
role="menuitem"
key={ block.name }
className="editor-inserter__block"
onClick={ selectBlock( block.name ) }
onClick={ selectBlock( block.name, block.attributes ) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should just pass the block object as an argument here instead of two arguments.

Copy link
Member Author

Choose a reason for hiding this comment

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

👌 fixed in 8ced4510795d9e428a2f6d1c2bbb4e2f744da23b.

return () => {
this.props.onSelect( name );
this.props.onSelect( name, attributes );
Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking more about this "attributes" argument. Regular blocks already have an attributes property but instead of containing attributes values, it contains attributes definition. I assume this will be called with the attributes definitions for these regular blocks which is not what's expected I guess.

It may not produce bugs at the moment but I think we should fix this ambiguity somehow.

Copy link
Member Author

Choose a reason for hiding this comment

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

👌 fixed in 8ced4510795d9e428a2f6d1c2bbb4e2f744da23b.

@mtias
Copy link
Member

mtias commented Nov 30, 2017

Looking good. A couple things.

I can search for "reusable block" and insert a broken block:

image

My saved block doesn't show up if I search for its name.

image

Let's add another tab to the inserter called "Saved" instead of putting saved blocks as a category of "blocks":

image

@mtias
Copy link
Member

mtias commented Nov 30, 2017

Another point is that the block inspector for the reusable block should let me delete the block from the records (with a warning that it'll stop working if it was used somewhere):

image

@mtias
Copy link
Member

mtias commented Nov 30, 2017

Also for later: creation of global blocks should be handled with proper capabilities (an author would not get access to create reusable blocks, but an editor would, etc). And let this be filterable if someone wants to allow anyone to create reusable blocks.

}

register_block_type( 'core/reusable-block', array(
'attributes' => array(
Copy link
Member

Choose a reason for hiding this comment

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

Some odd spaces here.

Copy link
Member Author

@noisysocks noisysocks Nov 30, 2017

Choose a reason for hiding this comment

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

The linter requires that the arrow on line 37 aligns with the arrow on line 43.

return gutenberg_render_block( $block );
}

register_block_type( 'core/reusable-block', array(
Copy link
Member

Choose a reason for hiding this comment

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

All the other terms we can more easily change, like internal variables, actions, and functions. But this we'll have to support once we announce.

I am not super comfortable with the name. A couple ideas:

  • core/global-block
  • core/saved-block -> to match the inserter tab.
  • or maybe this is an exception and is saved like global-block without the core suffix. Not to keen on an exception here, but it might warrant it (also of note, we have core-embed as a namespace.

For reference, the CPT is now called wp-block.

cc @aduth @youknowriad @mcsf @pento for naming thoughts

Copy link
Member

Choose a reason for hiding this comment

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

I'm not a native speaker, so if reusable-block is clearest I'm fine with sticking with it, just want to make sure we are ok with it.

Copy link
Member

Choose a reason for hiding this comment

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

Thinking a bit more, it seems the most clear and consistent with the wp-block post type is to call this core/block which maps to wp:block and wp:core/block. Thoughts?

Copy link
Member Author

@noisysocks noisysocks Nov 30, 2017

Choose a reason for hiding this comment

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

My only hesitation with global block is that global is a fairly technical term and that using it in the UI might limit how approachable this feature is to a wider audience.

For technical usages though, I'm happy with using a more precise term. core/block matching up with wp-block is very appealing.

Note that if we change this then we ought to change the /gutenberg/v1/reusable-blocks endpoint too, which would be a (fairly insignificant) breaking change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Saved block might speak to users more. Further, though I'm not a huge fan, there are precedents out there to justify custom blocks. Note that I can see reusable blocks working, if visual context and copy correctly introduce the concept.

Playing devil's advocate, saved and custom blocks may sound confusing ("Aren't I already making my own block when I add a "Paragraph" and type something in? Isn't it custom? Isn't it being saved?"). Those terms stress a different aspect from reusable, with reusable arguably stressing the user-facing value. (Mind you, a similar case can be made against reusable: "This Paragraph, or this Author block, aren't they reusable?")

Copy link
Member Author

@noisysocks noisysocks Dec 5, 2017

Choose a reason for hiding this comment

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

I'm going to go ahead and rename the block identifier to core/block so that we can move ahead with this PR. This makes sense to me since, just as <!-- wp:image --> inserts an image, <!-- wp:block --> inserts a wp_block.

Let's move the discussion about the name of the overall feature to a seperate issue. For what it's worth, I asked my wife (a regular WordPress user) what she thought and she said that custom block makes the most sense 🙂

icon="controls-repeat"
onClick={ isReusableBlock ? convertToStatic : convertToReusable }
>
{ isReusableBlock ? __( 'Detach from Reusable Block' ) : __( 'Make into a Reusable Block' ) }
Copy link
Member

Choose a reason for hiding this comment

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

Would "Convert to Reusable Block" or "Convert to Global Block" be more concise?

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed in 619d81f51afbd3bf0fd5a407e2a82a993b7a7051.

lib/blocks.php Outdated
/**
* Renders a single block into a HTML string.
*
* @since 1.3.0
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be updated.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in b8f96e9b5e7c905d37ba7e392083de1a249cc8a1.

@@ -790,7 +790,7 @@ function gutenberg_editor_scripts_and_styles( $hook ) {
$script = '( function() {';
$script .= sprintf( 'var editorSettings = %s;', wp_json_encode( $editor_settings ) );
$script .= <<<JS
window._wpLoadGutenbergEditor = Promise.all( [ wp.api.init(), wp.api.init( { versionString: 'gutenberg/v1' } ) ] ).then( function() {
window._wpLoadGutenbergEditor = Promise.all( [ wp.api.init(), wp.api.init( { versionString: 'gutenberg/v1/' } ) ] ).then( function() {
Copy link
Member

Choose a reason for hiding this comment

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

curious, what's the reason for this change?

Copy link
Member Author

@noisysocks noisysocks Nov 30, 2017

Choose a reason for hiding this comment

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

None of the Backbone methods work without the trailing slash, but we didn't catch that while testing #3377 since the unit tests mock the API call and no UI existed for any of this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think this is still useful with #3778

Copy link
Member Author

@noisysocks noisysocks Dec 4, 2017

Choose a reason for hiding this comment

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

Yes, since we're not using withAPIData.

const generatedClassName = hasBlockSupport( blockType, 'className', true ) ?
getBlockDefaultClassname( reusableBlock.type ) :
null;
const className = classnames( generatedClassName, reusableBlockAttributes.className );
Copy link
Member Author

Choose a reason for hiding this comment

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

Clever! Thanks so much @youknowriad 🙏

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.

Most comments aren't critical. This works great and is very cool to use and see 👍

key="save"
isPrimary
isLarge
isIndicatingProgress={ isSaving }
Copy link
Member

Choose a reason for hiding this comment

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

This prop does not exist on the Button component, and since Button passes through unrecognized props to the underlying DOM node, it results in a warning while editing:

Warning: React does not recognize the isIndicatingProgress prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase isindicatingprogress instead. If you accidentally passed it from a parent component, remove it from the DOM element.

Should this be the isBusy prop added in #3682?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. It definitely should be isBusy. Fixed in a820d1cc43dddd97d44e6e756707dfc6ab56c80b.

{ __( 'Detach' ) }
</Button>,
] }
{ ( isEditing || isSaving ) && [
Copy link
Member

Choose a reason for hiding this comment

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

Should the editing variation be visible while the name is being saved? In my testing, it flips back to the static text immediately upon hitting Save.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch—that's a bug that must have slipped in during a merge. Fixed in a820d1cc43dddd97d44e6e756707dfc6ab56c80b.

}
}

const ConnectedReusableBlockEdit = connect(
Copy link
Member

Choose a reason for hiding this comment

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

I don't have any ideas at the moment and it may have already been mentioned, but we need to work to find a solution where the block can access state without the implicit dependency on editor, either:

  • Blocks module having its own separate state
  • Merging more of [the non-post-editor-specific-] editor and blocks

Obvious too by the fact that we have equivalent action creators for what we're dispatching here, but unable (unwilling) to import them directly from editor.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed, and I also have no ideas on how to address this right now.

Merging more of [the non-post-editor-specific-] editor and blocks

Could you elaborate on this? I'm not quite caught up on my history here. Did we abandon the effort to merge the two modules (#2795)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just an idea: Does it make more sense for this block to be defined in the editor module instead?

I also even wonder if the blocks module should hold only the blocks API and define all the blocks in the editor module

Copy link
Contributor

Choose a reason for hiding this comment

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

Just an idea: Does it make more sense for this block to be defined in the editor module instead?

I think there's a lot of merit to that idea.

I also even wonder if the blocks module should hold only the blocks API and define all the blocks in the editor module

That one I'm not too convinced of right now. I mean, I could picture using editor/library, but the current situation of having the library sit next to the API makes sense to me, as the core blocks are the canonical blocks: in that sense, they highly complement the API (both code and docs) by providing numerous well tested use cases.

category: 'reusable-blocks',
isPrivate: true,

attributes: {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you should need to define this on the client, since it should be bootstrapped from the server definition.

See #2529

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm hesitant to do this because removing the client-side definition means our test fixtures aren't able to test parsing a <!-- wp:block ref="358b59ee-bab3-4d6f-8445-e8c6971a5605" /-->.


export default () => spinner;
function Spinner( { className } ) {
Copy link
Member

Choose a reason for hiding this comment

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

You're not / no longer taking advantage of these enhancements? Should we omit them respecting our good friend YAGNI?

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 I've removed these changes.

@@ -350,11 +350,13 @@ class BlockListBlock extends Component {
const { isHovered, isSelected, isMultiSelected, isFirstMultiSelected, focus } = this.props;
const showUI = isSelected && ( ! this.props.isTyping || ( focus && focus.collapsed === false ) );
const { error } = this.state;
const isReusableBlock = blockType.name === 'core/block';
Copy link
Member

Choose a reason for hiding this comment

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

Elsewhere we've limited our awareness to specific block types via abstraction, e.g. getDefaultBlockName, getUnknownTypeHandlerName. Should we need to consider that here? Maybe not the case we'd ever expect it to change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Couldn't hurt! I moved this logic out to isReusableBlock in 95a28a37adea3afeb44fb2b9c068c9e1fc61fb31.

import { convertBlockToStatic, convertBlockToReusable } from '../../actions';

export function ReusableBlockToggle( { block, convertToStatic, convertToReusable } ) {
const isReusableBlock = block.name === 'core/block';
Copy link
Member

Choose a reason for hiding this comment

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

Thinking purely from the presentational / container distinction, I might expect this variable to be passed as the prop, determined in a selector or mapStateToProps, particularly since we're not otherwise using the block prop.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 I've moved it in 95a28a37adea3afeb44fb2b9c068c9e1fc61fb31.

@@ -71,6 +71,10 @@ export class InserterMenu extends Component {
this.switchTab = this.switchTab.bind( this );
}

componentDidMount() {
this.props.fetchReusableBlocks();
Copy link
Member

Choose a reason for hiding this comment

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

Noting that this can become quite noisy for AJAX requests: Every time the user opens an inserter.

Personally I'm okay with this, since it ensures that the data is kept fresh, but worth keeping in mind.

Copy link
Member Author

Choose a reason for hiding this comment

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

For now I think this is OK. If it's a problem then we can limit it to fetch once when the inserter is opened for the first time.

@mtias
Copy link
Member

mtias commented Dec 7, 2017

@noisysocks Before we go ahead with exposing this at wide. Can you remind me why we are not using the ID provided by WP for the post object in wp_block like public 'ID' => int 2359 instead of the generated ref? It makes a lot more sense for me to see it as <!-- wp:block id="2359" /--> which is an internally consistent concept of WordPress.

noisysocks and others added 16 commits December 8, 2017 12:08
Adds the UI which displays when a reusable block is asked for its `edit`
component. This includes a panel which includes UI that indicates
whether a reusable block is loading and lets a user change the name of
the block.
Adds the necessary PHP code for rendering a reusable block as HTML on
the blog's front-end.
Changes BlockListBlock to display selected reusable blocks with a dashed
outline.
Add a block settings menu control which allows users to convert a
regular block to a reusable block and convert a reusable block to a
regular block.
Fix reusable blocks not loading by looking at the correct path in the
state tree (state.reusableBlocks.data) and by adding a trailing slash to
the /gutenberg/v1/ API versionString.
Patches the Inserter to display all reusable blocks in a seperate group,
and to insert a reusable block when one is clicked.
Distinguish between initialAttributes which are passed into createBlock
and attributes which define which attributes a block type supports.
Make the Inserter search both static blocks and reusable blocks.
Moves reusbale blocks from the Blocks tab to a new Saved tab in the
Inserter.
This way, just as <!-- wp:image --> inserts an image, <!-- wp:block --> inserts a wp_block.
Ensure that the Save button indicates that the block is being saved.
Move block.name === 'core/block' logic to a new isReusableBlock
function.
Copy link
Contributor

@mcsf mcsf left a comment

Choose a reason for hiding this comment

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

Per Slack, this looks great. The recent change to server-issued IDs is quite welcome.

@youknowriad youknowriad merged commit e437939 into WordPress:master Dec 8, 2017
@mtias
Copy link
Member

mtias commented Dec 8, 2017

Great work here everyone and specially @noisysocks. This is a great feature.

@noisysocks noisysocks deleted the add/reusable-blocks-ui branch December 11, 2017 02:36
@noisysocks
Copy link
Member Author

Also for later: creation of global blocks should be handled with proper capabilities (an author would not get access to create reusable blocks, but an editor would, etc). And let this be filterable if someone wants to allow anyone to create reusable blocks.

@mtias — could you please elaborate on this so that I can create an issue? Right now, any user with the edit_posts capability (authors, contributors and editors) can view and edit Reusable Blocks. Are you suggesting that we limit editing and creating Reusable Blocks to just editors?

@mtias
Copy link
Member

mtias commented Dec 11, 2017

Are you suggesting that we limit editing and creating Reusable Blocks to just editors? Right now, any user with the edit_posts capability (authors, contributors and editors) can view and edit Reusable Blocks.

We need to let authors insert them, but probably not edit them by default. Not sure if we should let authors create them, or only editors. Furthermore, this is something that should probably be filterable and part of general capabilities so people can map. Example: edit_blocks, insert_blocks, delete_blocks. Something more broad to think about. cc @pento

@ghost
Copy link

ghost commented Dec 11, 2017

@mtias ... something more broad.

There indeed needs to be a complete capabilities- and author-concept for reusable blocks.

A current users with a role below "editor" should only be able to see/create/edit/delete his/her own reusable blocks.

Users with/above "editor" role should be able to see/create/edit/delete any reusable block and also edit its author.

The concept should also provide a way to configure the visibility of reusable blocks for each user and/or post_type, not sure if via capability or filter.

Example for no visibility limit requirement: Simple one-user blog.

Example for visibility limit requirement: Multi author website with 15-20 authors and everybody creates a few reusable blocks which would then be visible for everybody, the gui would be a mess in no time...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Blocks Overall functionality of blocks [Feature] Synced Patterns Related to synced patterns (formerly reusable blocks)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants