ui: Refresh only on current / parent page (#5214)

This commit is contained in:
davidjumani 2021-07-21 15:05:30 +05:30 committed by GitHub
parent 535761b2b9
commit c4388d78e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,7 +53,8 @@ export const pollJobPlugin = {
showLoading = true,
catchMessage = i18n.t('label.error.caught'),
catchMethod = () => {},
action = null
action = null,
originalPage = null
} = options
store.dispatch('AddHeaderNotice', {
@ -63,6 +64,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) {
@ -85,7 +87,11 @@ export const pollJobPlugin = {
status: 'done',
duration: 2
})
if (!action || !('isFetchData' in action) || (action.isFetchData)) {
// 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)