Commit 56d8f2ce authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '293644-clarify-issue-hash-pound-sign' into 'master'

Add the word 'issues' to the mentions string

See merge request gitlab-org/gitlab!61068
parents b9ffe3a0 c179f4dd
<script> <script>
/* eslint-disable vue/no-v-html */ /* eslint-disable vue/no-v-html */
import { s__ } from '~/locale'; import { s__, n__ } from '~/locale';
export default { export default {
name: 'MRWidgetRelatedLinks', name: 'MRWidgetRelatedLinks',
...@@ -24,7 +24,8 @@ export default { ...@@ -24,7 +24,8 @@ export default {
if (this.state === 'closed') { if (this.state === 'closed') {
return s__('mrWidget|Did not close'); return s__('mrWidget|Did not close');
} }
return s__('mrWidget|Closes');
return n__('mrWidget|Closes issue', 'mrWidget|Closes issues', this.relatedLinks.closingCount);
}, },
}, },
}; };
...@@ -33,7 +34,8 @@ export default { ...@@ -33,7 +34,8 @@ export default {
<section class="mr-info-list gl-ml-7 gl-pb-5"> <section class="mr-info-list gl-ml-7 gl-pb-5">
<p v-if="relatedLinks.closing">{{ closesText }} <span v-html="relatedLinks.closing"></span></p> <p v-if="relatedLinks.closing">{{ closesText }} <span v-html="relatedLinks.closing"></span></p>
<p v-if="relatedLinks.mentioned"> <p v-if="relatedLinks.mentioned">
{{ s__('mrWidget|Mentions') }} <span v-html="relatedLinks.mentioned"></span> {{ n__('mrWidget|Mentions issue', 'mrWidget|Mentions issues', relatedLinks.mentionedCount) }}
<span v-html="relatedLinks.mentioned"></span>
</p> </p>
<p v-if="relatedLinks.assignToMe"><span v-html="relatedLinks.assignToMe"></span></p> <p v-if="relatedLinks.assignToMe"><span v-html="relatedLinks.assignToMe"></span></p>
</section> </section>
......
...@@ -72,7 +72,13 @@ export default class MergeRequestStore { ...@@ -72,7 +72,13 @@ export default class MergeRequestStore {
const assignToMe = links.assign_to_closing; const assignToMe = links.assign_to_closing;
if (closing || mentioned || assignToMe) { if (closing || mentioned || assignToMe) {
this.relatedLinks = { closing, mentioned, assignToMe }; this.relatedLinks = {
closing,
mentioned,
assignToMe,
closingCount: links.closing_count,
mentionedCount: links.mentioned_count,
};
} }
} }
......
...@@ -139,7 +139,6 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated ...@@ -139,7 +139,6 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
end end
def mentioned_issues_links def mentioned_issues_links
mentioned_issues = issues_mentioned_but_not_closing(current_user)
markdown( markdown(
issues_sentence(project, mentioned_issues), issues_sentence(project, mentioned_issues),
pipeline: :gfm, pipeline: :gfm,
...@@ -239,6 +238,18 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated ...@@ -239,6 +238,18 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
APPROVALS_WIDGET_BASE_TYPE APPROVALS_WIDGET_BASE_TYPE
end end
def closing_issues
strong_memoize(:closing_issues) do
visible_closing_issues_for(current_user)
end
end
def mentioned_issues
strong_memoize(:mentioned_issues) do
issues_mentioned_but_not_closing(current_user)
end
end
private private
def cached_can_be_reverted? def cached_can_be_reverted?
...@@ -253,10 +264,6 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated ...@@ -253,10 +264,6 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
# rubocop: enable CodeReuse/ServiceClass # rubocop: enable CodeReuse/ServiceClass
end end
def closing_issues
@closing_issues ||= visible_closing_issues_for(current_user)
end
def pipeline def pipeline
@pipeline ||= actual_head_pipeline @pipeline ||= actual_head_pipeline
end end
......
...@@ -110,9 +110,17 @@ class MergeRequestWidgetEntity < Grape::Entity ...@@ -110,9 +110,17 @@ class MergeRequestWidgetEntity < Grape::Entity
presenter(merge_request).closing_issues_links presenter(merge_request).closing_issues_links
end end
expose :closing_count do |merge_request|
presenter(merge_request).closing_issues.size
end
expose :mentioned_but_not_closing do |merge_request| expose :mentioned_but_not_closing do |merge_request|
presenter(merge_request).mentioned_issues_links presenter(merge_request).mentioned_issues_links
end end
expose :mentioned_count do |merge_request|
presenter(merge_request).mentioned_issues.size
end
end end
expose :codeclimate, if: -> (mr, _) { head_pipeline_downloadable_path_for_report_type(:codequality) } do expose :codeclimate, if: -> (mr, _) { head_pipeline_downloadable_path_for_report_type(:codequality) } do
......
...@@ -29,7 +29,7 @@ RSpec.describe 'Merge request > User sees closing issues message', :js do ...@@ -29,7 +29,7 @@ RSpec.describe 'Merge request > User sees closing issues message', :js do
let(:merge_request_description) { "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}" } let(:merge_request_description) { "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}" }
it 'displays closing issue message exactly one time' do it 'displays closing issue message exactly one time' do
expect(page).to have_content("Closes #{issue_1.to_reference} and #{issue_2.to_reference}", count: 1) expect(page).to have_content("Closes issues #{issue_1.to_reference} and #{issue_2.to_reference}", count: 1)
end end
end end
end end
...@@ -39691,8 +39691,10 @@ msgstr "" ...@@ -39691,8 +39691,10 @@ msgstr ""
msgid "mrWidget|Closed by" msgid "mrWidget|Closed by"
msgstr "" msgstr ""
msgid "mrWidget|Closes" msgid "mrWidget|Closes issue"
msgstr "" msgid_plural "mrWidget|Closes issues"
msgstr[0] ""
msgstr[1] ""
msgid "mrWidget|Delete source branch" msgid "mrWidget|Delete source branch"
msgstr "" msgstr ""
...@@ -39727,8 +39729,10 @@ msgstr "" ...@@ -39727,8 +39729,10 @@ msgstr ""
msgid "mrWidget|Members who can merge are allowed to add commits." msgid "mrWidget|Members who can merge are allowed to add commits."
msgstr "" msgstr ""
msgid "mrWidget|Mentions" msgid "mrWidget|Mentions issue"
msgstr "" msgid_plural "mrWidget|Mentions issues"
msgstr[0] ""
msgstr[1] ""
msgid "mrWidget|Merge" msgid "mrWidget|Merge"
msgstr "" msgstr ""
......
...@@ -31,7 +31,7 @@ RSpec.describe 'Merge request > User sees closing issues message', :js do ...@@ -31,7 +31,7 @@ RSpec.describe 'Merge request > User sees closing issues message', :js do
let(:merge_request_description) { "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}" } let(:merge_request_description) { "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}" }
it 'does not display closing issue message' do it 'does not display closing issue message' do
expect(page).to have_content("Closes #{issue_1.to_reference} and #{issue_2.to_reference}") expect(page).to have_content("Closes issues #{issue_1.to_reference} and #{issue_2.to_reference}")
end end
end end
...@@ -39,7 +39,7 @@ RSpec.describe 'Merge request > User sees closing issues message', :js do ...@@ -39,7 +39,7 @@ RSpec.describe 'Merge request > User sees closing issues message', :js do
let(:merge_request_description) { "Description\n\nRefers to #{issue_1.to_reference} and #{issue_2.to_reference}" } let(:merge_request_description) { "Description\n\nRefers to #{issue_1.to_reference} and #{issue_2.to_reference}" }
it 'does not display closing issue message' do it 'does not display closing issue message' do
expect(page).to have_content("Mentions #{issue_1.to_reference} and #{issue_2.to_reference}") expect(page).to have_content("Mentions issues #{issue_1.to_reference} and #{issue_2.to_reference}")
end end
end end
...@@ -47,8 +47,8 @@ RSpec.describe 'Merge request > User sees closing issues message', :js do ...@@ -47,8 +47,8 @@ RSpec.describe 'Merge request > User sees closing issues message', :js do
let(:merge_request_title) { "closes #{issue_1.to_reference}\n\n refers to #{issue_2.to_reference}" } let(:merge_request_title) { "closes #{issue_1.to_reference}\n\n refers to #{issue_2.to_reference}" }
it 'does not display closing issue message' do it 'does not display closing issue message' do
expect(page).to have_content("Closes #{issue_1.to_reference}") expect(page).to have_content("Closes issue #{issue_1.to_reference}")
expect(page).to have_content("Mentions #{issue_2.to_reference}") expect(page).to have_content("Mentions issue #{issue_2.to_reference}")
end end
end end
...@@ -56,7 +56,7 @@ RSpec.describe 'Merge request > User sees closing issues message', :js do ...@@ -56,7 +56,7 @@ RSpec.describe 'Merge request > User sees closing issues message', :js do
let(:merge_request_title) { "closing #{issue_1.to_reference}, #{issue_2.to_reference}" } let(:merge_request_title) { "closing #{issue_1.to_reference}, #{issue_2.to_reference}" }
it 'does not display closing issue message' do it 'does not display closing issue message' do
expect(page).to have_content("Closes #{issue_1.to_reference} and #{issue_2.to_reference}") expect(page).to have_content("Closes issues #{issue_1.to_reference} and #{issue_2.to_reference}")
end end
end end
...@@ -64,7 +64,7 @@ RSpec.describe 'Merge request > User sees closing issues message', :js do ...@@ -64,7 +64,7 @@ RSpec.describe 'Merge request > User sees closing issues message', :js do
let(:merge_request_title) { "Refers to #{issue_1.to_reference} and #{issue_2.to_reference}" } let(:merge_request_title) { "Refers to #{issue_1.to_reference} and #{issue_2.to_reference}" }
it 'does not display closing issue message' do it 'does not display closing issue message' do
expect(page).to have_content("Mentions #{issue_1.to_reference} and #{issue_2.to_reference}") expect(page).to have_content("Mentions issues #{issue_1.to_reference} and #{issue_2.to_reference}")
end end
end end
...@@ -72,8 +72,8 @@ RSpec.describe 'Merge request > User sees closing issues message', :js do ...@@ -72,8 +72,8 @@ RSpec.describe 'Merge request > User sees closing issues message', :js do
let(:merge_request_title) { "closes #{issue_1.to_reference}\n\n refers to #{issue_2.to_reference}" } let(:merge_request_title) { "closes #{issue_1.to_reference}\n\n refers to #{issue_2.to_reference}" }
it 'does not display closing issue message' do it 'does not display closing issue message' do
expect(page).to have_content("Closes #{issue_1.to_reference}") expect(page).to have_content("Closes issue #{issue_1.to_reference}")
expect(page).to have_content("Mentions #{issue_2.to_reference}") expect(page).to have_content("Mentions issue #{issue_2.to_reference}")
end end
end end
end end
...@@ -17,7 +17,7 @@ describe('MRWidgetRelatedLinks', () => { ...@@ -17,7 +17,7 @@ describe('MRWidgetRelatedLinks', () => {
it('returns Closes text for open merge request', () => { it('returns Closes text for open merge request', () => {
createComponent({ state: 'open', relatedLinks: {} }); createComponent({ state: 'open', relatedLinks: {} });
expect(wrapper.vm.closesText).toBe('Closes'); expect(wrapper.vm.closesText).toBe('Closes issues');
}); });
it('returns correct text for closed merge request', () => { it('returns correct text for closed merge request', () => {
...@@ -38,6 +38,7 @@ describe('MRWidgetRelatedLinks', () => { ...@@ -38,6 +38,7 @@ describe('MRWidgetRelatedLinks', () => {
createComponent({ createComponent({
relatedLinks: { relatedLinks: {
closing: '<a href="#">#23</a> and <a>#42</a>', closing: '<a href="#">#23</a> and <a>#42</a>',
closingCount: 2,
}, },
}); });
const content = wrapper const content = wrapper
...@@ -45,7 +46,7 @@ describe('MRWidgetRelatedLinks', () => { ...@@ -45,7 +46,7 @@ describe('MRWidgetRelatedLinks', () => {
.replace(/\n(\s)+/g, ' ') .replace(/\n(\s)+/g, ' ')
.trim(); .trim();
expect(content).toContain('Closes #23 and #42'); expect(content).toContain('Closes issues #23 and #42');
expect(content).not.toContain('Mentions'); expect(content).not.toContain('Mentions');
}); });
...@@ -53,11 +54,17 @@ describe('MRWidgetRelatedLinks', () => { ...@@ -53,11 +54,17 @@ describe('MRWidgetRelatedLinks', () => {
createComponent({ createComponent({
relatedLinks: { relatedLinks: {
mentioned: '<a href="#">#7</a>', mentioned: '<a href="#">#7</a>',
mentionedCount: 1,
}, },
}); });
expect(wrapper.text().trim()).toContain('Mentions #7'); const content = wrapper
expect(wrapper.text().trim()).not.toContain('Closes'); .text()
.replace(/\n(\s)+/g, ' ')
.trim();
expect(content).toContain('Mentions issue #7');
expect(content).not.toContain('Closes issues');
}); });
it('should have closing and mentioned issues at the same time', () => { it('should have closing and mentioned issues at the same time', () => {
...@@ -65,6 +72,8 @@ describe('MRWidgetRelatedLinks', () => { ...@@ -65,6 +72,8 @@ describe('MRWidgetRelatedLinks', () => {
relatedLinks: { relatedLinks: {
closing: '<a href="#">#7</a>', closing: '<a href="#">#7</a>',
mentioned: '<a href="#">#23</a> and <a>#42</a>', mentioned: '<a href="#">#23</a> and <a>#42</a>',
closingCount: 1,
mentionedCount: 2,
}, },
}); });
const content = wrapper const content = wrapper
...@@ -72,8 +81,8 @@ describe('MRWidgetRelatedLinks', () => { ...@@ -72,8 +81,8 @@ describe('MRWidgetRelatedLinks', () => {
.replace(/\n(\s)+/g, ' ') .replace(/\n(\s)+/g, ' ')
.trim(); .trim();
expect(content).toContain('Closes #7'); expect(content).toContain('Closes issue #7');
expect(content).toContain('Mentions #23 and #42'); expect(content).toContain('Mentions issues #23 and #42');
}); });
it('should have assing issues link', () => { it('should have assing issues link', () => {
......
...@@ -58,7 +58,7 @@ RSpec.describe MergeRequestWidgetEntity do ...@@ -58,7 +58,7 @@ RSpec.describe MergeRequestWidgetEntity do
data = described_class.new(resource, request: request, issues_links: true).as_json data = described_class.new(resource, request: request, issues_links: true).as_json
expect(data).to include(:issues_links) expect(data).to include(:issues_links)
expect(data[:issues_links]).to include(:assign_to_closing, :closing, :mentioned_but_not_closing) expect(data[:issues_links]).to include(:assign_to_closing, :closing, :mentioned_but_not_closing, :closing_count, :mentioned_count)
end end
it 'omits issue links by default' do it 'omits issue links by default' do
......
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