Sha256: 1f5cbe48a973e62c7e80e36a904b3c63003443667e25e9c6f384003f2e77e895

Contents?: true

Size: 1.39 KB

Versions: 36

Compression:

Stored size: 1.39 KB

Contents

module Hyrax
  class HomepagePresenter
    class_attribute :create_work_presenter_class
    self.create_work_presenter_class = Hyrax::SelectTypeListPresenter
    attr_reader :current_ability, :collections

    def initialize(current_ability, collections)
      @current_ability = current_ability
      @collections = collections
    end

    # @return [Boolean] If the current user is a guest and the display_share_button_when_not_logged_in?
    #   is activated, then return true. Otherwise return true if the signed in
    #   user has permission to create at least one kind of work.
    def display_share_button?
      (user_unregistered? && Hyrax.config.display_share_button_when_not_logged_in?) ||
        current_ability.can_create_any_work?
    end

    # A presenter for selecting a work type to create
    # this is needed here because the selector is in the header on every page
    def create_work_presenter
      @create_work_presenter ||= create_work_presenter_class.new(current_ability.current_user)
    end

    def create_many_work_types?
      create_work_presenter.many?
    end

    def draw_select_work_modal?
      display_share_button? && create_many_work_types?
    end

    def first_work_type
      create_work_presenter.first_model
    end

    private

      def user_unregistered?
        current_ability.current_user.new_record? ||
          current_ability.current_user.guest?
      end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/presenters/hyrax/homepage_presenter.rb
hyrax-2.9.5 app/presenters/hyrax/homepage_presenter.rb
hyrax-2.9.4 app/presenters/hyrax/homepage_presenter.rb
hyrax-2.9.3 app/presenters/hyrax/homepage_presenter.rb
hyrax-2.9.2 app/presenters/hyrax/homepage_presenter.rb
hyrax-2.9.1 app/presenters/hyrax/homepage_presenter.rb
hyrax-2.9.0 app/presenters/hyrax/homepage_presenter.rb
hyrax-2.8.0 app/presenters/hyrax/homepage_presenter.rb
hyrax-2.7.2 app/presenters/hyrax/homepage_presenter.rb
hyrax-2.7.1 app/presenters/hyrax/homepage_presenter.rb
hyrax-2.7.0 app/presenters/hyrax/homepage_presenter.rb
hyrax-2.6.0 app/presenters/hyrax/homepage_presenter.rb
hyrax-3.0.0.pre.rc1 app/presenters/hyrax/homepage_presenter.rb
hyrax-3.0.0.pre.beta3 app/presenters/hyrax/homepage_presenter.rb
hyrax-2.5.1 app/presenters/hyrax/homepage_presenter.rb
hyrax-2.5.0 app/presenters/hyrax/homepage_presenter.rb
hyrax-3.0.0.pre.beta2 app/presenters/hyrax/homepage_presenter.rb
hyrax-2.4.1 app/presenters/hyrax/homepage_presenter.rb
hyrax-3.0.0.pre.beta1 app/presenters/hyrax/homepage_presenter.rb
hyrax-2.4.0 app/presenters/hyrax/homepage_presenter.rb