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.


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

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

Instance Method Details

#activityObject


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

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

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

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

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

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

#notificationsObject


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

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

#render_recent_activityObject


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

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


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

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

#transfersObject


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

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