diff --git a/ui/src/utils/plugins.js b/ui/src/utils/plugins.js index fb316ae02a7..2b10996a242 100644 --- a/ui/src/utils/plugins.js +++ b/ui/src/utils/plugins.js @@ -55,7 +55,8 @@ export const pollJobPlugin = { catchMessage = i18n.t('label.error.caught'), catchMethod = () => {}, action = null, - bulkAction = false + bulkAction = false, + originalPage = null } = options store.dispatch('AddHeaderNotice', { @@ -65,6 +66,7 @@ export const pollJobPlugin = { status: 'progress' }) + options.originalPage = options.originalPage ? options.originalPage : this.$router.currentRoute.path api('queryAsyncJobResult', { jobId }).then(json => { const result = json.queryasyncjobresultresponse if (result.jobstatus === 1) { @@ -87,8 +89,12 @@ export const pollJobPlugin = { status: 'done', duration: 2 }) - if (!action || !('isFetchData' in action) || (action.isFetchData)) { - eventBus.$emit('async-job-complete', action) + + // Ensure we refresh on the same / parent page + const currentPage = this.$router.currentRoute.path + const samePage = originalPage === currentPage || originalPage.startsWith(currentPage + '/') + if (samePage && (!action || !('isFetchData' in action) || (action.isFetchData))) { + eventBus.$emit('async-job-complete') } successMethod(result) } else if (result.jobstatus === 2) { diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue index f2d4d6fc098..6b6bab4c3cd 100644 --- a/ui/src/views/AutogenView.vue +++ b/ui/src/views/AutogenView.vue @@ -1256,7 +1256,13 @@ export default { args = [action.api, params] } api(...args).then(json => { - this.handleResponse(json, resourceName, this.getDataIdentifier(params), action).then(jobId => { + var response = this.handleResponse(json, resourceName, this.getDataIdentifier(params), action) + if (!response) { + this.fetchData() + this.closeAction() + return + } + response.then(jobId => { hasJobId = jobId if ((action.icon === 'delete' || ['archiveEvents', 'archiveAlerts', 'unmanageVirtualMachine'].includes(action.api)) && this.dataView) { this.$router.go(-1)