]> source.dussan.org Git - redmine.git/commitdiff
Show a warning message for watchers who cannot view the object (#33329).
authorGo MAEDA <maeda@farend.jp>
Sun, 24 Jan 2021 05:38:22 +0000 (05:38 +0000)
committerGo MAEDA <maeda@farend.jp>
Sun, 24 Jan 2021 05:38:22 +0000 (05:38 +0000)
Patch by Marius BALTEANU.

git-svn-id: http://svn.redmine.org/redmine/trunk@20725 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/watchers_helper.rb
config/locales/en.yml
public/stylesheets/application.css
test/functional/issues_controller_test.rb

index ce39d7fb3eed711b4cadf3c18fffecda60fed8ea..b3b9dc772c73bef2fbb74b97f7531e3344e87e36 100644 (file)
@@ -52,6 +52,9 @@ module WatchersHelper
       s = ''.html_safe
       s << avatar(user, :size => "16").to_s
       s << link_to_user(user, :class => 'user')
+      if object.respond_to?(:visible?) && user.is_a?(User) && !object.visible?(user)
+        s << content_tag('span', l(:notice_invalid_watcher), class: 'icon-only icon-warning', title: l(:notice_invalid_watcher))
+      end
       if remove_allowed
         url = {:controller => 'watchers',
                :action => 'destroy',
index 142afa001c59c35be65dbfe883604ce997d94afd..00f246f333e75e6121fa6f6b8c02e986659f472d 100644 (file)
@@ -193,6 +193,7 @@ en:
   notice_issue_not_closable_by_open_tasks: "This issue cannot be closed because it has at least one open subtask."
   notice_issue_not_closable_by_blocking_issue: "This issue cannot be closed because it is blocked by at least one open issue."
   notice_issue_not_reopenable_by_closed_parent_issue: "This issue cannot be reopened because its parent issue is closed."
+  notice_invalid_watcher: "Invalid watcher: User will not receive any notifications because it does not have access to view this object."
 
   error_can_t_load_default_data: "Default configuration could not be loaded: %{value}"
   error_scm_not_found: "The entry or revision was not found in the repository."
index 627e0bd58893a25f773ea403545d3a05db2b01a1..da96a7d8da501a3b9f05f3bade9cd84b0bdf6874 100644 (file)
@@ -104,6 +104,7 @@ div#wrapper, div#wrapper2, div#wrapper3 { min-height: inherit; }
 #sidebar div.wiki ul li {list-style-type:inherit;}
 #sidebar a.icon-only {opacity: 0.4; margin-left: 5px;}
 #sidebar a.icon-only:hover {opacity: 1;}
+#sidebar span.icon-warning {margin-left: 5px;}
 #sidebar li input[type=checkbox] {height: 20px;}
 
 #content { flex-grow: 1; background-color: #fff; margin: 0px; padding: 10px 16px 10px 16px; overflow-x: auto;}
index d62c9f2c1ef3bde79c1e1900ca60f2c1e90b82c0..1762c7efd81b97c9b2792a26b898dcf916971486 100644 (file)
@@ -2657,6 +2657,21 @@ class IssuesControllerTest < Redmine::ControllerTest
     end
   end
 
+  def test_show_should_mark_invalid_watchers
+    @request.session[:user_id] = 2
+    issue = Issue.find(4)
+    issue.add_watcher User.find(4)
+
+    get :show, :params => {:id => issue.id}
+
+    assert_response :success
+    assert_select 'div#watchers ul' do
+      assert_select 'li.user-4' do
+        assert_select 'span.icon-warning[title=?]', l(:notice_invalid_watcher), text: l(:notice_invalid_watcher)
+      end
+    end
+  end
+
   def test_show_with_thumbnails_enabled_should_display_thumbnails
     skip unless convert_installed?
     @request.session[:user_id] = 2