2021-10-27 15:23:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Sidebars
|
|
|
|
module Groups
|
|
|
|
module Menus
|
|
|
|
class PackagesRegistriesMenu < ::Sidebars::Menu
|
|
|
|
override :configure_menu_items
|
|
|
|
def configure_menu_items
|
|
|
|
add_item(packages_registry_menu_item)
|
|
|
|
add_item(container_registry_menu_item)
|
2022-11-25 23:54:43 +05:30
|
|
|
add_item(harbor_registry_menu_item)
|
2021-10-27 15:23:28 +05:30
|
|
|
add_item(dependency_proxy_menu_item)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
override :title
|
|
|
|
def title
|
2022-10-11 01:57:18 +05:30
|
|
|
_('Packages and registries')
|
2021-10-27 15:23:28 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
override :sprite_icon
|
|
|
|
def sprite_icon
|
|
|
|
'package'
|
|
|
|
end
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
override :serialize_as_menu_item_args
|
|
|
|
def serialize_as_menu_item_args
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
private
|
|
|
|
|
|
|
|
def packages_registry_menu_item
|
2022-01-26 12:08:38 +05:30
|
|
|
return nil_menu_item(:packages_registry) unless context.group.packages_feature_enabled?
|
2021-10-27 15:23:28 +05:30
|
|
|
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('Package Registry'),
|
|
|
|
link: group_packages_path(context.group),
|
2023-05-27 22:25:52 +05:30
|
|
|
super_sidebar_parent: ::Sidebars::Groups::SuperSidebarMenus::OperationsMenu,
|
2021-10-27 15:23:28 +05:30
|
|
|
active_routes: { controller: 'groups/packages' },
|
|
|
|
item_id: :packages_registry
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def container_registry_menu_item
|
|
|
|
if !::Gitlab.config.registry.enabled || !can?(context.current_user, :read_container_image, context.group)
|
2022-01-26 12:08:38 +05:30
|
|
|
return nil_menu_item(:container_registry)
|
2021-10-27 15:23:28 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('Container Registry'),
|
|
|
|
link: group_container_registries_path(context.group),
|
2023-05-27 22:25:52 +05:30
|
|
|
super_sidebar_parent: ::Sidebars::Groups::SuperSidebarMenus::OperationsMenu,
|
2021-10-27 15:23:28 +05:30
|
|
|
active_routes: { controller: 'groups/registry/repositories' },
|
|
|
|
item_id: :container_registry
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
def harbor_registry_menu_item
|
|
|
|
if Feature.disabled?(:harbor_registry_integration) ||
|
2023-03-04 22:38:38 +05:30
|
|
|
context.group.harbor_integration.nil? ||
|
|
|
|
!context.group.harbor_integration.activated?
|
2022-10-11 01:57:18 +05:30
|
|
|
return nil_menu_item(:harbor_registry)
|
|
|
|
end
|
2022-05-07 20:08:51 +05:30
|
|
|
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('Harbor Registry'),
|
2022-08-13 15:12:31 +05:30
|
|
|
link: group_harbor_repositories_path(context.group),
|
2023-05-27 22:25:52 +05:30
|
|
|
super_sidebar_parent: ::Sidebars::Groups::SuperSidebarMenus::OperationsMenu,
|
2022-05-07 20:08:51 +05:30
|
|
|
active_routes: { controller: 'groups/harbor/repositories' },
|
|
|
|
item_id: :harbor_registry
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
def dependency_proxy_menu_item
|
2022-01-26 12:08:38 +05:30
|
|
|
setting_does_not_exist_or_is_enabled = !context.group.dependency_proxy_setting ||
|
2023-03-04 22:38:38 +05:30
|
|
|
context.group.dependency_proxy_setting.enabled
|
2022-01-26 12:08:38 +05:30
|
|
|
|
|
|
|
return nil_menu_item(:dependency_proxy) unless can?(context.current_user, :read_dependency_proxy, context.group)
|
|
|
|
return nil_menu_item(:dependency_proxy) unless setting_does_not_exist_or_is_enabled
|
2021-10-27 15:23:28 +05:30
|
|
|
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('Dependency Proxy'),
|
|
|
|
link: group_dependency_proxy_path(context.group),
|
2023-05-27 22:25:52 +05:30
|
|
|
super_sidebar_parent: ::Sidebars::Groups::SuperSidebarMenus::OperationsMenu,
|
2021-10-27 15:23:28 +05:30
|
|
|
active_routes: { controller: 'groups/dependency_proxies' },
|
|
|
|
item_id: :dependency_proxy
|
|
|
|
)
|
|
|
|
end
|
2022-01-26 12:08:38 +05:30
|
|
|
|
|
|
|
def nil_menu_item(item_id)
|
|
|
|
::Sidebars::NilMenuItem.new(item_id: item_id)
|
|
|
|
end
|
2021-10-27 15:23:28 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|