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>
/* eslint-disable vue/no-v-html */
import { s__ } from '~/locale';
import { s__, n__ } from '~/locale';
export default {
name: 'MRWidgetRelatedLinks',
......@@ -24,7 +24,8 @@ export default {
if (this.state === 'closed') {
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 {
<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.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 v-if="relatedLinks.assignToMe"><span v-html="relatedLinks.assignToMe"></span></p>
</section>
......
......@@ -72,7 +72,13 @@ export default class MergeRequestStore {
const assignToMe = links.assign_to_closing;
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
end
def mentioned_issues_links
mentioned_issues = issues_mentioned_but_not_closing(current_user)
markdown(
issues_sentence(project, mentioned_issues),
pipeline: :gfm,
......@@ -239,6 +238,18 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
APPROVALS_WIDGET_BASE_TYPE
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
def cached_can_be_reverted?
......@@ -253,10 +264,6 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
# rubocop: enable CodeReuse/ServiceClass
end
def closing_issues
@closing_issues ||= visible_closing_issues_for(current_user)
end
def pipeline
@pipeline ||= actual_head_pipeline
end
......
......@@ -110,9 +110,17 @@ class MergeRequestWidgetEntity < Grape::Entity
presenter(merge_request).closing_issues_links
end
expose :closing_count do |merge_request|
presenter(merge_request).closing_issues.size
end
expose :mentioned_but_not_closing do |merge_request|
presenter(merge_request).mentioned_issues_links
end
expose :mentioned_count do |merge_request|
presenter(merge_request).mentioned_issues.size
end
end
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
let(:merge_request_description) { "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}" }
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
......@@ -39691,8 +39691,10 @@ msgstr ""
msgid "mrWidget|Closed by"
msgstr ""
msgid "mrWidget|Closes"
msgstr ""
msgid "mrWidget|Closes issue"
msgid_plural "mrWidget|Closes issues"
msgstr[0] ""
msgstr[1] ""
msgid "mrWidget|Delete source branch"
msgstr ""
......@@ -39727,8 +39729,10 @@ msgstr ""
msgid "mrWidget|Members who can merge are allowed to add commits."
msgstr ""
msgid "mrWidget|Mentions"
msgstr ""
msgid "mrWidget|Mentions issue"
msgid_plural "mrWidget|Mentions issues"
msgstr[0] ""
msgstr[1] ""
msgid "mrWidget|Merge"
msgstr ""
......
......@@ -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}" }
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
......@@ -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}" }
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
......@@ -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}" }
it 'does not display closing issue message' do
expect(page).to have_content("Closes #{issue_1.to_reference}")
expect(page).to have_content("Mentions #{issue_2.to_reference}")
expect(page).to have_content("Closes issue #{issue_1.to_reference}")
expect(page).to have_content("Mentions issue #{issue_2.to_reference}")
end
end
......@@ -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}" }
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
......@@ -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}" }
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
......@@ -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}" }
it 'does not display closing issue message' do
expect(page).to have_content("Closes #{issue_1.to_reference}")
expect(page).to have_content("Mentions #{issue_2.to_reference}")
expect(page).to have_content("Closes issue #{issue_1.to_reference}")
expect(page).to have_content("Mentions issue #{issue_2.to_reference}")
end
end
end
......@@ -17,7 +17,7 @@ describe('MRWidgetRelatedLinks', () => {
it('returns Closes text for open merge request', () => {
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', () => {
......@@ -38,6 +38,7 @@ describe('MRWidgetRelatedLinks', () => {
createComponent({
relatedLinks: {
closing: '<a href="#">#23</a> and <a>#42</a>',
closingCount: 2,
},
});
const content = wrapper
......@@ -45,7 +46,7 @@ describe('MRWidgetRelatedLinks', () => {
.replace(/\n(\s)+/g, ' ')
.trim();
expect(content).toContain('Closes #23 and #42');
expect(content).toContain('Closes issues #23 and #42');
expect(content).not.toContain('Mentions');
});
......@@ -53,11 +54,17 @@ describe('MRWidgetRelatedLinks', () => {
createComponent({
relatedLinks: {
mentioned: '<a href="#">#7</a>',
mentionedCount: 1,
},
});
expect(wrapper.text().trim()).toContain('Mentions #7');
expect(wrapper.text().trim()).not.toContain('Closes');
const content = wrapper
.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', () => {
......@@ -65,6 +72,8 @@ describe('MRWidgetRelatedLinks', () => {
relatedLinks: {
closing: '<a href="#">#7</a>',
mentioned: '<a href="#">#23</a> and <a>#42</a>',
closingCount: 1,
mentionedCount: 2,
},
});
const content = wrapper
......@@ -72,8 +81,8 @@ describe('MRWidgetRelatedLinks', () => {
.replace(/\n(\s)+/g, ' ')
.trim();
expect(content).toContain('Closes #7');
expect(content).toContain('Mentions #23 and #42');
expect(content).toContain('Closes issue #7');
expect(content).toContain('Mentions issues #23 and #42');
});
it('should have assing issues link', () => {
......
......@@ -58,7 +58,7 @@ RSpec.describe MergeRequestWidgetEntity do
data = described_class.new(resource, request: request, issues_links: true).as_json
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
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