diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /lib/sidebars/projects/menus/infrastructure_menu.rb | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'lib/sidebars/projects/menus/infrastructure_menu.rb')
-rw-r--r-- | lib/sidebars/projects/menus/infrastructure_menu.rb | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/lib/sidebars/projects/menus/infrastructure_menu.rb b/lib/sidebars/projects/menus/infrastructure_menu.rb new file mode 100644 index 00000000000..75b6cae295f --- /dev/null +++ b/lib/sidebars/projects/menus/infrastructure_menu.rb @@ -0,0 +1,99 @@ +# frozen_string_literal: true + +module Sidebars + module Projects + module Menus + class InfrastructureMenu < ::Sidebars::Menu + override :configure_menu_items + def configure_menu_items + return false if Feature.disabled?(:sidebar_refactor, context.current_user) + return false unless context.project.feature_available?(:operations, context.current_user) + + add_item(kubernetes_menu_item) + add_item(serverless_menu_item) + add_item(terraform_menu_item) + + true + end + + override :link + def link + project_clusters_path(context.project) + end + + override :extra_container_html_options + def extra_container_html_options + { + class: 'shortcuts-infrastructure' + } + end + + override :title + def title + _('Infrastructure') + end + + override :sprite_icon + def sprite_icon + 'cloud-gear' + end + + private + + def kubernetes_menu_item + unless can?(context.current_user, :read_cluster, context.project) + return ::Sidebars::NilMenuItem.new(item_id: :kubernetes) + end + + ::Sidebars::MenuItem.new( + title: _('Kubernetes clusters'), + link: project_clusters_path(context.project), + active_routes: { controller: [:cluster_agents, :clusters] }, + container_html_options: { class: 'shortcuts-kubernetes' }, + hint_html_options: kubernetes_hint_html_options, + item_id: :kubernetes + ) + end + + def kubernetes_hint_html_options + return {} unless context.show_cluster_hint + + { disabled: true, + data: { trigger: 'manual', + container: 'body', + placement: 'right', + highlight: UserCalloutsHelper::GKE_CLUSTER_INTEGRATION, + highlight_priority: UserCallout.feature_names[:GKE_CLUSTER_INTEGRATION], + dismiss_endpoint: user_callouts_path, + auto_devops_help_path: help_page_path('topics/autodevops/index.md') } } + end + + def serverless_menu_item + unless can?(context.current_user, :read_cluster, context.project) + return ::Sidebars::NilMenuItem.new(item_id: :serverless) + end + + ::Sidebars::MenuItem.new( + title: _('Serverless platform'), + link: project_serverless_functions_path(context.project), + active_routes: { controller: :functions }, + item_id: :serverless + ) + end + + def terraform_menu_item + unless can?(context.current_user, :read_terraform_state, context.project) + return ::Sidebars::NilMenuItem.new(item_id: :terraform) + end + + ::Sidebars::MenuItem.new( + title: _('Terraform'), + link: project_terraform_index_path(context.project), + active_routes: { controller: :terraform }, + item_id: :terraform + ) + end + end + end + end +end |