summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatricio Cano <suprnova32@gmail.com>2015-09-16 19:46:24 -0500
committerPatricio Cano <suprnova32@gmail.com>2015-09-16 19:46:24 -0500
commit4c98357f16b1acfa793d8a5b28c7147e21f20356 (patch)
tree4fac132cf08e07b89a44c5cc253727c4c2552924
parentde1ffce7391a9e6adf07a8be60cd36bbc95ef2f3 (diff)
downloadgitlab-ce-4c98357f16b1acfa793d8a5b28c7147e21f20356.tar.gz
Added Global to the drop downs and updated the label of the button to show the current level instead of `Notifications`
-rw-r--r--app/assets/javascripts/project.js.coffee12
-rw-r--r--app/helpers/notifications_helper.rb22
-rw-r--r--app/models/notification.rb19
-rw-r--r--app/views/projects/buttons/_notifications.html.haml6
-rw-r--r--features/steps/project/project.rb4
5 files changed, 48 insertions, 15 deletions
diff --git a/app/assets/javascripts/project.js.coffee b/app/assets/javascripts/project.js.coffee
index e187ec6ab77..0ea8fffce07 100644
--- a/app/assets/javascripts/project.js.coffee
+++ b/app/assets/javascripts/project.js.coffee
@@ -27,8 +27,16 @@ class @Project
$('.update-notification').on 'click', (e) ->
e.preventDefault()
- level = $(@).data 'notification-level'
- $('#notification_level').val(level)
+ notification_level = $(@).data 'notification-level'
+ $('#notification_level').val(notification_level)
$('#notification-form').submit()
+ label = null
+ switch notification_level
+ when 0 then label = ' Disabled '
+ when 1 then label = ' Participating '
+ when 2 then label = ' Watching '
+ when 3 then label = ' Global '
+ when 4 then label = ' On Mention '
+ $('#notifications-button').empty().append("<i class='fa fa-bell'></i>" + label + "<i class='fa fa-angle-down'></i>")
$(@).parents('ul').find('li.active').removeClass 'active'
$(@).parent().addClass 'active' \ No newline at end of file
diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb
index 48dc198e4e2..4fd06bebc2a 100644
--- a/app/helpers/notifications_helper.rb
+++ b/app/helpers/notifications_helper.rb
@@ -24,19 +24,25 @@ module NotificationsHelper
when Notification::N_PARTICIPATING
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')
+ icon('volume-up fw', text: 'Participate')
end
end
when Notification::N_WATCH
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')
+ icon('eye fw', text: 'Watch')
end
end
when Notification::N_MENTION
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')
+ icon('at fw', text: 'On mention')
+ end
+ end
+ when Notification::N_GLOBAL
+ content_tag(:li, class: active_level_for(user_membership, 'global?')) do
+ link_to '#', class: 'update-notification', data: { notification_level: Notification::N_GLOBAL } do
+ icon('globe fw', text: 'Global')
end
end
else
@@ -44,12 +50,14 @@ module NotificationsHelper
end
end
+ def notification_label(user_membership)
+ Notification.new(user_membership).to_s
+ 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'
+ if value.send(level)
+ 'active'
end
end
end
diff --git a/app/models/notification.rb b/app/models/notification.rb
index 828378655ce..171b8df45c2 100644
--- a/app/models/notification.rb
+++ b/app/models/notification.rb
@@ -26,7 +26,7 @@ class Notification
end
def project_notification_levels
- [N_DISABLED, N_PARTICIPATING, N_WATCH, N_GLOBAL, N_MENTION]
+ [N_DISABLED, N_MENTION, N_PARTICIPATING, N_WATCH, N_GLOBAL]
end
end
@@ -57,4 +57,21 @@ class Notification
def level
target.notification_level
end
+
+ def to_s
+ case level
+ when N_DISABLED
+ 'Disabled'
+ when N_PARTICIPATING
+ 'Participating'
+ when N_WATCH
+ 'Watching'
+ when N_MENTION
+ 'On mention'
+ when N_GLOBAL
+ 'Global'
+ else
+ # do nothing
+ end
+ end
end
diff --git a/app/views/projects/buttons/_notifications.html.haml b/app/views/projects/buttons/_notifications.html.haml
index e782aeb3616..9bb46157229 100644
--- a/app/views/projects/buttons/_notifications.html.haml
+++ b/app/views/projects/buttons/_notifications.html.haml
@@ -4,10 +4,10 @@
= hidden_field_tag :notification_id, @membership.id
= hidden_field_tag :notification_level
%span.dropdown
- %a.dropdown-toggle.btn.btn-new{href: '#', "data-toggle" => "dropdown"}
+ %a.dropdown-toggle.btn.btn-new#notifications-button{href: '#', "data-toggle" => "dropdown"}
= icon('bell')
- Notifications
+ = notification_label(@membership)
= icon('angle-down')
%ul.dropdown-menu.dropdown-menu-right.project-home-dropdown
- - Notification.notification_levels.each do |level|
+ - Notification.project_notification_levels.each do |level|
= notification_list_item(level, @membership) \ No newline at end of file
diff --git a/features/steps/project/project.rb b/features/steps/project/project.rb
index 54c026395fc..390a0ba9703 100644
--- a/features/steps/project/project.rb
+++ b/features/steps/project/project.rb
@@ -132,11 +132,11 @@ class Spinach::Features::Project < Spinach::FeatureSteps
end
step 'I click notifications drop down button' do
- click_link 'Notifications'
+ click_link 'notifications-button'
end
step 'I choose Mention setting' do
- click_link 'Mention'
+ click_link 'On mention'
end
step 'I should see Notification saved message' do