summaryrefslogtreecommitdiff
path: root/lib/sidebars
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-02-18 09:45:46 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-02-18 09:45:46 +0000
commita7b3560714b4d9cc4ab32dffcd1f74a284b93580 (patch)
tree7452bd5c3545c2fa67a28aa013835fb4fa071baf /lib/sidebars
parentee9173579ae56a3dbfe5afe9f9410c65bb327ca7 (diff)
downloadgitlab-ce-a7b3560714b4d9cc4ab32dffcd1f74a284b93580.tar.gz
Add latest changes from gitlab-org/gitlab@14-8-stable-eev14.8.0-rc42
Diffstat (limited to 'lib/sidebars')
-rw-r--r--lib/sidebars/concerns/work_item_hierarchy.rb26
-rw-r--r--lib/sidebars/projects/menus/ci_cd_menu.rb6
-rw-r--r--lib/sidebars/projects/menus/project_information_menu.rb3
3 files changed, 34 insertions, 1 deletions
diff --git a/lib/sidebars/concerns/work_item_hierarchy.rb b/lib/sidebars/concerns/work_item_hierarchy.rb
new file mode 100644
index 00000000000..a4153bb5120
--- /dev/null
+++ b/lib/sidebars/concerns/work_item_hierarchy.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+# This module has the necessary methods to render
+# work items hierarchy menu
+module Sidebars
+ module Concerns
+ module WorkItemHierarchy
+ def hierarchy_menu_item(container, url, path)
+ unless show_hierarachy_menu_item?(container)
+ return ::Sidebars::NilMenuItem.new(item_id: :hierarchy)
+ end
+
+ ::Sidebars::MenuItem.new(
+ title: _('Planning hierarchy'),
+ link: url,
+ active_routes: { path: path },
+ item_id: :hierarchy
+ )
+ end
+
+ def show_hierarachy_menu_item?(container)
+ can?(context.current_user, :read_planning_hierarchy, container)
+ end
+ end
+ end
+end
diff --git a/lib/sidebars/projects/menus/ci_cd_menu.rb b/lib/sidebars/projects/menus/ci_cd_menu.rb
index 67e4209c382..5df99bb9d84 100644
--- a/lib/sidebars/projects/menus/ci_cd_menu.rb
+++ b/lib/sidebars/projects/menus/ci_cd_menu.rb
@@ -68,9 +68,13 @@ module Sidebars
return ::Sidebars::NilMenuItem.new(item_id: :pipelines_editor)
end
+ params = {
+ branch_name: context.current_ref || context.project.default_branch
+ }
+
::Sidebars::MenuItem.new(
title: s_('Pipelines|Editor'),
- link: project_ci_pipeline_editor_path(context.project),
+ link: project_ci_pipeline_editor_path(context.project, params),
active_routes: { path: 'projects/ci/pipeline_editor#show' },
item_id: :pipelines_editor
)
diff --git a/lib/sidebars/projects/menus/project_information_menu.rb b/lib/sidebars/projects/menus/project_information_menu.rb
index 44b94ee3522..4056d50d324 100644
--- a/lib/sidebars/projects/menus/project_information_menu.rb
+++ b/lib/sidebars/projects/menus/project_information_menu.rb
@@ -4,10 +4,13 @@ module Sidebars
module Projects
module Menus
class ProjectInformationMenu < ::Sidebars::Menu
+ include ::Sidebars::Concerns::WorkItemHierarchy
+
override :configure_menu_items
def configure_menu_items
add_item(activity_menu_item)
add_item(labels_menu_item)
+ add_item(hierarchy_menu_item(context.project, project_planning_hierarchy_path(context.project), 'projects#planning_hierarchy'))
add_item(members_menu_item)
true