debian-mirror-gitlab/lib/sidebars/projects/menus/deployments_menu.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

107 lines
3.3 KiB
Ruby
Raw Normal View History

2021-06-08 01:23:25 +05:30
# frozen_string_literal: true
module Sidebars
module Projects
module Menus
class DeploymentsMenu < ::Sidebars::Menu
override :configure_menu_items
def configure_menu_items
add_item(environments_menu_item)
2023-01-13 00:05:48 +05:30
add_item(feature_flags_menu_item)
2021-06-08 01:23:25 +05:30
add_item(releases_menu_item)
2023-03-17 16:20:25 +05:30
if Feature.enabled?(:show_pages_in_deployments_menu, context.current_user, type: :experiment)
add_item(pages_menu_item)
end
2021-06-08 01:23:25 +05:30
true
end
override :extra_container_html_options
def extra_container_html_options
{
class: 'shortcuts-deployments'
}
end
override :title
def title
_('Deployments')
end
override :sprite_icon
def sprite_icon
2021-11-18 22:05:49 +05:30
'deployments'
2021-06-08 01:23:25 +05:30
end
2023-05-27 22:25:52 +05:30
override :serialize_as_menu_item_args
def serialize_as_menu_item_args
nil
end
2021-06-08 01:23:25 +05:30
private
def feature_flags_menu_item
unless can?(context.current_user, :read_feature_flag, context.project)
return ::Sidebars::NilMenuItem.new(item_id: :feature_flags)
end
::Sidebars::MenuItem.new(
title: _('Feature Flags'),
link: project_feature_flags_path(context.project),
2023-05-27 22:25:52 +05:30
super_sidebar_parent: Sidebars::Projects::SuperSidebarMenus::OperationsMenu,
2021-06-08 01:23:25 +05:30
active_routes: { controller: :feature_flags },
container_html_options: { class: 'shortcuts-feature-flags' },
item_id: :feature_flags
)
end
def environments_menu_item
unless can?(context.current_user, :read_environment, context.project)
return ::Sidebars::NilMenuItem.new(item_id: :environments)
end
::Sidebars::MenuItem.new(
title: _('Environments'),
link: project_environments_path(context.project),
2023-05-27 22:25:52 +05:30
super_sidebar_parent: Sidebars::Projects::SuperSidebarMenus::OperationsMenu,
2021-06-08 01:23:25 +05:30
active_routes: { controller: :environments },
container_html_options: { class: 'shortcuts-environments' },
item_id: :environments
)
end
def releases_menu_item
if !can?(context.current_user, :read_release, context.project) ||
2023-03-04 22:38:38 +05:30
context.project.empty_repo?
2021-06-08 01:23:25 +05:30
return ::Sidebars::NilMenuItem.new(item_id: :releases)
end
::Sidebars::MenuItem.new(
title: _('Releases'),
link: project_releases_path(context.project),
2023-05-27 22:25:52 +05:30
super_sidebar_parent: Sidebars::Projects::SuperSidebarMenus::OperationsMenu,
2021-06-08 01:23:25 +05:30
item_id: :releases,
active_routes: { controller: :releases },
container_html_options: { class: 'shortcuts-deployments-releases' }
)
end
2023-03-17 16:20:25 +05:30
def pages_menu_item
unless context.project.pages_available? && context.current_user&.can?(:update_pages, context.project)
return ::Sidebars::NilMenuItem.new(item_id: :pages)
end
::Sidebars::MenuItem.new(
title: _('Pages'),
link: project_pages_path(context.project),
2023-05-27 22:25:52 +05:30
super_sidebar_parent: Sidebars::Projects::SuperSidebarMenus::OperationsMenu,
2023-03-17 16:20:25 +05:30
active_routes: { path: 'pages#show' },
item_id: :pages
)
end
2021-06-08 01:23:25 +05:30
end
end
end
end