ui: Fix refresh issue (#5232)

This commit is contained in:
davidjumani 2021-07-26 13:28:05 +05:30 committed by GitHub
parent c23cbdff8d
commit b065e79ae3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View File

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

View File

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