[28481] Make group mention appearance more in line with user-mention

https://community.openproject.com/wp/28481
pull/6662/head
Oliver Günther 6 years ago
parent d7b947cde0
commit b218058999
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 12
      app/assets/stylesheets/content/_user_mention.sass
  2. 2
      config/locales/en.yml
  3. 1
      lib/open_project/object_linking.rb
  4. 5
      lib/open_project/text_formatting/matchers/link_handlers/hash_separator.rb
  5. 4
      spec/lib/open_project/text_formatting/markdown/markdown_formatting_spec.rb
  6. 10
      spec/lib/open_project/text_formatting/markdown/markdown_spec.rb

@ -26,6 +26,16 @@
// See docs/COPYRIGHT.rdoc for more details.
//++
.user-mention:before
.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

@ -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"

@ -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

@ -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

@ -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 <a class="user-mention" href="/users/#{user.id}">Foo Barrit</a>)
'Link to user:"foo@bar.com"' => %(Link to <a class="user-mention" href="/users/#{user.id}" title="User Foo Barrit">Foo Barrit</a>)
)
end
end
@ -131,7 +131,7 @@ describe OpenProject::TextFormatting::Formats::Markdown::Formatter do
assert_html_output(
{
'Link to user:"foo@bar.com"' =>
%(Link to <a class="user-mention" href="http://openproject.org/users/#{user.id}">Foo Barrit</a>)
%(Link to <a class="user-mention" href="http://openproject.org/users/#{user.id}" title="User Foo Barrit">Foo Barrit</a>)
},
only_path: false
)

@ -321,7 +321,7 @@ describe OpenProject::TextFormatting,
subject { format_text("user##{linked_project_member.id}") }
it {
is_expected.to be_html_eql("<p>#{link_to(linked_project_member.name, { controller: :users, action: :show, id: linked_project_member.id }, class: 'user-mention')}</p>")
is_expected.to be_html_eql("<p>#{link_to(linked_project_member.name, { controller: :users, action: :show, id: linked_project_member.id }, title: "User #{linked_project_member.name}", class: 'user-mention')}</p>")
}
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("<p>#{link_to(linked_project_member.name, { controller: :users, action: :show, id: linked_project_member.id }, class: 'user-mention')}</p>") }
it { is_expected.to be_html_eql("<p>#{link_to(linked_project_member.name, { controller: :users, action: :show, id: linked_project_member.id }, title: "User #{linked_project_member.name}", class: 'user-mention')}</p>") }
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("<p>#{link_to(linked_project_member.name, { controller: :users, action: :show, id: linked_project_member.id }, class: 'user-mention')}</p>") }
it { is_expected.to be_html_eql("<p>#{link_to(linked_project_member.name, { controller: :users, action: :show, id: linked_project_member.id }, title: "User #{linked_project_member.name}", class: 'user-mention')}</p>") }
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("<p><span class='user-mention'>#{linked_project_member_group.name}</span></p>")
is_expected.to be_html_eql(
"<p><span class='user-mention' title='Group #{linked_project_member_group.name}'>#{linked_project_member_group.name}</span></p>"
)
end
end

Loading…
Cancel
Save