summaryrefslogtreecommitdiff
path: root/lib/sidebars
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-29 09:10:11 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-29 09:10:11 +0000
commit38e4bfea582e8c755dd21613bf21658b1771449b (patch)
tree0856b453061d24face108bd980cd5a63b09ead21 /lib/sidebars
parent64d80d99a907c9b5ac0d72b6a958916c496e31b1 (diff)
downloadgitlab-ce-38e4bfea582e8c755dd21613bf21658b1771449b.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/sidebars')
-rw-r--r--lib/sidebars/projects/menus/ci_cd_menu.rb114
-rw-r--r--lib/sidebars/projects/panel.rb1
2 files changed, 115 insertions, 0 deletions
diff --git a/lib/sidebars/projects/menus/ci_cd_menu.rb b/lib/sidebars/projects/menus/ci_cd_menu.rb
new file mode 100644
index 00000000000..c0336d8dfbc
--- /dev/null
+++ b/lib/sidebars/projects/menus/ci_cd_menu.rb
@@ -0,0 +1,114 @@
+# frozen_string_literal: true
+
+module Sidebars
+ module Projects
+ module Menus
+ class CiCdMenu < ::Sidebars::Menu
+ override :configure_menu_items
+ def configure_menu_items
+ return unless can?(context.current_user, :read_build, context.project)
+
+ add_item(pipelines_menu_item)
+ add_item(pipelines_editor_menu_item)
+ add_item(jobs_menu_item)
+ add_item(artifacts_menu_item)
+ add_item(pipeline_schedules_menu_item)
+ end
+
+ override :link
+ def link
+ project_pipelines_path(context.project)
+ end
+
+ override :extra_container_html_options
+ def extra_container_html_options
+ {
+ class: 'shortcuts-pipelines rspec-link-pipelines'
+ }
+ end
+
+ override :title
+ def title
+ _('CI/CD')
+ end
+
+ override :title_html_options
+ def title_html_options
+ {
+ id: 'js-onboarding-pipelines-link'
+ }
+ end
+
+ override :sprite_icon
+ def sprite_icon
+ 'rocket'
+ end
+
+ private
+
+ def pipelines_menu_item
+ ::Sidebars::MenuItem.new(
+ title: _('Pipelines'),
+ link: project_pipelines_path(context.project),
+ container_html_options: { class: 'shortcuts-pipelines' },
+ active_routes: { path: pipelines_routes },
+ item_id: :pipelines
+ )
+ end
+
+ def pipelines_routes
+ %w[
+ pipelines#index
+ pipelines#show
+ pipelines#new
+ ]
+ end
+
+ def pipelines_editor_menu_item
+ return unless context.can_view_pipeline_editor
+
+ ::Sidebars::MenuItem.new(
+ title: s_('Pipelines|Editor'),
+ link: project_ci_pipeline_editor_path(context.project),
+ active_routes: { path: 'projects/ci/pipeline_editor#show' },
+ item_id: :pipelines_editor
+ )
+ end
+
+ def jobs_menu_item
+ ::Sidebars::MenuItem.new(
+ title: _('Jobs'),
+ link: project_jobs_path(context.project),
+ container_html_options: { class: 'shortcuts-builds' },
+ active_routes: { controller: :jobs },
+ item_id: :jobs
+ )
+ end
+
+ def artifacts_menu_item
+ return unless Feature.enabled?(:artifacts_management_page, context.project)
+
+ ::Sidebars::MenuItem.new(
+ title: _('Artifacts'),
+ link: project_artifacts_path(context.project),
+ container_html_options: { class: 'shortcuts-builds' },
+ active_routes: { path: 'artifacts#index' },
+ item_id: :artifacts
+ )
+ end
+
+ def pipeline_schedules_menu_item
+ ::Sidebars::MenuItem.new(
+ title: _('Schedules'),
+ link: pipeline_schedules_path(context.project),
+ container_html_options: { class: 'shortcuts-builds' },
+ active_routes: { controller: :pipeline_schedules },
+ item_id: :pipeline_schedules
+ )
+ end
+ end
+ end
+ end
+end
+
+Sidebars::Projects::Menus::CiCdMenu.prepend_if_ee('EE::Sidebars::Projects::Menus::CiCdMenu')
diff --git a/lib/sidebars/projects/panel.rb b/lib/sidebars/projects/panel.rb
index 1db4d55740a..4cafc530979 100644
--- a/lib/sidebars/projects/panel.rb
+++ b/lib/sidebars/projects/panel.rb
@@ -14,6 +14,7 @@ module Sidebars
add_menu(Sidebars::Projects::Menus::ExternalIssueTrackerMenu.new(context))
add_menu(Sidebars::Projects::Menus::LabelsMenu.new(context))
add_menu(Sidebars::Projects::Menus::MergeRequestsMenu.new(context))
+ add_menu(Sidebars::Projects::Menus::CiCdMenu.new(context))
end
override :render_raw_menus_partial