summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-05-26 12:14:40 +0000
committerFilipa Lacerda <filipa@gitlab.com>2017-05-26 12:14:40 +0000
commit7f34b7cb16d7e42d7099712d8ce657e6e395913b (patch)
tree1f3168b68407c292c2ab4af4d5ba9f5a5fb1afaf
parent0defc4f7ccae38e69f0ad185bc912eb4f5448661 (diff)
parent10dccdc4e167901a3d86e04fc0748c539b545c6e (diff)
downloadgitlab-ce-7f34b7cb16d7e42d7099712d8ce657e6e395913b.tar.gz
Merge branch 'issue-edit-inline-project-move-warning' into 'issue-edit-inline'
Warn before moving issue in inline edit form See merge request !11708
-rw-r--r--app/assets/javascripts/issue_show/components/app.vue11
-rw-r--r--app/assets/javascripts/issue_show/components/edit_actions.vue7
-rw-r--r--app/assets/javascripts/issue_show/stores/index.js1
-rw-r--r--app/controllers/concerns/issuable_actions.rb2
-rw-r--r--spec/javascripts/issue_show/components/app_spec.js22
5 files changed, 36 insertions, 7 deletions
diff --git a/app/assets/javascripts/issue_show/components/app.vue b/app/assets/javascripts/issue_show/components/app.vue
index 74614984097..ed367c780c6 100644
--- a/app/assets/javascripts/issue_show/components/app.vue
+++ b/app/assets/javascripts/issue_show/components/app.vue
@@ -114,6 +114,7 @@ export default {
description: this.state.descriptionText,
lockedWarningVisible: false,
move_to_project_id: 0,
+ updateLoading: false,
});
}
},
@@ -121,6 +122,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) {
+ this.store.formState.updateLoading = false;
+ return;
+ }
+
this.service.updateIssuable(this.store.formState)
.then(res => res.json())
.then((data) => {
@@ -149,7 +158,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');
diff --git a/app/assets/javascripts/issue_show/components/edit_actions.vue b/app/assets/javascripts/issue_show/components/edit_actions.vue
index 7f3db73faee..3fe0bfdb751 100644
--- a/app/assets/javascripts/issue_show/components/edit_actions.vue
+++ b/app/assets/javascripts/issue_show/components/edit_actions.vue
@@ -15,7 +15,6 @@
data() {
return {
deleteLoading: false,
- updateLoading: false,
};
},
computed: {
@@ -25,7 +24,7 @@
},
methods: {
updateIssuable() {
- this.updateLoading = true;
+ this.formState.updateLoading = true;
eventHub.$emit('update.issuable');
},
closeForm() {
@@ -47,7 +46,7 @@
<div class="prepend-top-default append-bottom-default clearfix">
<button
class="btn btn-save pull-left"
- :class="{ disabled: updateLoading || !isSubmitEnabled }"
+ :class="{ disabled: formState.updateLoading || !isSubmitEnabled }"
type="submit"
:disabled="updateLoading || !isSubmitEnabled"
@click.prevent="updateIssuable">
@@ -55,7 +54,7 @@
<i
class="fa fa-spinner fa-spin"
aria-hidden="true"
- v-if="updateLoading">
+ v-if="formState.updateLoading">
</i>
</button>
<button
diff --git a/app/assets/javascripts/issue_show/stores/index.js b/app/assets/javascripts/issue_show/stores/index.js
index 76abcc64ed3..fbb95866671 100644
--- a/app/assets/javascripts/issue_show/stores/index.js
+++ b/app/assets/javascripts/issue_show/stores/index.js
@@ -19,6 +19,7 @@ export default class Store {
description: '',
lockedWarningVisible: false,
move_to_project_id: 0,
+ updateLoading: false,
};
}
diff --git a/app/controllers/concerns/issuable_actions.rb b/app/controllers/concerns/issuable_actions.rb
index bfd6441e928..0c3b68a7ac3 100644
--- a/app/controllers/concerns/issuable_actions.rb
+++ b/app/controllers/concerns/issuable_actions.rb
@@ -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
diff --git a/spec/javascripts/issue_show/components/app_spec.js b/spec/javascripts/issue_show/components/app_spec.js
index db146c4a1ee..b421f8356cf 100644
--- a/spec/javascripts/issue_show/components/app_spec.js
+++ b/spec/javascripts/issue_show/components/app_spec.js
@@ -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) => {