Module: NotificationsHelper
- Includes:
- IconsHelper
- Defined in:
- app/helpers/notifications_helper.rb
Constant Summary
Constants included
from IconsHelper
IconsHelper::DEFAULT_ICON_SIZE
Instance Method Summary
collapse
#audit_icon, #boolean_to_icon, #custom_icon, #external_snippet_icon, #file_type_icon_class, #gl_loading_icon, #sprite_file_icons_path, #sprite_icon, #sprite_icon_path, #visibility_level_icon
Instance Method Details
#can_read_project?(project) ⇒ Boolean
78
79
80
|
# File 'app/helpers/notifications_helper.rb', line 78
def can_read_project?(project)
can?(current_user, :read_project, project)
end
|
#notification_description(level) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'app/helpers/notifications_helper.rb', line 55
def notification_description(level)
case level.to_sym
when :participating
_('You will only receive notifications for threads you have participated in')
when :mention
_('You will receive notifications only for comments in which you were @mentioned')
when :watch
_('You will receive notifications for any activity')
when :disabled
_('You will not get any notifications via email')
when :global
_('Use your global notification setting')
when :custom
_('You will only receive notifications for the events you choose')
when :owner_disabled
_('Notifications have been disabled by the project or group owner')
end
end
|
#notification_dropdown_items(notification_setting) ⇒ Object
82
83
84
85
86
87
88
89
|
# File 'app/helpers/notifications_helper.rb', line 82
def notification_dropdown_items(notification_setting)
NotificationSetting.levels.each_key.map do |level|
next if level == "custom"
next if level == "global" && notification_setting.source.nil?
level
end.compact
end
|
#notification_icon(level) ⇒ Object
31
32
33
34
35
36
|
# File 'app/helpers/notifications_helper.rb', line 31
def notification_icon(level)
icon = notification_icon_class(level)
return '' unless icon
sprite_icon(icon)
end
|
#notification_icon_class(level) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'app/helpers/notifications_helper.rb', line 6
def notification_icon_class(level)
case level.to_sym
when :disabled, :owner_disabled
'notifications-off'
when :participating
'notifications'
when :watch
'eye'
when :mention
'at'
when :global
'earth'
end
end
|
#notification_icon_level(notification_setting, emails_disabled = false) ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'app/helpers/notifications_helper.rb', line 21
def notification_icon_level(notification_setting, emails_disabled = false)
if emails_disabled
'owner_disabled'
elsif notification_setting.global?
current_user.global_notification_setting.level
else
notification_setting.level
end
end
|
#notification_title(level) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'app/helpers/notifications_helper.rb', line 38
def notification_title(level)
case level.to_sym
when :participating
s_('NotificationLevel|Participate')
when :mention
s_('NotificationLevel|On mention')
else
N_('NotificationLevel|Global')
N_('NotificationLevel|Watch')
N_('NotificationLevel|Disabled')
N_('NotificationLevel|Custom')
level = "NotificationLevel|#{level.to_s.humanize}"
s_(level)
end
end
|
#show_unsubscribe_title?(noteable) ⇒ Boolean
74
75
76
|
# File 'app/helpers/notifications_helper.rb', line 74
def show_unsubscribe_title?(noteable)
can?(current_user, "read_#{noteable.to_ability_name}".to_sym, noteable)
end
|