Skip to content

Commit b3dca8c

Browse files
authored
ui: Go back for delete actions before querying async job (#5360)
* ui: Go back for delete actions before querying async job * Prevent redirecting if failed
1 parent 16e4de0 commit b3dca8c

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

ui/src/utils/plugins.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export const pollJobPlugin = {
9191
const currentPage = this.$router.currentRoute.path
9292
const samePage = options.originalPage === currentPage || options.originalPage.startsWith(currentPage + '/')
9393
if (samePage && (!action || !('isFetchData' in action) || (action.isFetchData))) {
94-
eventBus.$emit('async-job-complete')
94+
eventBus.$emit('async-job-complete', action)
9595
}
9696
successMethod(result)
9797
} else if (result.jobstatus === 2) {
@@ -121,8 +121,12 @@ export const pollJobPlugin = {
121121
status: 'failed',
122122
duration: 0
123123
})
124-
if (!action || !('isFetchData' in action) || (action.isFetchData)) {
125-
eventBus.$emit('async-job-complete')
124+
125+
// Ensure we refresh on the same / parent page
126+
const currentPage = this.$router.currentRoute.path
127+
const samePage = options.originalPage === currentPage || options.originalPage.startsWith(currentPage + '/')
128+
if (samePage && (!action || !('isFetchData' in action) || (action.isFetchData))) {
129+
eventBus.$emit('async-job-complete', action)
126130
}
127131
errorMethod(result)
128132
} else if (result.jobstatus === 0) {

ui/src/views/AutogenView.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,9 @@ export default {
862862
})
863863
},
864864
pollActionCompletion (jobId, action, resourceName, showLoading = true) {
865+
if (this.shouldNavigateBack(action)) {
866+
action.isFetchData = false
867+
}
865868
return new Promise((resolve) => {
866869
this.$pollJob({
867870
jobId,
@@ -1062,7 +1065,7 @@ export default {
10621065
api(...args).then(json => {
10631066
this.handleResponse(json, resourceName, action).then(jobId => {
10641067
hasJobId = jobId
1065-
if ((action.icon === 'delete' || ['archiveEvents', 'archiveAlerts', 'unmanageVirtualMachine'].includes(action.api)) && this.dataView) {
1068+
if (this.shouldNavigateBack(action)) {
10661069
this.$router.go(-1)
10671070
} else {
10681071
if (!hasJobId) {
@@ -1083,6 +1086,9 @@ export default {
10831086
})
10841087
})
10851088
},
1089+
shouldNavigateBack (action) {
1090+
return ((action.icon === 'delete' || ['archiveEvents', 'archiveAlerts', 'unmanageVirtualMachine'].includes(action.api)) && this.dataView)
1091+
},
10861092
changeFilter (filter) {
10871093
const query = Object.assign({}, this.$route.query)
10881094
delete query.templatefilter

0 commit comments

Comments
 (0)