diff options
Diffstat (limited to 'app/assets/javascripts/create_merge_request_dropdown.js')
-rw-r--r-- | app/assets/javascripts/create_merge_request_dropdown.js | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/app/assets/javascripts/create_merge_request_dropdown.js b/app/assets/javascripts/create_merge_request_dropdown.js index 35176c19f69..000faacb7d7 100644 --- a/app/assets/javascripts/create_merge_request_dropdown.js +++ b/app/assets/javascripts/create_merge_request_dropdown.js @@ -1,4 +1,3 @@ -/* eslint-disable no-new */ import { debounce } from 'lodash'; import { init as initConfidentialMergeRequest, @@ -8,7 +7,7 @@ import { import confidentialMergeRequestState from './confidential_merge_request/state'; import DropLab from './droplab/drop_lab'; import ISetter from './droplab/plugins/input_setter'; -import { deprecatedCreateFlash as Flash } from './flash'; +import createFlash from './flash'; import axios from './lib/utils/axios_utils'; import { __, sprintf } from './locale'; @@ -36,6 +35,7 @@ export default class CreateMergeRequestDropdown { this.branchInput = this.wrapperEl.querySelector('.js-branch-name'); this.branchMessage = this.wrapperEl.querySelector('.js-branch-message'); this.createMergeRequestButton = this.wrapperEl.querySelector('.js-create-merge-request'); + this.createMergeRequestLoading = this.createMergeRequestButton.querySelector('.js-spinner'); this.createTargetButton = this.wrapperEl.querySelector('.js-create-target'); this.dropdownList = this.wrapperEl.querySelector('.dropdown-menu'); this.dropdownToggle = this.wrapperEl.querySelector('.js-dropdown-toggle'); @@ -132,7 +132,9 @@ export default class CreateMergeRequestDropdown { .catch(() => { this.unavailable(); this.disable(); - Flash(__('Failed to check related branches.')); + createFlash({ + message: __('Failed to check related branches.'), + }); }); } @@ -147,7 +149,11 @@ export default class CreateMergeRequestDropdown { this.branchCreated = true; window.location.href = data.url; }) - .catch(() => Flash(__('Failed to create a branch for this issue. Please try again.'))); + .catch(() => + createFlash({ + message: __('Failed to create a branch for this issue. Please try again.'), + }), + ); } createMergeRequest() { @@ -163,13 +169,21 @@ export default class CreateMergeRequestDropdown { this.mergeRequestCreated = true; window.location.href = data.url; }) - .catch(() => Flash(__('Failed to create Merge Request. Please try again.'))); + .catch(() => + createFlash({ + message: __('Failed to create merge request. Please try again.'), + }), + ); } disable() { this.disableCreateAction(); } + setLoading(loading) { + this.createMergeRequestLoading.classList.toggle('gl-display-none', !loading); + } + disableCreateAction() { this.createMergeRequestButton.classList.add('disabled'); this.createMergeRequestButton.setAttribute('disabled', 'disabled'); @@ -256,7 +270,9 @@ export default class CreateMergeRequestDropdown { .catch(() => { this.unavailable(); this.disable(); - new Flash(__('Failed to get ref.')); + createFlash({ + message: __('Failed to get ref.'), + }); this.isGettingRef = false; @@ -376,8 +392,10 @@ export default class CreateMergeRequestDropdown { this.isCreatingBranch = false; this.enable(); + this.setLoading(false); }); + this.setLoading(true); this.disable(); } |