Class: Hyku::MenuPresenter

Inherits:
Hyrax::MenuPresenter show all
Defined in:
lib/generators/cdm_migrator/install/templates/presenters/hyku/menu_presenter.rb

Overview

view-model for the admin menu

Instance Attribute Summary

Attributes inherited from Hyrax::MenuPresenter

#view_context

Instance Method Summary collapse

Methods inherited from Hyrax::MenuPresenter

#collapsable_section, #initialize, #nav_link, #user_activity_section?

Constructor Details

This class inherits a constructor from Hyrax::MenuPresenter

Instance Method Details

#cdm_migrator_section?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/generators/cdm_migrator/install/templates/presenters/hyku/menu_presenter.rb', line 10

def cdm_migrator_section?
  %w[cdm csv].include?(controller_name)
end

#repository_activity_section?Boolean

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.

Returns:

  • (Boolean)


29
30
31
# File 'lib/generators/cdm_migrator/install/templates/presenters/hyku/menu_presenter.rb', line 29

def repository_activity_section?
  %w[admin dashboard status].include?(controller_name)
end

#roles_and_permissions_section?Boolean

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.

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
# File 'lib/generators/cdm_migrator/install/templates/presenters/hyku/menu_presenter.rb', line 16

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

#settings_section?Boolean

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.

Returns:

  • (Boolean)


6
7
8
# File 'lib/generators/cdm_migrator/install/templates/presenters/hyku/menu_presenter.rb', line 6

def settings_section?
  %w[appearances content_blocks labels features pages].include?(controller_name)
end

#show_admin_menu_items?Boolean

Returns true if we ought to show the user Admin-only areas of the menu

Returns:

  • (Boolean)


43
44
45
# File 'lib/generators/cdm_migrator/install/templates/presenters/hyku/menu_presenter.rb', line 43

def show_admin_menu_items?
  can?(:read, :admin_dashboard)
end

#show_configuration?Boolean

Returns true if we ought to show the user the ‘Configuration’ section of the menu

Returns:

  • (Boolean)


35
36
37
38
39
40
# File 'lib/generators/cdm_migrator/install/templates/presenters/hyku/menu_presenter.rb', line 35

def show_configuration?
  super ||
    can?(:manage, Site) ||
    can?(:manage, User) ||
    can?(:manage, Hyku::Group)
end