From 471ac6a2bd7b20eb0c8e48e0889fbc9498669a19 Mon Sep 17 00:00:00 2001 From: Marius BALTEANU Date: Sun, 19 Apr 2020 00:45:39 +0300 Subject: [PATCH 3/3] Show an warning message for watchers who cannot view the object. --- app/helpers/watchers_helper.rb | 3 +++ config/locales/en.yml | 1 + public/stylesheets/application.css | 1 + test/functional/issues_controller_test.rb | 15 +++++++++++++++ 4 files changed, 20 insertions(+) diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 00b6db2ff..f90273d7f 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -51,6 +51,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', diff --git a/config/locales/en.yml b/config/locales/en.yml index efaea5252..3659165be 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -194,6 +194,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." diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index a7512bd48..69c33f0a4 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -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: 6px 10px 10px 10px; overflow-x: auto;} diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 6853abf1f..d4f430ba0 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -2557,6 +2557,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 -- 2.22.0