1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# 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 :link
def link
renderable_items.first.link
end
override :title
def title
context.group.subgroup? ? _('Subgroup information') : _('Group information')
end
override :sprite_icon
def sprite_icon
'group'
end
override :active_routes
def active_routes
{ path: 'groups#subgroups' }
end
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),
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),
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),
active_routes: { path: 'group_members#index' },
item_id: :members
)
end
end
end
end
end
|