Commit 9d227686 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '288325-wiki-avatar' into 'master'

Wiki: Add author avatar and link

See merge request gitlab-org/gitlab!51273
parents e9b29be7 3e543192
......@@ -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
......
---
title: 'Wiki: Add author avatar and link'
merge_request: 51273
author:
type: changed
......@@ -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
......@@ -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:"
......
# 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment