-
Notifications
You must be signed in to change notification settings - Fork 46
/
menu_presenter.rb
43 lines (39 loc) · 1.55 KB
/
menu_presenter.rb
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
module Hyku
# view-model for the admin menu
class MenuPresenter < Hyrax::MenuPresenter
# Returns true if the current controller happens to be one of the controllers that deals
# with settings. This is used to keep the parent section on the sidebar open.
def settings_section?
%w[appearances content_blocks labels features pages].include?(controller_name)
end
# Returns true if the current controller happens to be one of the controllers that deals
# with roles and permissions. This is used to keep the parent section on the sidebar open.
def roles_and_permissions_section?
# we're using a case here because we need to differentiate UsersControllers
# in different namespaces (Hyrax & Admin)
case controller
when Hyrax::Admin::UsersController, ::Admin::GroupsController
true
else
false
end
end
# Returns true if the current controller happens to be one of the controllers that deals
# with repository activity This is used to keep the parent section on the sidebar open.
def repository_activity_section?
%w[admin dashboard status].include?(controller_name)
end
# Returns true if we ought to show the user the 'Configuration' section
# of the menu
def show_configuration?
super ||
can?(:manage, Site) ||
can?(:manage, User) ||
can?(:manage, Hyku::Group)
end
# Returns true if we ought to show the user Admin-only areas of the menu
def show_admin_menu_items?
can?(:read, :admin_dashboard)
end
end
end