Class: Hyrax::Dashboard::UserPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/hyrax/dashboard/user_presenter.rb

Overview

Presenter for dashboard of a non-admin user

Instance Method Summary collapse

Constructor Details

#initialize(current_user, view_context, since) ⇒ UserPresenter

Returns a new instance of UserPresenter.



6
7
8
9
10
# File 'app/presenters/hyrax/dashboard/user_presenter.rb', line 6

def initialize(current_user, view_context, since)
  @current_user = current_user
  @view_context = view_context
  @since = since
end

Instance Method Details

#activityObject



12
13
14
# File 'app/presenters/hyrax/dashboard/user_presenter.rb', line 12

def activity
  @activity ||= current_user.all_user_activity(activity_seconds_ago)
end


40
41
42
43
# File 'app/presenters/hyrax/dashboard/user_presenter.rb', line 40

def link_to_additional_notifications
  return unless notifications.count > Hyrax.config.max_notifications_for_dashboard
  link_to t('hyrax.dashboard.additional_notifications'), hyrax.notifications_path
end


45
46
47
# File 'app/presenters/hyrax/dashboard/user_presenter.rb', line 45

def link_to_manage_proxies
  link_to t('hyrax.dashboard.manage_proxies'), hyrax.depositors_path, aria: { label: t('hyrax.dashboard.manage_proxies') }
end

#notificationsObject



16
17
18
# File 'app/presenters/hyrax/dashboard/user_presenter.rb', line 16

def notifications
  @notifications ||= current_user.mailbox.inbox
end

#render_recent_activityObject



24
25
26
27
28
29
30
# File 'app/presenters/hyrax/dashboard/user_presenter.rb', line 24

def render_recent_activity
  if activity.empty?
    t('hyrax.dashboard.no_activity')
  else
    render 'hyrax/users/activity_log', events: activity
  end
end

#render_recent_notificationsObject



32
33
34
35
36
37
38
# File 'app/presenters/hyrax/dashboard/user_presenter.rb', line 32

def render_recent_notifications
  if notifications.empty?
    t('hyrax.dashboard.no_notifications')
  else
    render "hyrax/notifications/notifications", messages: notifications_for_dashboard
  end
end

#transfersObject



20
21
22
# File 'app/presenters/hyrax/dashboard/user_presenter.rb', line 20

def transfers
  @transfers ||= Hyrax::TransfersPresenter.new(current_user, view_context)
end