Skip to content

Element deletion blockers#18728

Open
brandonkelly wants to merge 6 commits into5.10from
feature/deletion-blockers
Open

Element deletion blockers#18728
brandonkelly wants to merge 6 commits into5.10from
feature/deletion-blockers

Conversation

@brandonkelly
Copy link
Copy Markdown
Member

Description

Adds the ability for elements to define blockers that should prevent their own deletion.

When the element is deleted via a supporting UI control, the element will be checked for blockers, and if there are any, a modal will be shown to the user that lists them, along with various options to resolve them.

A deletion blocker modal for a user, showing that they have two entries assigned to them, and two active subscriptions.

Elements can define their own deletion blockers via the new ElementInterface::deletionBlockers() method, and plugins can register additional blockers via a new Element::EVENT_DEFINE_DELETION_BLOCKERS event.

See ElementInterface::deletionBlockers() for documentation on blocker/action definitions, and craft\elements\User::deletionBlockers() for a usage example.

Related issues

[ci skip]
[ci skip]
# Conflicts:
#	src/templates/_elements/cardsview/elements.twig
#	src/templates/_elements/tableview/elements.twig
#	src/templates/_elements/thumbsview/elements.twig
#	src/web/assets/cp/dist/cp.js
#	src/web/assets/cp/dist/cp.js.map
Copy link
Copy Markdown
Contributor

@i-just i-just left a comment

Choose a reason for hiding this comment

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

This looks great!

I only found one proper bug, and the rest are questions/suggestions:

  1. it's not possible to delete assets via element index action on this branch (using local FS)
  2. when the deletion modal is presented, could we make the whole “accordion” title clickable (to expand), not just the icon?
  3. is it intended behaviour that you can’t use double-click to open, e.g. entries in the element index in the deletion modal? (the pencil icon works as expected)
  4. lets say you have a setup where some entries were authored by the user you want to delete; is there a reason why the “delete entries” action takes immediate effect, and reassign/remove author ones don’t?
    • if it needs to stay like this, could we tweak the confirmation message to say that this will take immediate effect? (I know most people rarely read those messages at all/in full, but it might be beneficial if/when they do)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants