Feature #36699

Change the text of the user link when converting @user notation to html

Added by Mizuki ISHIKAWA 10 months ago. Updated 8 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Marius BALTEANU% Done:

0%

Category:Text formatting
Target version:-
Resolution:Fixed

Description

#13919 added the Mention feature to Redmine.
There are three types of notations that can be converted to user links: @user, user#1, and user:user. With this change, only @user will have the Mention feature.

Currently, when you convert @jsmith to HTML, you get the link "John Smith".
I propose to change this to the following:
  • Plan 1. @John Smith
  • Plan 2. @jsmith(John Smith)
  • Plan 3. @jsmith
Reason for change:
  • The functions are different from those of other user#1 and user:user notations and should be separated.
  • I think it's important to have @ in front of the name so that people who don't know much about Redmine realize that they can use the Mention feature.

Concerns:
Since @jsmith has always been assumed to be converted to "John Smith", changing it may break the display of wiki pages and issues.

Please let me know what you think.

mention.png (48.5 KB) Marius BALTEANU, 2022-02-24 23:01

0001-Render-mentioned-users-with-leading-36699-13919.patch Magnifier (5.78 KB) Marius BALTEANU, 2022-03-18 22:31


Related issues

Related to Redmine - Feature #13919: Mention user on issues and wiki pages using @user with au... Closed

Associated revisions

Revision 21440
Added by Marius BALTEANU 10 months ago

Add class user-mention to user classes when user is linked using @ (#36699, #13919).

Revision 21468
Added by Marius BALTEANU 9 months ago

Render mentioned users with leading @ and highlight (#36699, #13919).

History

#1 Updated by Marius BALTEANU 10 months ago

  • Related to Feature #13919: Mention user on issues and wiki pages using @user with autocomplete added

#2 Updated by Marius BALTEANU 10 months ago

For now I've added the class user-mention to user links generated using @ (r21440).

The easiest way is to obtain "@John Smith" using two different approaches:

1. Only from CSS:

diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index f837a710e..57b3a9680 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -150,6 +150,9 @@ a img{ border: 0; }
 a.issue.closed, a.issue.closed:link, a.issue.closed:visited { color: #999; text-decoration: line-through; }
 a.project.closed, a.project.closed:link, a.project.closed:visited { color: #999; }
 a.user.locked, a.user.locked:link, a.user.locked:visited {color: #999;}
+a.user.user-mention:before {
+  content: "@";
+}

2. Rendered with @

diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 33f72e144..c91f7cbaa 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -60,6 +60,7 @@ module ApplicationHelper
     case principal
     when User
       name = h(principal.name(options[:format]))
+      name = "@" + name if options[:is_mention]
       css_classes = ''
       if principal.active? || (User.current.admin? && principal.logged?)
         url = user_url(principal, :only_path => only_path)
@@ -1265,7 +1266,7 @@ module ApplicationHelper
           elsif sep == "@" 
             name = remove_double_quotes(identifier)
             u = User.visible.find_by("LOWER(login) = :s AND type = 'User'", :s => name.downcase)
-            link = link_to_user(u, :only_path => only_path, :class => 'user-mention') if u
+            link = link_to_user(u, :only_path => only_path, :class => 'user-mention', :is_mention => true) if u
           end

Also, maybe we should highlight the users linked with @:

#3 Updated by Mizuki ISHIKAWA 10 months ago

Marius BALTEANU wrote:

For now I've added the class user-mention to user links generated using @ (r21440).

The easiest way is to obtain "@John Smith" using two different approaches:

1. Only from CSS:

[...]

2. Rendered with @

[...]

Also, maybe we should highlight the users linked with @:

Thank you for your commit.
I think it's a good improvement that doesn't affect the existing look and feel, and people who want to change it can do so using css.

#4 Updated by Marius BALTEANU 9 months ago

I think it's better to actually render the display name with @. Patch attached.

#5 Updated by Marius BALTEANU 9 months ago

  • Assignee set to Marius BALTEANU
  • Target version deleted (5.0.0)
  • Resolution set to Fixed

Change committed, thanks!

#6 Updated by Marius BALTEANU 8 months ago

  • Status changed from New to Closed

Also available in: Atom PDF