Commit 307e024c authored by Phil Hughes's avatar Phil Hughes

Fixed remove deploy key loading icon not being removed after canceling

Closes #37595
parent 28c983db
...@@ -32,7 +32,9 @@ ...@@ -32,7 +32,9 @@
doAction() { doAction() {
this.isLoading = true; this.isLoading = true;
eventHub.$emit(`${this.type}.key`, this.deployKey); eventHub.$emit(`${this.type}.key`, this.deployKey, () => {
this.isLoading = false;
});
}, },
}, },
computed: { computed: {
...@@ -50,6 +52,9 @@ ...@@ -50,6 +52,9 @@
:disabled="isLoading" :disabled="isLoading"
@click="doAction"> @click="doAction">
{{ text }} {{ text }}
<loading-icon v-if="isLoading" /> <loading-icon
v-if="isLoading"
:inline="true"
/>
</button> </button>
</template> </template>
...@@ -47,12 +47,15 @@ ...@@ -47,12 +47,15 @@
.then(() => this.fetchKeys()) .then(() => this.fetchKeys())
.catch(() => new Flash('Error enabling deploy key')); .catch(() => new Flash('Error enabling deploy key'));
}, },
disableKey(deployKey) { disableKey(deployKey, callback) {
// eslint-disable-next-line no-alert // eslint-disable-next-line no-alert
if (confirm('You are going to remove this deploy key. Are you sure?')) { if (confirm('You are going to remove this deploy key. Are you sure?')) {
this.service.disableKey(deployKey.id) this.service.disableKey(deployKey.id)
.then(() => this.fetchKeys()) .then(() => this.fetchKeys())
.then(callback)
.catch(() => new Flash('Error removing deploy key')); .catch(() => new Flash('Error removing deploy key'));
} else {
callback();
} }
}, },
}, },
......
---
title: Fixed deploy keys remove button loading state not resetting
merge_request:
author:
type: fixed
...@@ -34,7 +34,7 @@ describe('Deploy keys action btn', () => { ...@@ -34,7 +34,7 @@ describe('Deploy keys action btn', () => {
setTimeout(() => { setTimeout(() => {
expect( expect(
eventHub.$emit, eventHub.$emit,
).toHaveBeenCalledWith('enable.key', deployKey); ).toHaveBeenCalledWith('enable.key', deployKey, jasmine.anything());
done(); done();
}); });
......
...@@ -139,4 +139,18 @@ describe('Deploy keys app component', () => { ...@@ -139,4 +139,18 @@ describe('Deploy keys app component', () => {
it('hasKeys returns true when there are keys', () => { it('hasKeys returns true when there are keys', () => {
expect(vm.hasKeys).toEqual(3); expect(vm.hasKeys).toEqual(3);
}); });
it('resets remove button loading state', (done) => {
spyOn(window, 'confirm').and.returnValue(false);
const btn = vm.$el.querySelector('.btn-warning');
btn.click();
Vue.nextTick(() => {
expect(btn.querySelector('.fa')).toBeNull();
done();
});
});
}); });
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