diff options
author | Phil Hughes <me@iamphill.com> | 2019-03-13 18:44:17 +0300 |
---|---|---|
committer | John T Skarbek <jtslear@gmail.com> | 2019-03-14 16:19:40 +0300 |
commit | e371b4ebc462e9dd24402bd0ee6f0e2e19b026a8 (patch) | |
tree | 24d4328aa5815abb9a1f9d3f3a24a4c0c111c0d8 /app | |
parent | 17426abf3196d4a298c9f789c07034b70903c08f (diff) |
Merge branch '48324-enable-squash-message-on-fast-forward' into 'master'
Allow modifying squash commit message for fast-forward only merge method
Closes #48324, #58805, and #58631
See merge request gitlab-org/gitlab-ce!26017
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/vue_merge_request_widget/components/states/commits_header.vue | 18 | ||||
-rw-r--r-- | app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue | 77 |
2 files changed, 56 insertions, 39 deletions
diff --git a/app/assets/javascripts/vue_merge_request_widget/components/states/commits_header.vue b/app/assets/javascripts/vue_merge_request_widget/components/states/commits_header.vue index 33963d5e1e6..0312b147b62 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/states/commits_header.vue +++ b/app/assets/javascripts/vue_merge_request_widget/components/states/commits_header.vue @@ -14,6 +14,10 @@ export default { type: Boolean, required: true, }, + isFastForwardEnabled: { + type: Boolean, + required: true, + }, commitsCount: { type: Number, required: false, @@ -37,16 +41,22 @@ export default { return n__(__('%d commit'), __('%d commits'), this.isSquashEnabled ? 1 : this.commitsCount); }, modifyLinkMessage() { - return this.isSquashEnabled ? __('Modify commit messages') : __('Modify merge commit'); + if (this.isFastForwardEnabled) return __('Modify commit message'); + else if (this.isSquashEnabled) return __('Modify commit messages'); + return __('Modify merge commit'); }, ariaLabel() { return this.expanded ? __('Collapse') : __('Expand'); }, message() { + const message = this.isFastForwardEnabled + ? s__('mrWidgetCommitsAdded|%{commitCount} will be added to %{targetBranch}.') + : s__( + 'mrWidgetCommitsAdded|%{commitCount} and %{mergeCommitCount} will be added to %{targetBranch}.', + ); + return sprintf( - s__( - 'mrWidgetCommitsAdded|%{commitCount} and %{mergeCommitCount} will be added to %{targetBranch}.', - ), + message, { commitCount: `<strong class="commits-count-message">${this.commitsCountMessage}</strong>`, mergeCommitCount: `<strong>${s__('mrWidgetCommitsAdded|1 merge commit')}</strong>`, diff --git a/app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue b/app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue index 9b4e80ee3a3..8e043ed50c9 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue +++ b/app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue @@ -113,6 +113,12 @@ export default { shouldShowMergeControls() { return this.mr.isMergeAllowed || this.shouldShowMergeWhenPipelineSucceedsText; }, + shouldShowSquashEdit() { + return this.squashBeforeMerge && this.shouldShowSquashBeforeMerge; + }, + shouldShowMergeEdit() { + return !this.mr.ffOnlyEnabled; + }, }, methods: { updateMergeCommitMessage(includeDescription) { @@ -321,43 +327,44 @@ export default { <div v-if="mr.ffOnlyEnabled" class="mr-fast-forward-message"> {{ __('Fast-forward merge without a merge commit') }} </div> - <template v-else> - <commits-header - :is-squash-enabled="squashBeforeMerge" - :commits-count="mr.commitsCount" - :target-branch="mr.targetBranch" - > - <ul class="border-top content-list commits-list flex-list"> - <commit-edit - v-if="squashBeforeMerge && shouldShowSquashBeforeMerge" + <commits-header + v-if="shouldShowSquashEdit || shouldShowMergeEdit" + :is-squash-enabled="squashBeforeMerge" + :commits-count="mr.commitsCount" + :target-branch="mr.targetBranch" + :is-fast-forward-enabled="mr.ffOnlyEnabled" + > + <ul class="border-top content-list commits-list flex-list"> + <commit-edit + v-if="shouldShowSquashEdit" + v-model="squashCommitMessage" + :label="__('Squash commit message')" + input-id="squash-message-edit" + squash + > + <commit-message-dropdown + slot="header" v-model="squashCommitMessage" - :label="__('Squash commit message')" - input-id="squash-message-edit" - squash - > - <commit-message-dropdown - slot="header" - v-model="squashCommitMessage" - :commits="mr.commits" + :commits="mr.commits" + /> + </commit-edit> + <commit-edit + v-if="shouldShowMergeEdit" + v-model="commitMessage" + :label="__('Merge commit message')" + input-id="merge-message-edit" + > + <label slot="checkbox"> + <input + id="include-description" + type="checkbox" + @change="updateMergeCommitMessage($event.target.checked)" /> - </commit-edit> - <commit-edit - v-model="commitMessage" - :label="__('Merge commit message')" - input-id="merge-message-edit" - > - <label slot="checkbox"> - <input - id="include-description" - type="checkbox" - @change="updateMergeCommitMessage($event.target.checked)" - /> - {{ __('Include merge request description') }} - </label> - </commit-edit> - </ul> - </commits-header> - </template> + {{ __('Include merge request description') }} + </label> + </commit-edit> + </ul> + </commits-header> </template> </div> </template> |