Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-01-19 09:10:50 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-01-19 09:10:50 +0300
commitb8f44765693d6f6e4c8df6ab7b7c7b1141f83b26 (patch)
tree85d95eb57e7ee5a230d63e5e7f00e1c9c55ebcd4
parentbd1944e6cc35261fac30affee839dfc6de0e1667 (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--app/views/shared/wikis/show.html.haml2
-rw-r--r--changelogs/unreleased/288325-wiki-avatar.yml5
-rw-r--r--lib/gitlab/git/wiki_page_version.rb7
-rw-r--r--locale/gitlab.pot2
-rw-r--r--spec/lib/gitlab/git/wiki_page_version_spec.rb28
5 files changed, 41 insertions, 3 deletions
diff --git a/app/views/shared/wikis/show.html.haml b/app/views/shared/wikis/show.html.haml
index 6f1c1a3a801..6d14ba8fe7b 100644
--- a/app/views/shared/wikis/show.html.haml
+++ b/app/views/shared/wikis/show.html.haml
@@ -7,7 +7,7 @@
.nav-text.flex-fill
%span.wiki-last-edit-by
- if @page.last_version
- = (_("Last edited by %{name}") % { name: "<strong>#{@page.last_version.author_name}</strong>" }).html_safe
+ = html_escape(_("Last edited by %{link_start}%{avatar} %{name}%{link_end}")) % { avatar: image_tag(avatar_icon_for_email(@page.last_version.author_email, 24), class: "avatar s24 float-none gl-mr-0!"), name: "<strong>#{@page.last_version.author_name}</strong>".html_safe, link_start: "<a href='#{@page.last_version.author_url}'>".html_safe, link_end: '</a>'.html_safe }
= time_ago_with_tooltip(@page.last_version.authored_date)
.nav-controls.pb-md-3.pb-lg-0
diff --git a/changelogs/unreleased/288325-wiki-avatar.yml b/changelogs/unreleased/288325-wiki-avatar.yml
new file mode 100644
index 00000000000..02cf02c23d9
--- /dev/null
+++ b/changelogs/unreleased/288325-wiki-avatar.yml
@@ -0,0 +1,5 @@
+---
+title: 'Wiki: Add author avatar and link'
+merge_request: 51273
+author:
+type: changed
diff --git a/lib/gitlab/git/wiki_page_version.rb b/lib/gitlab/git/wiki_page_version.rb
index 475a9d4d1b9..efe39fa852c 100644
--- a/lib/gitlab/git/wiki_page_version.rb
+++ b/lib/gitlab/git/wiki_page_version.rb
@@ -10,7 +10,12 @@ module Gitlab
@format = format
end
- delegate :message, :sha, :id, :author_name, :authored_date, to: :commit
+ delegate :message, :sha, :id, :author_name, :author_email, :authored_date, to: :commit
+
+ def author_url
+ user = ::User.find_by_any_email(author_email)
+ user.nil? ? "mailto:#{author_email}" : Gitlab::UrlBuilder.build(user)
+ end
end
end
end
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 74f1f257b20..d44faab8136 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -16498,7 +16498,7 @@ msgstr ""
msgid "Last edited %{date}"
msgstr ""
-msgid "Last edited by %{name}"
+msgid "Last edited by %{link_start}%{avatar} %{name}%{link_end}"
msgstr ""
msgid "Last item before this page loaded in your browser:"
diff --git a/spec/lib/gitlab/git/wiki_page_version_spec.rb b/spec/lib/gitlab/git/wiki_page_version_spec.rb
new file mode 100644
index 00000000000..836fa2449ec
--- /dev/null
+++ b/spec/lib/gitlab/git/wiki_page_version_spec.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::Git::WikiPageVersion do
+ let_it_be(:project) { create(:project, :public, :repository) }
+ let(:user) { create(:user, username: 'someone') }
+
+ describe '#author_url' do
+ subject(:author_url) { described_class.new(commit, nil).author_url }
+
+ context 'user exists in gitlab' do
+ let(:commit) { create(:commit, project: project, author: user) }
+
+ it 'returns the profile link of the user' do
+ expect(author_url).to eq('http://localhost/someone')
+ end
+ end
+
+ context 'user does not exist in gitlab' do
+ let(:commit) { create(:commit, project: project, author_email: "someone@somewebsite.com") }
+
+ it 'returns a mailto: url' do
+ expect(author_url).to eq('mailto:someone@somewebsite.com')
+ end
+ end
+ end
+end