Commit c8e78181 authored by Piotr Stankowski's avatar Piotr Stankowski

Add link to squash template help

Show hint about commit templates
regardless of merge commit editor visibility.
Change hint message to mention squash template
when squash is performed.
parent b0aa21fb
...@@ -41,7 +41,6 @@ export default { ...@@ -41,7 +41,6 @@ export default {
rows="7" rows="7"
@input="$emit('input', $event.target.value)" @input="$emit('input', $event.target.value)"
></textarea> ></textarea>
<slot name="text-muted"></slot>
</div> </div>
</li> </li>
</template> </template>
...@@ -181,9 +181,16 @@ export default { ...@@ -181,9 +181,16 @@ export default {
return this.mr.canRemoveSourceBranch; return this.mr.canRemoveSourceBranch;
}, },
commitTemplateHelpPage() { commitTemplateHelpPage() {
return helpPagePath('user/project/merge_requests/commit_templates.md', { return helpPagePath('user/project/merge_requests/commit_templates.md');
anchor: 'merge-commit-message-template', },
}); commitTemplateHintText() {
if (this.shouldShowSquashEdit && this.shouldShowMergeEdit) {
return this.$options.i18n.mergeAndSquashCommitTemplatesHintText;
}
if (this.shouldShowSquashEdit) {
return this.$options.i18n.squashCommitTemplateHintText;
}
return this.$options.i18n.mergeCommitTemplateHintText;
}, },
commits() { commits() {
if (this.glFeatures.mergeRequestWidgetGraphql) { if (this.glFeatures.mergeRequestWidgetGraphql) {
...@@ -509,6 +516,12 @@ export default { ...@@ -509,6 +516,12 @@ export default {
mergeCommitTemplateHintText: s__( mergeCommitTemplateHintText: s__(
'mrWidget|To change this default message, edit the template for merge commit messages. %{linkStart}Learn more.%{linkEnd}', 'mrWidget|To change this default message, edit the template for merge commit messages. %{linkStart}Learn more.%{linkEnd}',
), ),
squashCommitTemplateHintText: s__(
'mrWidget|To change this default message, edit the template for squash commit messages. %{linkStart}Learn more.%{linkEnd}',
),
mergeAndSquashCommitTemplatesHintText: s__(
'mrWidget|To change these default messages, edit the templates for both the merge and squash commit messages. %{linkStart}Learn more.%{linkEnd}',
),
}, },
}; };
</script> </script>
...@@ -674,23 +687,22 @@ export default { ...@@ -674,23 +687,22 @@ export default {
:label="__('Merge commit message')" :label="__('Merge commit message')"
input-id="merge-message-edit" input-id="merge-message-edit"
class="gl-m-0! gl-p-0!" class="gl-m-0! gl-p-0!"
> />
<template #text-muted> <li class="gl-m-0! gl-p-0!">
<p class="form-text text-muted"> <p class="form-text text-muted">
<gl-sprintf :message="$options.i18n.mergeCommitTemplateHintText"> <gl-sprintf :message="commitTemplateHintText">
<template #link="{ content }"> <template #link="{ content }">
<gl-link <gl-link
:href="commitTemplateHelpPage" :href="commitTemplateHelpPage"
class="inline-link" class="inline-link"
target="_blank" target="_blank"
> >
{{ content }} {{ content }}
</gl-link> </gl-link>
</template> </template>
</gl-sprintf> </gl-sprintf>
</p> </p>
</template> </li>
</commit-edit>
</ul> </ul>
</div> </div>
<div <div
...@@ -792,19 +804,18 @@ export default { ...@@ -792,19 +804,18 @@ export default {
v-model="commitMessage" v-model="commitMessage"
:label="__('Merge commit message')" :label="__('Merge commit message')"
input-id="merge-message-edit" input-id="merge-message-edit"
> />
<template #text-muted> <li>
<p class="form-text text-muted"> <p class="form-text text-muted">
<gl-sprintf :message="$options.i18n.mergeCommitTemplateHintText"> <gl-sprintf :message="commitTemplateHintText">
<template #link="{ content }"> <template #link="{ content }">
<gl-link :href="commitTemplateHelpPage" class="inline-link" target="_blank"> <gl-link :href="commitTemplateHelpPage" class="inline-link" target="_blank">
{{ content }} {{ content }}
</gl-link> </gl-link>
</template> </template>
</gl-sprintf> </gl-sprintf>
</p> </p>
</template> </li>
</commit-edit>
</ul> </ul>
</commits-header> </commits-header>
</template> </template>
......
...@@ -41666,9 +41666,15 @@ msgstr "" ...@@ -41666,9 +41666,15 @@ msgstr ""
msgid "mrWidget|To approve this merge request, please enter your password. This project requires all approvals to be authenticated." msgid "mrWidget|To approve this merge request, please enter your password. This project requires all approvals to be authenticated."
msgstr "" msgstr ""
msgid "mrWidget|To change these default messages, edit the templates for both the merge and squash commit messages. %{linkStart}Learn more.%{linkEnd}"
msgstr ""
msgid "mrWidget|To change this default message, edit the template for merge commit messages. %{linkStart}Learn more.%{linkEnd}" msgid "mrWidget|To change this default message, edit the template for merge commit messages. %{linkStart}Learn more.%{linkEnd}"
msgstr "" msgstr ""
msgid "mrWidget|To change this default message, edit the template for squash commit messages. %{linkStart}Learn more.%{linkEnd}"
msgstr ""
msgid "mrWidget|To merge, a Jira issue key must be mentioned in the title or description." msgid "mrWidget|To merge, a Jira issue key must be mentioned in the title or description."
msgstr "" msgstr ""
......
...@@ -3,7 +3,6 @@ import CommitEdit from '~/vue_merge_request_widget/components/states/commit_edit ...@@ -3,7 +3,6 @@ import CommitEdit from '~/vue_merge_request_widget/components/states/commit_edit
const testCommitMessage = 'Test commit message'; const testCommitMessage = 'Test commit message';
const testLabel = 'Test label'; const testLabel = 'Test label';
const testTextMuted = 'Test text muted';
const testInputId = 'test-input-id'; const testInputId = 'test-input-id';
describe('Commits edit component', () => { describe('Commits edit component', () => {
...@@ -64,7 +63,6 @@ describe('Commits edit component', () => { ...@@ -64,7 +63,6 @@ describe('Commits edit component', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ createComponent({
header: `<div class="test-header">${testCommitMessage}</div>`, header: `<div class="test-header">${testCommitMessage}</div>`,
'text-muted': `<p class="test-text-muted">${testTextMuted}</p>`,
}); });
}); });
...@@ -74,12 +72,5 @@ describe('Commits edit component', () => { ...@@ -74,12 +72,5 @@ describe('Commits edit component', () => {
expect(headerSlotElement.exists()).toBe(true); expect(headerSlotElement.exists()).toBe(true);
expect(headerSlotElement.text()).toBe(testCommitMessage); expect(headerSlotElement.text()).toBe(testCommitMessage);
}); });
it('renders text-muted slot correctly', () => {
const textMutedElement = wrapper.find('.test-text-muted');
expect(textMutedElement.exists()).toBe(true);
expect(textMutedElement.text()).toBe(testTextMuted);
});
}); });
}); });
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue from 'vue';
import { GlSprintf } from '@gitlab/ui';
import simplePoll from '~/lib/utils/simple_poll'; import simplePoll from '~/lib/utils/simple_poll';
import CommitEdit from '~/vue_merge_request_widget/components/states/commit_edit.vue'; import CommitEdit from '~/vue_merge_request_widget/components/states/commit_edit.vue';
import CommitMessageDropdown from '~/vue_merge_request_widget/components/states/commit_message_dropdown.vue'; import CommitMessageDropdown from '~/vue_merge_request_widget/components/states/commit_message_dropdown.vue';
...@@ -487,6 +488,7 @@ describe('ReadyToMerge', () => { ...@@ -487,6 +488,7 @@ describe('ReadyToMerge', () => {
const findCommitEditElements = () => wrapper.findAll(CommitEdit); const findCommitEditElements = () => wrapper.findAll(CommitEdit);
const findCommitDropdownElement = () => wrapper.find(CommitMessageDropdown); const findCommitDropdownElement = () => wrapper.find(CommitMessageDropdown);
const findFirstCommitEditLabel = () => findCommitEditElements().at(0).props('label'); const findFirstCommitEditLabel = () => findCommitEditElements().at(0).props('label');
const findTipLink = () => wrapper.find(GlSprintf);
describe('squash checkbox', () => { describe('squash checkbox', () => {
it('should be rendered when squash before merge is enabled and there is more than 1 commit', () => { it('should be rendered when squash before merge is enabled and there is more than 1 commit', () => {
...@@ -751,6 +753,12 @@ describe('ReadyToMerge', () => { ...@@ -751,6 +753,12 @@ describe('ReadyToMerge', () => {
expect(findCommitDropdownElement().exists()).toBeTruthy(); expect(findCommitDropdownElement().exists()).toBeTruthy();
}); });
}); });
it('renders a tip including a link to docs on templates', () => {
createComponent();
expect(findTipLink().exists()).toBe(true);
});
}); });
describe('Merge request project settings', () => { describe('Merge request project settings', () => {
......
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