Project

General

Profile

Actions

Defect #38458

closed

Display order of watchers in the sidebar is indeterminate

Added by Go MAEDA over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Issues
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

In the watcher section of an issue's sidebar, the order of watchers is not explicitly specified and is environment-dependent (see watcher_users below).

I would suggest improving `watcher_users` to ensure that watchers are displayed in the order they are added.

lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb:

      module ClassMethods
        def acts_as_watchable(options = {})
          return if self.included_modules.include?(Redmine::Acts::Watchable::InstanceMethods)
          class_eval do
            has_many :watchers, :as => :watchable, :dependent => :delete_all
            has_many :watcher_users, :through => :watchers, :source => :user, :validate => false


Files

test-for-38458-note-2.patch (2.33 KB) test-for-38458-note-2.patch Go MAEDA, 2023-05-01 08:51

Related issues

Has duplicate Redmine - Feature #19484: Users orderingClosed

Actions
Actions #1

Updated by Go MAEDA over 1 year ago

  • Description updated (diff)
Actions #2

Updated by Holger Just over 1 year ago

How about ordering it alphabetically (or more specifically: sorted according to the chosen name formatting)? That way, long watcher lists would be easy to scan, we would not leak possible meta data about watchers, and the patch is small :)

This change could probably be implemented by this patch only:

diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb
index dfd3d5c490..d8a1e07759 100644
--- a/app/helpers/watchers_helper.rb
+++ b/app/helpers/watchers_helper.rb
@@ -48,7 +48,7 @@ def watcher_css(objects)
   def watchers_list(object)
     remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project)
     content = ''.html_safe
-    lis = object.watcher_users.collect do |user|
+    lis = object.watcher_users.sorted.collect do |user|
       s = ''.html_safe
       s << avatar(user, :size => "16").to_s
       s << link_to_principal(user, class: user.class.to_s.downcase)
Actions #3

Updated by Go MAEDA over 1 year ago

I agree with your idea of sorting watchers by their names.

The reason I suggested displaying watchers in the order they were added is that watchers are currently often displayed in this order.

But now I think sorting watchers by their name is better than the order they are added. It is intuitive and the order of addition is not so important in ordinary situations.

Actions #4

Updated by Go MAEDA over 1 year ago

  • File test-for-38458-note-2.patch added
  • Subject changed from Undefined display order of watchers in the sidebar to Display order of watchers in the sidebar is indeterminate
  • Target version set to 5.1.0

Setting the target version to 5.1.0.

Actions #5

Updated by Go MAEDA over 1 year ago

  • File deleted (test-for-38458-note-2.patch)
Actions #7

Updated by Go MAEDA over 1 year ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch in r22225.

Actions #8

Updated by Holger Just 9 months ago

Actions

Also available in: Atom PDF