From 091dd36accf8cb26b66a1307bd0899b3ca1e3c33 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Sun, 24 Jan 2021 05:38:22 +0000 Subject: [PATCH] Show a warning message for watchers who cannot view the object (#33329). Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@20725 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- 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 ce39d7fb3..b3b9dc772 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -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', diff --git a/config/locales/en.yml b/config/locales/en.yml index 142afa001..00f246f33 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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." diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 627e0bd58..da96a7d8d 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: 10px 16px 10px 16px; overflow-x: auto;} diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index d62c9f2c1..1762c7efd 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -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 -- 2.39.5