This is an automated email from the ASF dual-hosted git repository. machristie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
commit 1539cd49650f0f4863ae3db730bfd1c4e90b0f63 Author: Marcus Christie <[email protected]> AuthorDate: Fri Sep 21 12:30:17 2018 -0400 AIRAVATA-2876 Navigate to route with save error --- .../applications/ApplicationEditorContainer.vue | 83 +++++++++++++++++++--- .../static/django_airavata_admin/src/router.js | 4 +- 2 files changed, 74 insertions(+), 13 deletions(-) diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationEditorContainer.vue b/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationEditorContainer.vue index 288e125..fd96abd 100644 --- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationEditorContainer.vue +++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationEditorContainer.vue @@ -30,7 +30,7 @@ </div> <div class="row"> <div class="col"> - <b-button variant="primary" @click="saveAll" :disabled="readonly"> + <b-button variant="primary" @click="saveAll" :disabled="readonly || !isDirty"> Save </b-button> <delete-button v-if="id" :disabled="readonly" @delete="deleteApplication"> @@ -452,27 +452,58 @@ export default { return Promise.resolve(this.currentDeployment); }, saveAll() { - // TODO: catch errors and navigate to the route showing the errors const moduleSave = this.appModuleIsDirty - ? this.saveApplicationModule(this.appModule) + ? this.saveApplicationModule(this.appModule).catch(error => { + // Navigate to the route that has the error + this.$router.push({ + name: this.id ? "application_module" : "new_application_module" + }); + // Cancel the chain of promises + return Promise.reject(error); + }) : Promise.resolve(this.appModule); const interfaceSave = moduleSave.then( - this.appInterfaceIsDirty - ? this.saveApplicationInterface(this.appInterface) - : Promise.resolve(this.appInterface) + appModule => + this.appInterfaceIsDirty + ? this.saveApplicationInterface(this.appInterface).catch(error => { + // Navigate to the route that has the error + this.$router.push({ + name: "application_interface" + }); + // Cancel the chain of promises + return Promise.reject(error); + }) + : Promise.resolve(this.appInterface) ); const deploymentsSave = interfaceSave - .then(() => { + .then(appInterface => { return Promise.all( this.dirtyAppDeploymentComputeHostIds.map(computeHostId => { const deployment = this.appDeployments.find( dep => dep.computeHostId === computeHostId ); - return this.saveApplicationDeployment(deployment); + return this.saveApplicationDeployment(deployment).catch(error => { + // Navigate to the route that has the error + if (deployment.appDeploymentId) { + this.$router.push({ + name: "application_deployment", + params: { + id: this.id, + deploymentId: deployment.appDeploymentId + } + }); + } else { + this.$router.push({ + name: "new_application_deployment", + params: { id: this.id, hostId: deployment.computeHostId } + }); + } + return Promise.reject(error); + }); }) ); }) - .then(() => { + .then(appDeployments => { return Promise.all( this.dirtyAppDeploymentSharedEntityComputeHostIds.map( computeHostId => { @@ -482,12 +513,42 @@ export default { const deployment = this.appDeployments.find( dep => dep.computeHostId === computeHostId ); - return this.saveSharedEntity(sharedEntity, deployment); + return this.saveSharedEntity(sharedEntity, deployment).catch( + error => { + // Navigate to the route that has the error + if (deployment.appDeploymentId) { + this.$router.push({ + name: "application_deployment", + params: { + id: this.id, + deploymentId: deployment.appDeploymentId + } + }); + } else { + this.$router.push({ + name: "new_application_deployment", + params: { + id: this.id, + hostId: deployment.computeHostId + } + }); + } + return Promise.reject(error); + } + ); } ) ); }) - .then(() => { + .then(sharedEntities => { + if (!this.id && this.appModule.appModuleId) { + // if we just create a new module, navigate to app module route now + // that we have an id + this.$router.push({ + name: "application_module", + params: { id: this.appModule.appModuleId } + }); + } // Reinitialize deployment editing so that deployment being edited is // the saved instance this.initializeDeploymentEditing(); diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/router.js b/django_airavata/apps/admin/static/django_airavata_admin/src/router.js index 10cacd8..b695de7 100644 --- a/django_airavata/apps/admin/static/django_airavata_admin/src/router.js +++ b/django_airavata/apps/admin/static/django_airavata_admin/src/router.js @@ -43,8 +43,8 @@ const routes = [ component: ApplicationEditorContainer, name: "new_application", children: [ - // TODO: Maybe only have the module route for a new application, save it - // and then replace the URL with the module id + // Only the module route for a new application, save it and then replace + // the URL with the module id { path: "", components: {
