debian-mirror-gitlab/lib/sidebars/groups/menus/group_information_menu.rb

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

85 lines
2.4 KiB
Ruby
Raw Normal View History

2021-10-27 15:23:28 +05:30
# frozen_string_literal: true
module Sidebars
module Groups
module Menus
class GroupInformationMenu < ::Sidebars::Menu
override :configure_menu_items
def configure_menu_items
add_item(activity_menu_item)
add_item(labels_menu_item)
add_item(members_menu_item)
true
end
override :title
def title
context.group.subgroup? ? _('Subgroup information') : _('Group information')
end
override :sprite_icon
def sprite_icon
2022-06-21 17:19:12 +05:30
context.group.subgroup? ? 'subgroup' : 'group'
2021-10-27 15:23:28 +05:30
end
override :active_routes
def active_routes
{ path: 'groups#subgroups' }
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 activity_menu_item
unless can?(context.current_user, :read_group_activity, context.group)
return ::Sidebars::NilMenuItem.new(item_id: :activity)
end
::Sidebars::MenuItem.new(
title: _('Activity'),
link: activity_group_path(context.group),
2023-05-27 22:25:52 +05:30
super_sidebar_parent: ::Sidebars::Groups::SuperSidebarMenus::PlanMenu,
2021-10-27 15:23:28 +05:30
active_routes: { path: 'groups#activity' },
item_id: :activity
)
end
def labels_menu_item
unless can?(context.current_user, :read_group_labels, context.group)
return ::Sidebars::NilMenuItem.new(item_id: :labels)
end
::Sidebars::MenuItem.new(
title: _('Labels'),
link: group_labels_path(context.group),
2023-05-27 22:25:52 +05:30
super_sidebar_parent: ::Sidebars::Groups::SuperSidebarMenus::PlanMenu,
super_sidebar_before: :activity,
2021-10-27 15:23:28 +05:30
active_routes: { controller: :labels },
item_id: :labels
)
end
def members_menu_item
unless can?(context.current_user, :read_group_member, context.group)
return ::Sidebars::NilMenuItem.new(item_id: :members)
end
::Sidebars::MenuItem.new(
title: _('Members'),
link: group_group_members_path(context.group),
2023-05-27 22:25:52 +05:30
sprite_icon: context.is_super_sidebar ? 'users' : nil,
super_sidebar_parent: ::Sidebars::StaticMenu,
2021-10-27 15:23:28 +05:30
active_routes: { path: 'group_members#index' },
item_id: :members
)
end
end
end
end
end