parent
625d344206
commit
3ce6658d8d
|
@ -121,6 +121,14 @@ export default {
|
|||
this.showForm = false;
|
||||
},
|
||||
updateIssuable() {
|
||||
const canPostUpdate = this.store.formState.move_to_project_id !== 0 ?
|
||||
confirm('Are you sure you want to move this issue to another project?') : true; // eslint-disable-line no-alert
|
||||
|
||||
if (!canPostUpdate) {
|
||||
eventHub.$emit('enable.submit.btn');
|
||||
return;
|
||||
}
|
||||
|
||||
this.service.updateIssuable(this.store.formState)
|
||||
.then(res => res.json())
|
||||
.then((data) => {
|
||||
|
@ -149,7 +157,7 @@ export default {
|
|||
// Stop the poll so we don't get 404's with the issue not existing
|
||||
this.poll.stop();
|
||||
|
||||
gl.utils.visitUrl(data.path);
|
||||
gl.utils.visitUrl(data.web_url);
|
||||
})
|
||||
.catch(() => {
|
||||
eventHub.$emit('close.form');
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
},
|
||||
},
|
||||
methods: {
|
||||
enableSubmit() {
|
||||
this.updateLoading = false;
|
||||
},
|
||||
updateIssuable() {
|
||||
this.updateLoading = true;
|
||||
eventHub.$emit('update.issuable');
|
||||
|
@ -40,6 +43,12 @@
|
|||
}
|
||||
},
|
||||
},
|
||||
created() {
|
||||
eventHub.$on('enable.submit.btn', this.enableSubmit);
|
||||
},
|
||||
beforeDestroy() {
|
||||
eventHub.$off('enable.submit.btn', this.enableSubmit);
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -50,7 +59,7 @@
|
|||
:class="{ disabled: updateLoading || !isSubmitEnabled }"
|
||||
type="submit"
|
||||
:disabled="updateLoading || !isSubmitEnabled"
|
||||
@click="updateIssuable">
|
||||
@click.prevent="updateIssuable">
|
||||
Save changes
|
||||
<i
|
||||
class="fa fa-spinner fa-spin"
|
||||
|
|
|
@ -20,7 +20,7 @@ module IssuableActions
|
|||
format.html { redirect_to index_path }
|
||||
format.json do
|
||||
render json: {
|
||||
path: index_path
|
||||
web_url: index_path
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,13 +32,16 @@ describe('Issuable output', () => {
|
|||
canMove: true,
|
||||
endpoint: '/gitlab-org/gitlab-shell/issues/9/realtime_changes',
|
||||
issuableRef: '#1',
|
||||
initialTitle: '',
|
||||
initialTitleHtml: '',
|
||||
initialTitleText: '',
|
||||
initialDescriptionHtml: '',
|
||||
initialDescriptionText: '',
|
||||
markdownPreviewUrl: '/',
|
||||
markdownDocs: '/',
|
||||
projectsAutocompleteUrl: '/',
|
||||
isConfidential: false,
|
||||
projectNamespace: '/',
|
||||
projectPath: '/',
|
||||
},
|
||||
}).$mount();
|
||||
});
|
||||
|
@ -224,6 +227,23 @@ describe('Issuable output', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('does not update issuable if project move confirm is false', (done) => {
|
||||
spyOn(window, 'confirm').and.returnValue(false);
|
||||
spyOn(vm.service, 'updateIssuable');
|
||||
|
||||
vm.store.formState.move_to_project_id = 1;
|
||||
|
||||
vm.updateIssuable();
|
||||
|
||||
setTimeout(() => {
|
||||
expect(
|
||||
vm.service.updateIssuable,
|
||||
).not.toHaveBeenCalled();
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('closes form on error', (done) => {
|
||||
spyOn(window, 'Flash').and.callThrough();
|
||||
spyOn(vm.service, 'updateIssuable').and.callFake(() => new Promise((resolve, reject) => {
|
||||
|
|
Loading…
Reference in New Issue