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 ...@@ -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, 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 << 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) if status = user_status(issuable.author)
author_output << "#{status}".html_safe author_output << "#{status}".html_safe
end end
...@@ -240,6 +242,27 @@ module IssuablesHelper ...@@ -240,6 +242,27 @@ module IssuablesHelper
html.html_safe html.html_safe
end 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 def issuable_first_contribution_icon
content_tag(:span, class: 'fa-stack') do content_tag(:span, class: 'fa-stack') do
concat(icon('certificate', class: "fa-stack-2x")) concat(icon('certificate', class: "fa-stack-2x"))
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
&middot; &middot;
opened #{time_ago_with_tooltip(issue.created_at, placement: 'bottom')} opened #{time_ago_with_tooltip(issue.created_at, placement: 'bottom')}
by #{link_to_member(@project, issue.author, avatar: false)} by #{link_to_member(@project, issue.author, avatar: false)}
= gitlab_team_member_badge(issue.author)
- if issue.milestone - if issue.milestone
%span.issuable-milestone.d-none.d-sm-inline-block %span.issuable-milestone.d-none.d-sm-inline-block
&nbsp; &nbsp;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
&middot; &middot;
opened #{time_ago_with_tooltip(merge_request.created_at, placement: 'bottom')} opened #{time_ago_with_tooltip(merge_request.created_at, placement: 'bottom')}
by #{link_to_member(@project, merge_request.author, avatar: false)} by #{link_to_member(@project, merge_request.author, avatar: false)}
= gitlab_team_member_badge(merge_request.author)
- if merge_request.milestone - if merge_request.milestone
%span.issuable-milestone.d-none.d-sm-inline-block %span.issuable-milestone.d-none.d-sm-inline-block
&nbsp; &nbsp;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
&middot; &middot;
opened #{time_ago_with_tooltip(epic.created_at, placement: 'bottom')} opened #{time_ago_with_tooltip(epic.created_at, placement: 'bottom')}
by #{link_to_member(@group, epic.author, avatar: false)} by #{link_to_member(@group, epic.author, avatar: false)}
= gitlab_team_member_badge(epic.author)
- if epic.start_date? || epic.end_date? - if epic.start_date? || epic.end_date?
&nbsp; &nbsp;
%span.issuable-dates.d-inline-flex.align-items-center.align-top %span.issuable-dates.d-inline-flex.align-items-center.align-top
......
...@@ -9677,6 +9677,9 @@ msgstr "" ...@@ -9677,6 +9677,9 @@ msgstr ""
msgid "GitLab Support Bot" msgid "GitLab Support Bot"
msgstr "" msgstr ""
msgid "GitLab Team Member"
msgstr ""
msgid "GitLab User" msgid "GitLab User"
msgstr "" msgstr ""
......
...@@ -303,4 +303,46 @@ describe IssuablesHelper do ...@@ -303,4 +303,46 @@ describe IssuablesHelper do
end end
end 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 end
...@@ -13,7 +13,7 @@ describe 'projects/issues/show' do ...@@ -13,7 +13,7 @@ describe 'projects/issues/show' do
assign(:noteable, issue) assign(:noteable, issue)
stub_template 'shared/issuable/_sidebar' => '' stub_template 'shared/issuable/_sidebar' => ''
stub_template 'projects/issues/_discussion' => '' stub_template 'projects/issues/_discussion' => ''
allow(view).to receive(:issuable_meta).and_return('') allow(view).to receive(:user_status).and_return('')
end end
context 'when the issue is closed' do context 'when the issue is closed' do
...@@ -152,4 +152,18 @@ describe 'projects/issues/show' do ...@@ -152,4 +152,18 @@ describe 'projects/issues/show' do
expect(rendered).not_to have_selector('#js-sentry-error-stack-trace') expect(rendered).not_to have_selector('#js-sentry-error-stack-trace')
end end
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 end
...@@ -93,6 +93,20 @@ describe 'projects/merge_requests/show.html.haml' do ...@@ -93,6 +93,20 @@ describe 'projects/merge_requests/show.html.haml' do
end end
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) def serialize_issuable_sidebar(user, project, merge_request)
MergeRequestSerializer MergeRequestSerializer
.new(current_user: user, project: project) .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