From 14888a398c71565bf8c595ed125e52ca8fb0c5f9 Mon Sep 17 00:00:00 2001 From: Fatih Acet Date: Fri, 12 Aug 2016 21:48:34 +0300 Subject: [PATCH] Disable commit button if commit message textarea empty. --- .../javascripts/merge_conflict_data_provider.js.es6 | 10 ++++++++-- .../merge_requests/conflicts/_submit_form.html.haml | 5 ++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/merge_conflict_data_provider.js.es6 b/app/assets/javascripts/merge_conflict_data_provider.js.es6 index 76088503323..10d8a8a8ea7 100644 --- a/app/assets/javascripts/merge_conflict_data_provider.js.es6 +++ b/app/assets/javascripts/merge_conflict_data_provider.js.es6 @@ -237,8 +237,14 @@ class MergeConflictDataProvider { } - isAllResolved() { - return !this.vueInstance.isSubmitting && this.getConflictsCount() === this.getResolvedCount(); + isReadyToCommit() { + const { conflictsData, isSubmitting } = this.vueInstance + const allResolved = this.getConflictsCount() === this.getResolvedCount(); + const hasCommitMessage = $.trim(conflictsData.commitMessage).length; + + return !isSubmitting && hasCommitMessage && allResolved; + } + getCommitButtonText() { const initial = 'Commit conflict resolution'; diff --git a/app/views/projects/merge_requests/conflicts/_submit_form.html.haml b/app/views/projects/merge_requests/conflicts/_submit_form.html.haml index 6a2b80069e8..78bd4133ea2 100644 --- a/app/views/projects/merge_requests/conflicts/_submit_form.html.haml +++ b/app/views/projects/merge_requests/conflicts/_submit_form.html.haml @@ -6,11 +6,10 @@ .commit-message-container.form-group .max-width-marker - %textarea.form-control.js-commit-message{":disabled" => "!allResolved", "v-model" => "conflictsData.commitMessage"} + %textarea.form-control.js-commit-message{"v-model" => "conflictsData.commitMessage"} {{{conflictsData.commitMessage}}} - %button{type: "button", class: "btn btn-success js-submit-button", ":disabled" => "!allResolved", "@click" => "commit()"} - %a.fa.fa-spin.fa-spinner{":class" => "{'hidden': !isSubmitting}"} + %button{type: "button", class: "btn btn-success js-submit-button", ":disabled" => "!readyToCommit", "@click" => "commit()"} %span {{commitButtonText}} = link_to "Cancel", namespace_project_merge_request_path(@merge_request.project.namespace, @merge_request.project, @merge_request), class: "btn btn-cancel"