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

Use second-level navigation for the Relations create menu

Henriette Dargeca9968820345
diff --git a/app/components/work_package_relations_tab/index_component.html.erb b/app/components/work_package_relations_tab/index_component.html.erb
index 7493233286a..b362bc895b3 100644
--- a/app/components/work_package_relations_tab/index_component.html.erb
+++ b/app/components/work_package_relations_tab/index_component.html.erb
@@ -22,7 +22,13 @@
t(:label_relation)
end
- render_add_relations_menu_items(menu, ADD_RELATION_MENU_TYPES)
+ render_add_relations_menu_items(menu, FIRST_LEVEL_RELATION_MENU_TYPES)
+ menu.with_sub_menu_item(
+ label: t("#{I18N_NAMESPACE}.relations.label_other_relations"),
+ menu_id: ADD_RELATION_SUB_MENU
+ ) do |sub_menu|
+ render_add_relations_menu_items(sub_menu, SECOND_LEVEL_RELATION_MENU_TYPES)
+ end
end
end
end
diff --git a/app/components/work_package_relations_tab/index_component.rb b/app/components/work_package_relations_tab/index_component.rb
index 82d94b1ee5a..f8a93012023 100644
--- a/app/components/work_package_relations_tab/index_component.rb
+++ b/app/components/work_package_relations_tab/index_component.rb
@@ -9,6 +9,7 @@
class WorkPackageRelationsTab::IndexComponent < ApplicationComponent
FRAME_ID = "work-package-relations-tab-content"
ADD_RELATION_ACTION_MENU = "add-relation-action-menu"
+ ADD_RELATION_SUB_MENU = "add-relation-sub-menu"
ADD_CHILD_ACTION_MENU = "add-child-action-menu"
I18N_NAMESPACE = "work_package_relations_tab"
@@ -17,20 +18,23 @@ class WorkPackageRelationsTab::IndexComponent < ApplicationComponent
Relation::TYPE_CHILD
].freeze
- ADD_RELATION_MENU_TYPES = [
+ FIRST_LEVEL_RELATION_MENU_TYPES = [
*ADD_CHILD_MENU_TYPES,
- Relation::TYPE_RELATES,
Relation::TYPE_FOLLOWS,
Relation::TYPE_PRECEDES,
Relation::TYPE_PARENT,
- Relation::TYPE_DUPLICATES,
- Relation::TYPE_DUPLICATED,
+ Relation::TYPE_RELATES
+ ].freeze
+
+ SECOND_LEVEL_RELATION_MENU_TYPES = [
Relation::TYPE_BLOCKS,
Relation::TYPE_BLOCKED,
Relation::TYPE_INCLUDES,
Relation::TYPE_PARTOF,
Relation::TYPE_REQUIRES,
- Relation::TYPE_REQUIRED
+ Relation::TYPE_REQUIRED,
+ Relation::TYPE_DUPLICATES,
+ Relation::TYPE_DUPLICATED
].freeze
include ApplicationHelper
diff --git a/app/components/work_package_relations_tab/index_component.sass b/app/components/work_package_relations_tab/index_component.sass
index 64111497b3e..5548a04b742 100644
--- a/app/components/work_package_relations_tab/index_component.sass
+++ b/app/components/work_package_relations_tab/index_component.sass
@@ -1,6 +1,7 @@
// We reference an ID as one is required to be specified for the action menu list.
// It can't be nested inside the BEM model as it's placed as a #top-layer element.
#add-relation-action-menu-list,
+#add-relation-sub-menu-list,
#add-child-action-menu-list
max-height: 510px
max-width: 280px
diff --git a/config/locales/en.yml b/config/locales/en.yml
index a2365a15f09..972464dec73 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -895,6 +895,7 @@ en:
label_parent_singular: "parent"
label_parent_plural: "parent"
+ label_other_relations: "Other relations"
ghost_relation_title: "Related work package"
ghost_relation_description: "This is not visible to you due to permissions."
diff --git a/spec/support/components/work_packages/relations.rb b/spec/support/components/work_packages/relations.rb
index 7b27d918d9a..37f83d979b1 100644
--- a/spec/support/components/work_packages/relations.rb
+++ b/spec/support/components/work_packages/relations.rb
@@ -99,19 +99,19 @@ module Components
end
def select_relation_type(relation_type)
- within_add_relation_action_menu do
+ within_add_relation_action_menu(relation_type:) do
click_link_or_button relation_type
end
end
def expect_new_relation_type(relation_type)
- within_add_relation_action_menu do
+ within_add_relation_action_menu(relation_type:) do
expect(page).to have_link(relation_type, wait: 1)
end
end
def expect_no_new_relation_type(relation_type)
- within_add_relation_action_menu do
+ within_add_relation_action_menu(relation_type:) do
expect(page).to have_no_link(relation_type, wait: 1)
end
end
@@ -122,13 +122,28 @@ module Components
new_relation_button.click
end
+ def open_relation_sub_menu
+ return if add_relation_sub_menu.visible?
+
+ new_relation_sub_menu_button.click
+ end
+
def add_relation_action_menu
action_menu_id = new_relation_button["aria-controls"]
page.find(id: action_menu_id, visible: :all)
end
+ def add_relation_sub_menu
+ action_menu_id = new_relation_sub_menu_button["aria-controls"]
+ page.find(id: action_menu_id, visible: :all)
+ end
+
def new_relation_button
- page.find_test_selector("add-relation-action-menu").find_button
+ page.find(id: "add-relation-action-menu-button")
+ end
+
+ def new_relation_sub_menu_button
+ page.find(id: "add-relation-sub-menu-button")
end
def remove_relation(relatable)
@@ -389,8 +404,9 @@ module Components
private
- def within_add_relation_action_menu(&)
+ def within_add_relation_action_menu(relation_type:, &)
open_add_relation_action_menu
+ open_relation_sub_menu unless first_level_relation?(relation_type)
within(add_relation_action_menu, &)
end
@@ -411,6 +427,10 @@ module Components
end
end
end
+
+ def first_level_relation?(relation_type)
+ ["Related To", "Create new child", "Child", "Parent", "Predecessor (before)", "Successor (after)"].include?(relation_type)
+ end
end
end
end