summaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
authorPatricio Cano <suprnova32@gmail.com>2015-09-14 20:33:24 -0500
committerPatricio Cano <suprnova32@gmail.com>2015-09-14 20:33:24 -0500
commit01cc20378be1b77bd2a40a6af257e2cf116ce26a (patch)
tree043a3d8fc24f1cea2f530ffb1122e5ad00d12a96 /app/helpers
parent8a6fb46dff970d599860b06a6c9105c503cbb89c (diff)
downloadgitlab-ce-01cc20378be1b77bd2a40a6af257e2cf116ce26a.tar.gz
Notification dropdown now shows currently active level, and also shows what the actual value of `global` is, if the project has the notification level set to global.
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/notifications_helper.rb19
1 files changed, 14 insertions, 5 deletions
diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb
index 829993fd77f..48dc198e4e2 100644
--- a/app/helpers/notifications_helper.rb
+++ b/app/helpers/notifications_helper.rb
@@ -13,28 +13,28 @@ module NotificationsHelper
end
end
- def notification_list_item(notification_level)
+ def notification_list_item(notification_level, user_membership)
case notification_level
when Notification::N_DISABLED
- content_tag(:li) do
+ content_tag(:li, class: active_level_for(user_membership, 'disabled?')) do
link_to '#', class: 'update-notification', data: { notification_level: Notification::N_DISABLED } do
icon('microphone-slash fw', text: 'Disabled')
end
end
when Notification::N_PARTICIPATING
- content_tag(:li) do
+ content_tag(:li, class: active_level_for(user_membership, 'participating?')) do
link_to '#', class: 'update-notification', data: { notification_level: Notification::N_PARTICIPATING } do
icon('volume-up fw', text: 'Participating')
end
end
when Notification::N_WATCH
- content_tag(:li) do
+ content_tag(:li, class: active_level_for(user_membership, 'watch?')) do
link_to '#', class: 'update-notification', data: { notification_level: Notification::N_WATCH } do
icon('globe fw', text: 'Watch')
end
end
when Notification::N_MENTION
- content_tag(:li) do
+ content_tag(:li, class: active_level_for(user_membership, 'mention?')) do
link_to '#', class: 'update-notification', data: { notification_level: Notification::N_MENTION } do
icon('at fw', text: 'Mention')
end
@@ -43,4 +43,13 @@ module NotificationsHelper
# do nothing
end
end
+
+ def active_level_for(user_membership, level)
+ value = Notification.new(user_membership)
+ if value.global?
+ return 'active' if current_user.notification.send(level)
+ elsif value.send(level)
+ return 'active'
+ end
+ end
end