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

Bugfix: Prevent delete a template when has children #2479

Merged
merged 3 commits into from
Oct 28, 2024

Conversation

leekelleher
Copy link
Member

Description

Partial fix for umbraco/Umbraco-CMS#16443

When a template has child templates, the Delete action is available, (which would delete the parent template and orphan the child templates).

This PR adds a Template Has No Children Condition to prevent the Delete action being displayed for templates that have child templates.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

How to test?

  1. Create a template.
  2. Create another template below the first one created.
  3. Try to delete the parent template with children; does the Delete action display?

to prevent the "delete" action being displayed
for templates that have child templates.
Copy link
Contributor

@madsrasmussen madsrasmussen left a comment

Choose a reason for hiding this comment

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

Everything works as expected. Awesome!

I have done something similar for users where I went with a name like: UmbTemplateAllowDeleteActionCondition.

In the user case I had multiple conditions I needed to check so I combined them into one. It will make it possible to add tests where it might be difficult when they are split in JSON. Sometimes the server also sends a "canDelete/canEdit" etc. value we need to include in the check.

Just for the sake of sharing ideas: I think a "hasChildren/noChildren" condition will make sense though. I would just make it very general with its own "hasChildren"-context so it can be used in trees, workspaces, collections, etc.

https://github.com/umbraco/Umbraco.CMS.Backoffice/tree/main/src/packages/user/user/conditions

How does that sound to you?

@madsrasmussen madsrasmussen self-assigned this Oct 24, 2024
it didn't have any configurable properties.

Lazy-loaded the manifest api.
to "Template Allow Delete Action" condition.
@leekelleher leekelleher enabled auto-merge (squash) October 28, 2024 09:38
@leekelleher
Copy link
Member Author

@madsrasmussen Thanks for the feedback, I've updated accordingly.

Copy link
Contributor

@madsrasmussen madsrasmussen left a comment

Choose a reason for hiding this comment

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

fantastic 💯

@leekelleher leekelleher merged commit 32390f6 into release/15.0 Oct 28, 2024
8 checks passed
@leekelleher leekelleher deleted the v15/bugfix/template-delete-condition branch October 28, 2024 10:24
nielslyngsoe pushed a commit that referenced this pull request Nov 4, 2024
* Adds "Template Has No Children Condition"

to prevent the "delete" action being displayed
for templates that have child templates.

* Removed condition config type

it didn't have any configurable properties.

Lazy-loaded the manifest api.

* Renamed "Template Has No Children" condition

to "Template Allow Delete Action" condition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants