Skip to content

Commit b065e79

Browse files
authored
ui: Fix refresh issue (#5232)
1 parent c23cbdf commit b065e79

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

ui/src/utils/plugins.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ export const pollJobPlugin = {
5555
catchMessage = i18n.t('label.error.caught'),
5656
catchMethod = () => {},
5757
action = null,
58-
bulkAction = false
58+
bulkAction = false,
59+
originalPage = null
5960
} = options
6061

6162
store.dispatch('AddHeaderNotice', {
@@ -65,6 +66,7 @@ export const pollJobPlugin = {
6566
status: 'progress'
6667
})
6768

69+
options.originalPage = options.originalPage ? options.originalPage : this.$router.currentRoute.path
6870
api('queryAsyncJobResult', { jobId }).then(json => {
6971
const result = json.queryasyncjobresultresponse
7072
if (result.jobstatus === 1) {
@@ -87,8 +89,12 @@ export const pollJobPlugin = {
8789
status: 'done',
8890
duration: 2
8991
})
90-
if (!action || !('isFetchData' in action) || (action.isFetchData)) {
91-
eventBus.$emit('async-job-complete', action)
92+
93+
// Ensure we refresh on the same / parent page
94+
const currentPage = this.$router.currentRoute.path
95+
const samePage = originalPage === currentPage || originalPage.startsWith(currentPage + '/')
96+
if (samePage && (!action || !('isFetchData' in action) || (action.isFetchData))) {
97+
eventBus.$emit('async-job-complete')
9298
}
9399
successMethod(result)
94100
} else if (result.jobstatus === 2) {

ui/src/views/AutogenView.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,13 @@ export default {
12561256
args = [action.api, params]
12571257
}
12581258
api(...args).then(json => {
1259-
this.handleResponse(json, resourceName, this.getDataIdentifier(params), action).then(jobId => {
1259+
var response = this.handleResponse(json, resourceName, this.getDataIdentifier(params), action)
1260+
if (!response) {
1261+
this.fetchData()
1262+
this.closeAction()
1263+
return
1264+
}
1265+
response.then(jobId => {
12601266
hasJobId = jobId
12611267
if ((action.icon === 'delete' || ['archiveEvents', 'archiveAlerts', 'unmanageVirtualMachine'].includes(action.api)) && this.dataView) {
12621268
this.$router.go(-1)

0 commit comments

Comments
 (0)