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 ability to delete a Reusable Block #3792

Closed
noisysocks opened this issue Dec 3, 2017 · 9 comments · Fixed by #4139
Closed

Reusable Blocks: Add ability to delete a Reusable Block #3792

noisysocks opened this issue Dec 3, 2017 · 9 comments · Fixed by #4139
Assignees
Labels
[Feature] Blocks Overall functionality of blocks [Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) [Type] Enhancement A suggestion for improvement.

Comments

@noisysocks
Copy link
Member

The user should be able to delete a Reusable Block that they've created.

Technically, this can be accomplished by:

  • Implementing the delete_item and delete_item_permissions_check methods in WP_REST_Reusable_Blocks_Controller
  • Adding a DELETE_REUSABLE_BLOCK effect, which calls new wp.api.models.ReusableBlocks( { id } ).destroy()
  • Dispatching DELETE_REUSABLE_BLOCK when the user confirms their intent to delete the block

Some discussion about how the UI for this should work is required. Some ideas:

  1. Add an X icon to each Reusable Block in the Inserter. Clicking it would show an alert which confirms whether or not the user is OK with deleting the block. On confirmation, the block is deleted and a 'Reusable block deleted' notice is shown.
  2. Add a 'Delete Reusable Block' button to the Block Inspector. This is shown when a Reusable Block is selected. Clicking it would show an alert which confirms whether or not the user is OK with deleting the block. On confirmation, the block is deleted and a 'Reusable block deleted' notice is shown.

cc. @jasmussen @mtias

@noisysocks noisysocks added [Feature] Blocks Overall functionality of blocks [Type] Enhancement A suggestion for improvement. labels Dec 3, 2017
@noisysocks noisysocks self-assigned this Dec 3, 2017
@jasmussen
Copy link
Contributor

I know @karmatosed has some thoughts on this.

My instincts go along this route: have a new section dedicated to re-usable blocks that lives in the ellipsis menu. This ellipsis menu item could take you to a completely separate "screen takeover" section, that lists all your reusable blocks with options to delete either. This could also provide a more relaxed interface for renaming or even editing the blocks, as I'm sure future enhancements are likely to require some real estate.

Here are mockups for configuring "Publicize" as an extensibility pattern, something similar could be used here:

ellipsis

publicize

The chief downside with the above is that it's a lot of new work.

An alternative, for now, would be to simply add the "delete block" item to the block ellipsis menu:

block ellipsis

@mtias
Copy link
Member

mtias commented Dec 7, 2017

@jasmussen wouldn't it be alright to add a trash button to this mode?

image

I agree with having a view for managing all the reusable blocks down the line. Another thinking is how to categorize them. I'd love for this to be less user involved. Say if you have 20 reusable blocks of type x, that we automatically group them under a category in the "saved" blocks panel in the inserter. If you have a mix of types and only 5 blocks, it's ok to just let them mix.

The other thing is allowing the original icon to persist instead of forcing the icon to be the same.

@jasmussen
Copy link
Contributor

jasmussen commented Dec 7, 2017

All of those ideas sound good to me, provided we can

  • prompt on delete to make sure the user knows the action not only deletes the saved block source, but (presumably?) detaches all used instances from the block
  • the separate page for all the blocks can be revisited some time in the future

Given how important this feature feels, I suspect it'll be important to have a nice big screen section to manage these from a central location.

@westonruter
Copy link
Member

Given how important this feature feels, I suspect it'll be important to have a nice big screen section to manage these from a central location.

Indeed. The next generation of the Widgets admin screen.

@Lewiscowles1986
Copy link
Contributor

Lewiscowles1986 commented Dec 10, 2017

Just an idea, could the front-end remove the block if it's been removed, not render if the block doesn't exist, and then just add an admin ui to wherever you're storing blocks?

I have a plugin that delivers the same concept as re-usable blocks. You cannot delete one from a post, just from the admin area.

I've maintained it since 2015 (the code is from early 2014), and it has a visual editor integration using oEmbed. It does add some non-visual content in the case a block is not present (for debugging). But as it's implemented via CPT you get the benefit of powerful content and a deleted folder (users have to be really determined to ensure it's really deleted).

@afercia
Copy link
Contributor

afercia commented Dec 18, 2017

To my understanding, it is also possible that some reusable blocks will be "orphaned", meaning saved in the database but not currently used anywhere. That's when they're "detached" but the wp_block post still exists in the database, right?

If so, a dedicated UI to manage reusable blocks separately does make even more sense, as it would be the only place in the UI where they can be managed.

@amandablum
Copy link

I am also experiencing this issue, but want to give some more context to the issue. As an admin/user, not a developer, I expect reusable blocks to be one of the primary ways we give clients templates in a usable way (I know we can create blocks but the average admin isn't going to do that,.)
We want to consider the admin vs user usability of these blocks. Putting the delete button on an ACTUAL block in a post signals to me that I am merely deleting THAT block, not the reusable block, and I expect clients to misunderstand the use of the delete button and delete a reusable block they need, just not on that page. The only place I expect I would understand the totality of the block deletion is either in the menu from which we select blocks, or in the Gutenberg admin menu (I don't know if that's expected to live on).
Second, to delete a reusable block via the above methods means I first have to insert the block into a post/page, unless I misunderstand the flow above. As an admin, I'm noticing the blocks that need deletion (mostly because they were accidentally created) in the "add a block" menu.Its counter-intuitive to insert that bad block, and then delete it and expect it to disappear from the add a block menu.

@ryancwalsh
Copy link

I'm confused. This issue is marked as "closed", but I can't find (by poking around in WordPress or by searching the internet for docs) any way to edit or delete a reusable block.

Can someone tell me where/how to do that, even if it means logging into the server via SSH and editing files? I don't know where to look. Thanks.

@ryancwalsh
Copy link

Well, I just found "Remove from Reusable Blocks", which I swear wasn't there yesterday. Maybe when I updated Gutenberg today that feature became available, or maybe I'd just never seen it. So that answers the question about deletion. And the editing seems to work but with a delay (e.g. if you have 2 custom blocks in the same post and go to edit one). Okay. Sorry for the distraction. No real problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks [Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) [Type] Enhancement A suggestion for improvement.
Projects
None yet
9 participants