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
This commit is contained in:
davidjumani 2021-08-27 13:48:17 +05:30 committed by GitHub
parent 16e4de0c25
commit b3dca8ca27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -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) {

View File

@ -862,6 +862,9 @@ export default {
})
},
pollActionCompletion (jobId, action, resourceName, showLoading = true) {
if (this.shouldNavigateBack(action)) {
action.isFetchData = false
}
return new Promise((resolve) => {
this.$pollJob({
jobId,
@ -1062,7 +1065,7 @@ 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) {
if (this.shouldNavigateBack(action)) {
this.$router.go(-1)
} else {
if (!hasJobId) {
@ -1083,6 +1086,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