Commit 45b6085d authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/296784/createMRButtonLoadingIcon' into 'master'

Added loading icon to create merge request button

See merge request gitlab-org/gitlab!57105
parents e10f7ccd dcc7e3ea
...@@ -35,6 +35,7 @@ export default class CreateMergeRequestDropdown { ...@@ -35,6 +35,7 @@ export default class CreateMergeRequestDropdown {
this.branchInput = this.wrapperEl.querySelector('.js-branch-name'); this.branchInput = this.wrapperEl.querySelector('.js-branch-name');
this.branchMessage = this.wrapperEl.querySelector('.js-branch-message'); this.branchMessage = this.wrapperEl.querySelector('.js-branch-message');
this.createMergeRequestButton = this.wrapperEl.querySelector('.js-create-merge-request'); 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.createTargetButton = this.wrapperEl.querySelector('.js-create-target');
this.dropdownList = this.wrapperEl.querySelector('.dropdown-menu'); this.dropdownList = this.wrapperEl.querySelector('.dropdown-menu');
this.dropdownToggle = this.wrapperEl.querySelector('.js-dropdown-toggle'); this.dropdownToggle = this.wrapperEl.querySelector('.js-dropdown-toggle');
...@@ -179,6 +180,10 @@ export default class CreateMergeRequestDropdown { ...@@ -179,6 +180,10 @@ export default class CreateMergeRequestDropdown {
this.disableCreateAction(); this.disableCreateAction();
} }
setLoading(loading) {
this.createMergeRequestLoading.classList.toggle('gl-display-none', !loading);
}
disableCreateAction() { disableCreateAction() {
this.createMergeRequestButton.classList.add('disabled'); this.createMergeRequestButton.classList.add('disabled');
this.createMergeRequestButton.setAttribute('disabled', 'disabled'); this.createMergeRequestButton.setAttribute('disabled', 'disabled');
...@@ -387,8 +392,10 @@ export default class CreateMergeRequestDropdown { ...@@ -387,8 +392,10 @@ export default class CreateMergeRequestDropdown {
this.isCreatingBranch = false; this.isCreatingBranch = false;
this.enable(); this.enable();
this.setLoading(false);
}); });
this.setLoading(true);
this.disable(); this.disable();
} }
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
Checking branch availability… Checking branch availability…
.btn-group.btn-group-sm.available.hidden .btn-group.btn-group-sm.available.hidden
%button.btn.js-create-merge-request.btn-success.btn-inverted{ type: 'button', data: { action: data_action } } %button.gl-button.btn.js-create-merge-request.btn-success.btn-inverted{ type: 'button', data: { action: data_action } }
.spinner.js-spinner.gl-mr-2.gl-display-none
= value = value
%button.btn.gl-button.create-merge-request-dropdown-toggle.dropdown-toggle.btn-success.btn-inverted.js-dropdown-toggle.gl-flex-grow-0.gl-h-7{ type: 'button', data: { dropdown: { trigger: '#create-merge-request-dropdown' }, display: 'static' } } %button.btn.gl-button.create-merge-request-dropdown-toggle.dropdown-toggle.btn-success.btn-inverted.js-dropdown-toggle.gl-flex-grow-0.gl-h-7{ type: 'button', data: { dropdown: { trigger: '#create-merge-request-dropdown' }, display: 'static' } }
......
---
title: Add loading icon to create merge request button
merge_request: 57105
author:
type: changed
...@@ -20,7 +20,9 @@ describe('CreateMergeRequestDropdown', () => { ...@@ -20,7 +20,9 @@ describe('CreateMergeRequestDropdown', () => {
</div> </div>
<div class="js-ref"></div> <div class="js-ref"></div>
<div class="js-create-mr"></div> <div class="js-create-mr"></div>
<div class="js-create-merge-request"></div> <div class="js-create-merge-request">
<span class="js-spinner"></span>
</div>
<div class="js-create-target"></div> <div class="js-create-target"></div>
<div class="js-dropdown-toggle"></div> <div class="js-dropdown-toggle"></div>
</div> </div>
...@@ -100,4 +102,18 @@ describe('CreateMergeRequestDropdown', () => { ...@@ -100,4 +102,18 @@ describe('CreateMergeRequestDropdown', () => {
expect(dropdown.createMergeRequestButton.classList).toContain('disabled'); expect(dropdown.createMergeRequestButton.classList).toContain('disabled');
}); });
}); });
describe('setLoading', () => {
it.each`
loading | hasClass
${true} | ${false}
${false} | ${true}
`('it toggle loading spinner when loading is $loading', ({ loading, hasClass }) => {
dropdown.setLoading(loading);
expect(document.querySelector('.js-spinner').classList.contains('gl-display-none')).toEqual(
hasClass,
);
});
});
}); });
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