Commit 6e427338 authored by Peter Hegman's avatar Peter Hegman Committed by Kushal Pandya

Add GitLab employee badge to issues/MRs/Epics

Added to Issue, MR, and Epic list view. Also added to Issue and MR
headers
parent 328060f0
......@@ -196,6 +196,8 @@ module IssuablesHelper
author_output = link_to_member(project, issuable.author, size: 24, mobile_classes: "d-none d-sm-inline")
author_output << link_to_member(project, issuable.author, size: 24, by_username: true, avatar: false, mobile_classes: "d-inline d-sm-none")
author_output << gitlab_team_member_badge(issuable.author, css_class: 'ml-1')
if status = user_status(issuable.author)
author_output << "#{status}".html_safe
end
......@@ -240,6 +242,27 @@ module IssuablesHelper
html.html_safe
end
def gitlab_team_member_badge(author, css_class: nil)
return unless author.gitlab_employee?
default_css_class = 'd-inline-block align-middle'
gitlab_team_member = _('GitLab Team Member')
content_tag(
:span,
class: css_class ? "#{default_css_class} #{css_class}" : default_css_class,
data: { toggle: 'tooltip', title: gitlab_team_member, container: 'body' },
role: 'img',
aria: { label: gitlab_team_member }
) do
sprite_icon(
'tanuki-verified',
size: 16,
css_class: 'gl-text-purple d-block'
)
end
end
def issuable_first_contribution_icon
content_tag(:span, class: 'fa-stack') do
concat(icon('certificate', class: "fa-stack-2x"))
......
......@@ -24,6 +24,7 @@
&middot;
opened #{time_ago_with_tooltip(issue.created_at, placement: 'bottom')}
by #{link_to_member(@project, issue.author, avatar: false)}
= gitlab_team_member_badge(issue.author)
- if issue.milestone
%span.issuable-milestone.d-none.d-sm-inline-block
&nbsp;
......
......@@ -20,6 +20,7 @@
&middot;
opened #{time_ago_with_tooltip(merge_request.created_at, placement: 'bottom')}
by #{link_to_member(@project, merge_request.author, avatar: false)}
= gitlab_team_member_badge(merge_request.author)
- if merge_request.milestone
%span.issuable-milestone.d-none.d-sm-inline-block
&nbsp;
......
......@@ -15,6 +15,7 @@
&middot;
opened #{time_ago_with_tooltip(epic.created_at, placement: 'bottom')}
by #{link_to_member(@group, epic.author, avatar: false)}
= gitlab_team_member_badge(epic.author)
- if epic.start_date? || epic.end_date?
&nbsp;
%span.issuable-dates.d-inline-flex.align-items-center.align-top
......
......@@ -9677,6 +9677,9 @@ msgstr ""
msgid "GitLab Support Bot"
msgstr ""
msgid "GitLab Team Member"
msgstr ""
msgid "GitLab User"
msgstr ""
......
......@@ -303,4 +303,46 @@ describe IssuablesHelper do
end
end
end
describe '#gitlab_team_member_badge' do
let(:issue) { build(:issue, author: user) }
before do
allow(Gitlab).to receive(:com?).and_return(true)
end
context 'when `:gitlab_employee_badge` feature flag is disabled' do
let(:user) { build(:user, email: 'test@gitlab.com') }
before do
stub_feature_flags(gitlab_employee_badge: false)
end
it 'returns nil' do
expect(helper.gitlab_team_member_badge(issue.author)).to be_nil
end
end
context 'when issue author is not a GitLab team member' do
let(:user) { build(:user, email: 'test@example.com') }
it 'returns nil' do
expect(helper.gitlab_team_member_badge(issue.author)).to be_nil
end
end
context 'when issue author is a GitLab team member' do
let(:user) { build(:user, email: 'test@gitlab.com') }
it 'returns span with svg icon' do
expect(helper.gitlab_team_member_badge(issue.author)).to have_selector('span > svg')
end
context 'when `css_class` parameter is passed' do
it 'adds CSS classes' do
expect(helper.gitlab_team_member_badge(issue.author, css_class: 'foo bar baz')).to have_selector('span.foo.bar.baz')
end
end
end
end
end
......@@ -13,7 +13,7 @@ describe 'projects/issues/show' do
assign(:noteable, issue)
stub_template 'shared/issuable/_sidebar' => ''
stub_template 'projects/issues/_discussion' => ''
allow(view).to receive(:issuable_meta).and_return('')
allow(view).to receive(:user_status).and_return('')
end
context 'when the issue is closed' do
......@@ -152,4 +152,18 @@ describe 'projects/issues/show' do
expect(rendered).not_to have_selector('#js-sentry-error-stack-trace')
end
end
context 'when issue is created by a GitLab team member' do
let(:user) { create(:user, email: 'test@gitlab.com') }
before do
allow(Gitlab).to receive(:com?).and_return(true)
end
it 'renders an employee badge next to their name' do
render
expect(rendered).to have_selector('[aria-label="GitLab Team Member"]')
end
end
end
......@@ -93,6 +93,20 @@ describe 'projects/merge_requests/show.html.haml' do
end
end
context 'when merge request is created by a GitLab team member' do
let(:user) { create(:user, email: 'test@gitlab.com') }
before do
allow(Gitlab).to receive(:com?).and_return(true)
end
it 'renders an employee badge next to their name' do
render
expect(rendered).to have_selector('[aria-label="GitLab Team Member"]')
end
end
def serialize_issuable_sidebar(user, project, merge_request)
MergeRequestSerializer
.new(current_user: user, project: project)
......
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