From 568d78fc9169921d099ea57b91c21275828d706c Mon Sep 17 00:00:00 2001 From: davidjumani Date: Tue, 24 Aug 2021 10:21:37 +0530 Subject: [PATCH 1/2] ui: Go back for delete actions before querying async job --- ui/src/views/AutogenView.vue | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue index 5f408c757608..05bec489b9c5 100644 --- a/ui/src/views/AutogenView.vue +++ b/ui/src/views/AutogenView.vue @@ -972,6 +972,9 @@ export default { break } } + if ((action.icon === 'delete' || ['archiveEvents', 'archiveAlerts', 'unmanageVirtualMachine'].includes(action.api)) && this.dataView) { + this.$router.go(-1) + } if (['addLdapConfiguration', 'deleteLdapConfiguration'].includes(action.api)) { this.$store.dispatch('UpdateConfiguration') } @@ -1057,12 +1060,8 @@ export default { api(...args).then(json => { this.handleResponse(json, resourceName, action).then(jobId => { hasJobId = jobId - if ((action.icon === 'delete' || ['archiveEvents', 'archiveAlerts', 'unmanageVirtualMachine'].includes(action.api)) && this.dataView) { - this.$router.go(-1) - } else { - if (!hasJobId) { - this.fetchData() - } + if (!hasJobId) { + this.fetchData() } }) this.closeAction() From 534b715ecd4573d58a02658c477075748baf546a Mon Sep 17 00:00:00 2001 From: davidjumani Date: Wed, 25 Aug 2021 10:50:22 +0530 Subject: [PATCH 2/2] Prevent redirecting if failed --- ui/src/utils/plugins.js | 10 +++++++--- ui/src/views/AutogenView.vue | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/ui/src/utils/plugins.js b/ui/src/utils/plugins.js index 3c512d2d261c..1f621be34559 100644 --- a/ui/src/utils/plugins.js +++ b/ui/src/utils/plugins.js @@ -91,7 +91,7 @@ export const pollJobPlugin = { const currentPage = this.$router.currentRoute.path const samePage = options.originalPage === currentPage || options.originalPage.startsWith(currentPage + '/') if (samePage && (!action || !('isFetchData' in action) || (action.isFetchData))) { - eventBus.$emit('async-job-complete') + eventBus.$emit('async-job-complete', action) } successMethod(result) } else if (result.jobstatus === 2) { @@ -121,8 +121,12 @@ export const pollJobPlugin = { status: 'failed', duration: 0 }) - if (!action || !('isFetchData' in action) || (action.isFetchData)) { - eventBus.$emit('async-job-complete') + + // Ensure we refresh on the same / parent page + const currentPage = this.$router.currentRoute.path + const samePage = options.originalPage === currentPage || options.originalPage.startsWith(currentPage + '/') + if (samePage && (!action || !('isFetchData' in action) || (action.isFetchData))) { + eventBus.$emit('async-job-complete', action) } errorMethod(result) } else if (result.jobstatus === 0) { diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue index 05bec489b9c5..da7f951a77cc 100644 --- a/ui/src/views/AutogenView.vue +++ b/ui/src/views/AutogenView.vue @@ -857,6 +857,9 @@ export default { }) }, pollActionCompletion (jobId, action, resourceName, showLoading = true) { + if (this.shouldNavigateBack(action)) { + action.isFetchData = false + } return new Promise((resolve) => { this.$pollJob({ jobId, @@ -972,9 +975,6 @@ export default { break } } - if ((action.icon === 'delete' || ['archiveEvents', 'archiveAlerts', 'unmanageVirtualMachine'].includes(action.api)) && this.dataView) { - this.$router.go(-1) - } if (['addLdapConfiguration', 'deleteLdapConfiguration'].includes(action.api)) { this.$store.dispatch('UpdateConfiguration') } @@ -1060,8 +1060,12 @@ export default { api(...args).then(json => { this.handleResponse(json, resourceName, action).then(jobId => { hasJobId = jobId - if (!hasJobId) { - this.fetchData() + if (this.shouldNavigateBack(action)) { + this.$router.go(-1) + } else { + if (!hasJobId) { + this.fetchData() + } } }) this.closeAction() @@ -1077,6 +1081,9 @@ export default { }) }) }, + shouldNavigateBack (action) { + return ((action.icon === 'delete' || ['archiveEvents', 'archiveAlerts', 'unmanageVirtualMachine'].includes(action.api)) && this.dataView) + }, changeFilter (filter) { const query = Object.assign({}, this.$route.query) delete query.templatefilter