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

Make child relationships uneditable

Aaron Contrerasee6ab4b84c93
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 e78da4db38e..13c8366e386 100644
--- a/app/components/work_package_relations_tab/relation_component.html.erb
+++ b/app/components/work_package_relations_tab/relation_component.html.erb
@@ -30,14 +30,18 @@
'aria-label': I18n.t(:label_agenda_item_actions),
scheme: :invisible,
ml: 2)
- menu.with_item(label: "Edit relation",
- href: edit_path,
- test_selector: edit_button_test_selector,
- content_arguments: {
- data: { turbo_stream: true }
- }) do |item|
- item.with_leading_visual_icon(icon: :pencil)
+ # Children have nothing to edit as it's not a relation.
+ unless parent_child_relationship?
+ menu.with_item(label: "Edit relation",
+ href: edit_path,
+ test_selector: edit_button_test_selector,
+ content_arguments: {
+ data: { turbo_stream: true }
+ }) do |item|
+ item.with_leading_visual_icon(icon: :pencil)
+ end
end
+
menu.with_item(label: "Delete relation",
scheme: :danger,
href: destroy_path,
diff --git a/app/components/work_package_relations_tab/relation_component.rb b/app/components/work_package_relations_tab/relation_component.rb
index 255becb1f65..8890b6e78b3 100644
--- a/app/components/work_package_relations_tab/relation_component.rb
+++ b/app/components/work_package_relations_tab/relation_component.rb
@@ -36,7 +36,7 @@ class WorkPackageRelationsTab::RelationComponent < ApplicationComponent
def edit_path
if parent_child_relationship?
- "#" # TODO: Implement work package child edit path
+ raise NotImplementedError, "Children relationships are not editable"
else
edit_work_package_relation_path(@work_package, @relation)
end
diff --git a/spec/features/work_packages/details/relations/primerized_relations_spec.rb b/spec/features/work_packages/details/relations/primerized_relations_spec.rb
index 77dcdb06e4a..799e765609e 100644
--- a/spec/features/work_packages/details/relations/primerized_relations_spec.rb
+++ b/spec/features/work_packages/details/relations/primerized_relations_spec.rb
@@ -227,5 +227,16 @@ RSpec.describe "Primerized work package relations tab",
expect(page).to have_text("And they can be edited!")
end
end
+
+ it "does not have an edit action for children" do
+ scroll_to_element relations_panel
+
+ child_row = relations_panel.find("[data-test-selector='op-relation-row-#{child_wp.id}']")
+
+ within(child_row) do
+ page.find("[data-test-selector='op-relation-row-#{child_wp.id}-action-menu']").click
+ expect(page).to have_no_css("[data-test-selector='op-relation-row-#{child_wp.id}-edit-button']")
+ end
+ end
end
end