summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz.bizon@ntsn.pl>2015-10-12 12:07:31 +0200
committerGrzegorz Bizon <grzegorz.bizon@ntsn.pl>2015-10-12 12:07:31 +0200
commitb8f5e7427f7cbcdb19dcc5554301e87a880cfe2a (patch)
tree9d2bb7a0dfd74eb0522607126b9f2d03b6289d06
parent5ffbf5feb7577ec3affc32992c79cddca3036c4d (diff)
downloadgitlab-ce-b8f5e7427f7cbcdb19dcc5554301e87a880cfe2a.tar.gz
Show notifications button even if user is not member of a project
Notifications button was unavailable if user wasn't member of the project, even if protected project is available via group privileges. Showing disabled button with explanation tool-tip is less confusing. This closes #2846.
-rw-r--r--app/controllers/projects_controller.rb1
-rw-r--r--app/views/projects/buttons/_notifications.html.haml33
2 files changed, 21 insertions, 13 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 213c2a7173b..ffbd91324cb 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -88,6 +88,7 @@ class ProjectsController < ApplicationController
else
if current_user
@membership = @project.project_member_by_id(current_user.id)
+ @group_member = GroupMember.find_by(user_id: current_user.id)
end
render :show
diff --git a/app/views/projects/buttons/_notifications.html.haml b/app/views/projects/buttons/_notifications.html.haml
index 4b69a6d7a6f..501a51d0e8a 100644
--- a/app/views/projects/buttons/_notifications.html.haml
+++ b/app/views/projects/buttons/_notifications.html.haml
@@ -1,14 +1,21 @@
-- return unless @membership
+- return unless [@membership, @group_member].any?
-= form_tag profile_notifications_path, method: :put, remote: true, class: 'inline-form', id: 'notification-form' do
- = hidden_field_tag :notification_type, 'project'
- = hidden_field_tag :notification_id, @membership.id
- = hidden_field_tag :notification_level
- %span.dropdown
- %a.dropdown-new.btn.btn-new#notifications-button{href: '#', "data-toggle" => "dropdown"}
- = icon('bell')
- = notification_label(@membership)
- = icon('angle-down')
- %ul.dropdown-menu.dropdown-menu-right.project-home-dropdown
- - Notification.project_notification_levels.each do |level|
- = notification_list_item(level, @membership)
+- if @membership
+ = form_tag profile_notifications_path, method: :put, remote: true, class: 'inline-form', id: 'notification-form' do
+ = hidden_field_tag :notification_type, 'project'
+ = hidden_field_tag :notification_id, @membership.id
+ = hidden_field_tag :notification_level
+ %span.dropdown
+ %a.dropdown-new.btn.btn-new#notifications-button{href: '#', "data-toggle" => "dropdown"}
+ = icon('bell')
+ = notification_label(@membership)
+ = icon('angle-down')
+ %ul.dropdown-menu.dropdown-menu-right.project-home-dropdown
+ - Notification.project_notification_levels.each do |level|
+ = notification_list_item(level, @membership)
+
+- elsif @group_member
+ .btn.btn-new.disabled#notifications-button
+ = icon('bell')
+ = notification_label(@group_member)
+ = icon('angle-down')