Fix/group mention links (#9036)

* turn group mentioning into link

* add profile button to group edit page

* Include built ckeditor

Co-authored-by: Oliver Günther <mail@oliverguenther.de>
pull/9041/head
ulferts 4 years ago committed by GitHub
parent 4980b4fb4a
commit 9edf745085
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/views/groups/edit.html.erb
  2. 4
      frontend/src/vendor/ckeditor/ckeditor.js
  3. 2
      frontend/src/vendor/ckeditor/ckeditor.js.map
  4. 30
      lib/open_project/object_linking.rb
  5. 7
      lib/open_project/text_formatting/filters/mention_filter.rb
  6. 11
      lib/open_project/text_formatting/matchers/link_handlers/hash_separator.rb
  7. 2
      spec/features/wysiwyg/user_mention_spec.rb
  8. 14
      spec/lib/open_project/text_formatting/markdown/mentions_spec.rb

@ -32,6 +32,12 @@ See docs/COPYRIGHT.rdoc for more details.
<% local_assigns[:additional_breadcrumb] = @group.name %>
<%= breadcrumb_toolbar @group.name do %>
<li class="toolbar-item">
<%= link_to show_group_path(@group), class: 'button' do %>
<%= op_icon('button--icon icon-user') %>
<span class="button--text"><%= t(:label_profile) %></span>
<% end %>
</li>
<% if current_user.admin? %>
<li class="toolbar-item">
<%= link_to @group,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -43,24 +43,32 @@ module OpenProject
# Displays a link to user's account page if active or registered
def link_to_user(user, options = {})
if user.is_a?(User)
if user.is_a?(User) && user.locked?
user.name
elsif user.is_a?(User)
name = user.name
only_path = options.delete(:only_path)
only_path = true if only_path.nil?
href = user_url(user,
only_path: options.delete(:only_path) { true })
options[:title] ||= I18n.t(:label_user_named, name: name)
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
name
end
link_to(name, href, options)
else
h(user.to_s)
end
end
# Displays a link to groups's account page
def link_to_group(group, options = {})
return h(group.to_s) unless group.is_a?(Group)
name = group.name
href = show_group_url(group,
only_path: options.delete(:only_path) { true })
options[:title] ||= I18n.t(:label_group_named, name: name)
link_to(name, href, options)
end
# Generates a link to an attachment.
# Options:
# * :text - Link text (default to attachment filename)

@ -69,10 +69,9 @@ module OpenProject::TextFormatting
end
def group_mention(group)
content_tag :span,
group.name,
title: I18n.t(:label_group_named, name: group.name),
class: 'user-mention'
link_to_group(group,
only_path: context[:only_path],
class: 'user-mention')
end
def work_package_mention(work_package)

@ -107,7 +107,9 @@ module OpenProject::TextFormatting::Matchers
def render_user
user = User.find_by(id: oid)
if user
link_to_user(user, only_path: context[:only_path], class: 'user-mention')
link_to_user(user,
only_path: context[:only_path],
class: 'user-mention')
end
end
@ -115,10 +117,9 @@ module OpenProject::TextFormatting::Matchers
group = Group.find_by(id: oid)
if group
content_tag :span,
group.name,
title: I18n.t(:label_group_named, name: group.name),
class: 'user-mention'
link_to_group(group,
only_path: context[:only_path],
class: 'user-mention')
end
end
end

@ -105,7 +105,7 @@ describe 'Wysiwyg work package user mentions',
wp_page.expect_and_dismiss_notification message: "The comment was successfully added."
expect(page)
.to have_selector('span.user-mention', text: 'Foogroup')
.to have_selector('a.user-mention', text: 'Foogroup')
end
# The mention is still displayed as such when reentering the comment field

@ -348,7 +348,12 @@ describe OpenProject::TextFormatting,
let(:expected) do
<<~EXPECTED
<p class="op-uc-p">
Link to <span title="Group #{linked_project_member_group.name}" class="user-mention">#{linked_project_member_group.name}</span>
Link to
<a class="user-mention op-uc-link"
href="/groups/#{linked_project_member_group.id}"
title="Group #{linked_project_member_group.name}">
#{linked_project_member_group.name}
</a>
</p>
EXPECTED
end
@ -389,10 +394,11 @@ describe OpenProject::TextFormatting,
let(:expected) do
<<~EXPECTED
<p class="op-uc-p">
<span class='user-mention'
title='Group #{linked_project_member_group.name}'>
<a class="user-mention op-uc-link"
href="/groups/#{linked_project_member_group.id}"
title="Group #{linked_project_member_group.name}">
#{linked_project_member_group.name}
</span>
</a>
</p>
EXPECTED
end

Loading…
Cancel
Save