class Hyrax::MenuPresenter

view-model for the admin menu

Attributes

view_context[R]

Public Class Methods

new(view_context) click to toggle source
# File lib/generators/cdm_migrator/install/templates/presenters/hyrax/menu_presenter.rb, line 4
def initialize(view_context)
  @view_context = view_context
end

Public Instance Methods

cdm_migrator_section?() click to toggle source
# File lib/generators/cdm_migrator/install/templates/presenters/hyrax/menu_presenter.rb, line 19
def cdm_migrator_section?
  %w[cdm csv].include?(controller_name)
end
collapsable_section(text, id:, icon_class:, open:, &block) click to toggle source

Draw a collaspable menu section. The passed block should contain <li> items.

# File lib/generators/cdm_migrator/install/templates/presenters/hyrax/menu_presenter.rb, line 50
def collapsable_section(text, id:, icon_class:, open:, &block)
  CollapsableSectionPresenter.new(view_context: view_context,
                                  text: text,
                                  id: id,
                                  icon_class: icon_class,
                                  open: open).render(&block)
end
settings_section?() click to toggle source

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.

# File lib/generators/cdm_migrator/install/templates/presenters/hyrax/menu_presenter.rb, line 15
def settings_section?
  %w[appearances content_blocks features pages collection_types].include?(controller_name)
end
show_configuration?() click to toggle source

@return [Boolean] will the configuration section be displayed to the user

# File lib/generators/cdm_migrator/install/templates/presenters/hyrax/menu_presenter.rb, line 59
def show_configuration?
  can?(:update, :appearance) ||
    can?(:manage, :collection_types) ||
    can?(:manage, Sipity::WorkflowResponsibility) ||
    can?(:manage, Hyrax::Feature)
end
user_activity_section?() click to toggle source

@return [Boolean] true if the current controller happens to be one of the controllers that deals with user activity This is used to keep the parent section on the sidebar open.

# File lib/generators/cdm_migrator/install/templates/presenters/hyrax/menu_presenter.rb, line 38
def user_activity_section?
  # we're using a case here because we need to differentiate UsersControllers
  # in different namespaces (Hyrax & Admin)
  case controller
  when Hyrax::UsersController, Hyrax::NotificationsController, Hyrax::TransfersController, Hyrax::DepositorsController
    true
  else
    false
  end
end