diff --git a/app/assets/stylesheets/content/_user_mention.sass b/app/assets/stylesheets/content/_user_mention.sass index 7f1b57948f..bde798630f 100644 --- a/app/assets/stylesheets/content/_user_mention.sass +++ b/app/assets/stylesheets/content/_user_mention.sass @@ -26,6 +26,16 @@ // See docs/COPYRIGHT.rdoc for more details. //++ -.user-mention:before - content: '@' - color: $gray-dark +.user-mention + @include varprop(color, content-link-color) + + &:hover + text-decoration: underline + + &:before + content: '@' + color: $gray-dark + +span.user-mention + // Remove text selection cursor for group + cursor: default diff --git a/config/locales/en.yml b/config/locales/en.yml index afe1cde0d3..d9193c1a37 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1257,6 +1257,7 @@ en: label_group_by: "Group by" label_group_new: "New group" label_group: "Group" + label_group_named: "Group %{name}" label_group_plural: "Groups" label_help: "Help" label_here: here @@ -1516,6 +1517,7 @@ en: label_used_by_types: "Used by types" label_used_in_projects: "Used in projects" label_user: "User" + label_user_named: "User %{name}" label_user_activity: "%{value}'s activity" label_user_anonymous: "Anonymous" label_user_mail_option_all: "For any event on all my projects" diff --git a/lib/open_project/object_linking.rb b/lib/open_project/object_linking.rb index 7d2e65f8f7..7efaa597b8 100644 --- a/lib/open_project/object_linking.rb +++ b/lib/open_project/object_linking.rb @@ -49,6 +49,7 @@ module OpenProject if user.active? || user.registered? || user.invited? href = only_path ? user_path(user) : user_url(user) + options[:title] ||= I18n.t(:label_user_named, name: name) link_to(name, href, options) else diff --git a/lib/open_project/text_formatting/matchers/link_handlers/hash_separator.rb b/lib/open_project/text_formatting/matchers/link_handlers/hash_separator.rb index e32932302e..27f0c35f8a 100644 --- a/lib/open_project/text_formatting/matchers/link_handlers/hash_separator.rb +++ b/lib/open_project/text_formatting/matchers/link_handlers/hash_separator.rb @@ -91,7 +91,10 @@ module OpenProject::TextFormatting::Matchers def render_group if group = Group.find_by(id: oid) - content_tag(:span, group.name, class: 'user-mention') + content_tag :span, + group.name, + title: I18n.t(:label_group_named, name: group.name), + class: 'user-mention' end end end diff --git a/spec/lib/open_project/text_formatting/markdown/markdown_formatting_spec.rb b/spec/lib/open_project/text_formatting/markdown/markdown_formatting_spec.rb index f990209cf7..5a1e667ed2 100644 --- a/spec/lib/open_project/text_formatting/markdown/markdown_formatting_spec.rb +++ b/spec/lib/open_project/text_formatting/markdown/markdown_formatting_spec.rb @@ -121,7 +121,7 @@ describe OpenProject::TextFormatting::Formats::Markdown::Formatter do context 'with path only' do it 'outputs the reference' do assert_html_output( - 'Link to user:"foo@bar.com"' => %(Link to Foo Barrit) + 'Link to user:"foo@bar.com"' => %(Link to Foo Barrit) ) end end @@ -131,7 +131,7 @@ describe OpenProject::TextFormatting::Formats::Markdown::Formatter do assert_html_output( { 'Link to user:"foo@bar.com"' => - %(Link to Foo Barrit) + %(Link to Foo Barrit) }, only_path: false ) diff --git a/spec/lib/open_project/text_formatting/markdown/markdown_spec.rb b/spec/lib/open_project/text_formatting/markdown/markdown_spec.rb index 677ae044e3..6a8f2e6f9a 100644 --- a/spec/lib/open_project/text_formatting/markdown/markdown_spec.rb +++ b/spec/lib/open_project/text_formatting/markdown/markdown_spec.rb @@ -321,7 +321,7 @@ describe OpenProject::TextFormatting, subject { format_text("user##{linked_project_member.id}") } it { - is_expected.to be_html_eql("
#{link_to(linked_project_member.name, { controller: :users, action: :show, id: linked_project_member.id }, class: 'user-mention')}
") + is_expected.to be_html_eql("#{link_to(linked_project_member.name, { controller: :users, action: :show, id: linked_project_member.id }, title: "User #{linked_project_member.name}", class: 'user-mention')}
") } end @@ -341,7 +341,7 @@ describe OpenProject::TextFormatting, context 'with a common login name' do subject { format_text("user:\"#{linked_project_member.login}\"") } - it { is_expected.to be_html_eql("#{link_to(linked_project_member.name, { controller: :users, action: :show, id: linked_project_member.id }, class: 'user-mention')}
") } + it { is_expected.to be_html_eql("#{link_to(linked_project_member.name, { controller: :users, action: :show, id: linked_project_member.id }, title: "User #{linked_project_member.name}", class: 'user-mention')}
") } end context "with an email address as login name" do @@ -353,7 +353,7 @@ describe OpenProject::TextFormatting, end subject { format_text("user:\"#{linked_project_member.login}\"") } - it { is_expected.to be_html_eql("#{link_to(linked_project_member.name, { controller: :users, action: :show, id: linked_project_member.id }, class: 'user-mention')}
") } + it { is_expected.to be_html_eql("#{link_to(linked_project_member.name, { controller: :users, action: :show, id: linked_project_member.id }, title: "User #{linked_project_member.name}", class: 'user-mention')}
") } end end @@ -388,7 +388,9 @@ describe OpenProject::TextFormatting, subject { format_text("group##{linked_project_member_group.id}") } it 'produces the expected html' do - is_expected.to be_html_eql("#{linked_project_member_group.name}
") + is_expected.to be_html_eql( + "#{linked_project_member_group.name}
" + ) end end