Skip to content

[OP-19734] Fix deletion of work packages with children, by looking at who we can delete and see - #24473

Merged
oliverguenther merged 3 commits into
release/17.7from
fix/deletion-of-work-packages-with-children
Jul 29, 2026
Merged

[OP-19734] Fix deletion of work packages with children, by looking at who we can delete and see#24473
oliverguenther merged 3 commits into
release/17.7from
fix/deletion-of-work-packages-with-children

Conversation

@oliverguenther

@oliverguenther oliverguenther commented Jul 28, 2026

Copy link
Copy Markdown
Member

Both delete dialogs built their descendant list with a plain WorkPackage query and no proper permission check.
Selecting a work package with a child in a project you have no access to resulted in a visibility violation.

The dialogs now filter descendants with WorkPackage.visible and count the rest.
A warning banner says how many descendants you cannot see, without naming them or their projects.

The bulk dialog now renders the multi-project warning as an info banner instead.

As discussed with product, we want to unlink descendants rather than preventing deletion of the parent.
For that,DeleteService now iterates all descendants. The ones without permission keep their own hierarchy, but get the parent unlinked depending on:

  • with manage_subtasks in the parent's project they are detached (parent: nil) and carry a new Journal::CausedByWorkPackageParentDeletion, rendering as "Parent removed because the parent work package was deleted"
  • without it the call fails with :cannot_detach_undeletable_descendants and nothing is deleted

Adds substantial test coverage for invisible descendants in children, grandchildren in other projects, etc.

Adds a cause for deleted parents
2026-07-28_16-07-52@2x

https://community.openproject.org/work_packages/OP-19734

Case 1 - no children
2026-07-28_15-36-06

Case 2: children that I can delete

2026-07-28_15-36-34

Case 3(a) One invisible

2026-07-28_15-37-31

Case 3(b) Multiple invisible

2026-07-28_15-38-18

Case 4(a) can't delete one, can't view one, CAN delete one

image

Case 5 - Bulk delete, can't see some descendants
2026-07-28_15-38-51

Case 5(a) - Bulk delete, with some visible descendants to be deleted

2026-07-28_15-39-45

Case 5(b) - Delete with some children viewable, not deletable
2026-07-28_15-41-17

Project names linked

2026-07-28_15-44-53@2x

@oliverguenther
oliverguenther force-pushed the fix/deletion-of-work-packages-with-children branch 2 times, most recently from 84d4ce1 to f2e73af Compare July 28, 2026 14:06
@oliverguenther
oliverguenther marked this pull request as ready for review July 28, 2026 14:10
@oliverguenther
oliverguenther force-pushed the fix/deletion-of-work-packages-with-children branch 6 times, most recently from db430db to ec9ecf2 Compare July 29, 2026 08:35
… who we can delete and see

Both delete dialogs built their descendant list with a plain WorkPackage query and no proper permission check.
Selecting a work package with a child in a project you have no access to resulted in a visibility violation.

The dialogs now filters descendants with WorkPackage.visible, categorize them into ones that they can see, but not delete, or not see.
A warning banner says how many descendants you cannot see (or delete), without naming them or their projects.

As discussed with product, we want to unlink descendants rather than preventing deletion of the parent.
For that,DeleteService now iterates all descendants. The ones without permission keep their own hierarchy, but get the parent unlinked depending on:

- with manage_subtasks in the parent's project they are detached (parent: nil) and carry a new Journal::CausedByWorkPackageParentDeletion, rendering as "Parent removed because the parent work package was deleted"
- without it the call fails with :cannot_detach_undeletable_descendants and nothing is deleted

Adds substantial test coverage for invisible descendants in children, grandchildren in other projects, etc.

https://community.openproject.org/work_packages/OP-19734
@oliverguenther
oliverguenther force-pushed the fix/deletion-of-work-packages-with-children branch from ec9ecf2 to 4a0c2ac Compare July 29, 2026 08:36

@mrmir mrmir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice! I think I got to all the test cases locally as well 🤞🏽

Comment thread spec/components/work_packages/delete_dialog_component_spec.rb Outdated
Co-authored-by: Mir Bhatia <m.bhatia@openproject.com>
@oliverguenther
oliverguenther merged commit 3be1626 into release/17.7 Jul 29, 2026
13 of 14 checks passed
@oliverguenther
oliverguenther deleted the fix/deletion-of-work-packages-with-children branch July 29, 2026 12:29
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants