diff options
author | Felipe Artur <felipefac@gmail.com> | 2016-04-13 15:42:33 -0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2016-04-13 15:42:33 -0300 |
commit | 5395e6175e77d3cd8800bb9f41c09d59934b502f (patch) | |
tree | 2234488f40eb4f7aa6920fbe2ab41b1d6f53e14e /app/helpers/notifications_helper.rb | |
parent | 39d853f5bd9492fa8dfc8e07ec11070705d3c879 (diff) | |
parent | c0678f2d281242601560e2646cab1aa8a349c4bb (diff) | |
download | gitlab-ce-issue_3508.tar.gz |
Merge branch 'master' into issue_3508issue_3508
Diffstat (limited to 'app/helpers/notifications_helper.rb')
-rw-r--r-- | app/helpers/notifications_helper.rb | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 499c655d2bf..54ab9179efc 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -1,48 +1,48 @@ module NotificationsHelper include IconsHelper - def notification_icon(notification) - if notification.disabled? - icon('volume-off', class: 'ns-mute') - elsif notification.participating? - icon('volume-down', class: 'ns-part') - elsif notification.watch? - icon('volume-up', class: 'ns-watch') - else - icon('circle-o', class: 'ns-default') + def notification_icon_class(level) + case level.to_sym + when :disabled + 'microphone-slash' + when :participating + 'volume-up' + when :watch + 'eye' + when :mention + 'at' + when :global + 'globe' end end - def notification_list_item(notification_level, user_membership) - case notification_level - when Notification::N_DISABLED - update_notification_link(Notification::N_DISABLED, user_membership, 'Disabled', 'microphone-slash') - when Notification::N_PARTICIPATING - update_notification_link(Notification::N_PARTICIPATING, user_membership, 'Participate', 'volume-up') - when Notification::N_WATCH - update_notification_link(Notification::N_WATCH, user_membership, 'Watch', 'eye') - when Notification::N_MENTION - update_notification_link(Notification::N_MENTION, user_membership, 'On mention', 'at') - when Notification::N_GLOBAL - update_notification_link(Notification::N_GLOBAL, user_membership, 'Global', 'globe') - else - # do nothing - end + def notification_icon(level, text = nil) + icon("#{notification_icon_class(level)} fw", text: text) end - def update_notification_link(notification_level, user_membership, title, icon) - content_tag(:li, class: active_level_for(user_membership, notification_level)) do - link_to '#', class: 'update-notification', data: { notification_level: notification_level } do - icon("#{icon} fw", text: title) - end + def notification_title(level) + case level.to_sym + when :participating + 'Participate' + when :mention + 'On mention' + else + level.to_s.titlecase end end - def notification_label(user_membership) - Notification.new(user_membership).to_s - end + def notification_list_item(level, setting) + title = notification_title(level) + + data = { + notification_level: level, + notification_title: title + } - def active_level_for(user_membership, level) - 'active' if user_membership.notification_level == level + content_tag(:li, class: ('active' if setting.level == level)) do + link_to '#', class: 'update-notification', data: data do + notification_icon(level, title) + end + end end end |