Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

while deleting a child check if the user has permission in child project to edit the wp

Behrokh Satarnejad21a35af6c25b
diff --git a/app/components/work_package_relations_tab/relation_component.html.erb b/app/components/work_package_relations_tab/relation_component.html.erb
index 303a2a5d1e0..9d010379b6c 100644
--- a/app/components/work_package_relations_tab/relation_component.html.erb
+++ b/app/components/work_package_relations_tab/relation_component.html.erb
@@ -25,19 +25,21 @@
end
end
- menu.with_item(label: I18n.t(:label_relation_delete),
- scheme: :danger,
- href: destroy_path,
- form_arguments: {
- method: :delete,
- data: {
- confirm: t("text_are_you_sure"),
- turbo_stream: true,
- update_work_package: true
- }
- },
- test_selector: delete_button_test_selector) do |item|
- item.with_leading_visual_icon(icon: :trash)
+ if should_render_delete_option?
+ menu.with_item(label: I18n.t(:label_relation_delete),
+ scheme: :danger,
+ href: destroy_path,
+ form_arguments: {
+ method: :delete,
+ data: {
+ confirm: t("text_are_you_sure"),
+ turbo_stream: true,
+ update_work_package: true
+ }
+ },
+ test_selector: delete_button_test_selector) do |item|
+ item.with_leading_visual_icon(icon: :trash)
+ end
end
end
end
diff --git a/app/components/work_package_relations_tab/relation_component.rb b/app/components/work_package_relations_tab/relation_component.rb
index 8bdcdbcaae3..a13fb9756ef 100644
--- a/app/components/work_package_relations_tab/relation_component.rb
+++ b/app/components/work_package_relations_tab/relation_component.rb
@@ -63,6 +63,12 @@ class WorkPackageRelationsTab::RelationComponent < ApplicationComponent
helpers.current_user.allowed_in_project?(:manage_work_package_relations, @work_package.project)
end
+ def should_render_delete_option?
+ return true unless parent_child_relationship?
+
+ helpers.current_user.allowed_in_project?(:manage_subtasks, @child.project)
+ end
+
def visible?
@visibility == :visible
end