ui: Fix failing UI (#5263)

This commit is contained in:
davidjumani 2021-07-30 15:48:55 +05:30 committed by GitHub
parent db31e67d51
commit 66e7bdedac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 33 deletions

View File

@ -55,8 +55,7 @@ export const pollJobPlugin = {
catchMessage = i18n.t('label.error.caught'), catchMessage = i18n.t('label.error.caught'),
catchMethod = () => {}, catchMethod = () => {},
action = null, action = null,
bulkAction = false, bulkAction = false
originalPage = null
} = options } = options
store.dispatch('AddHeaderNotice', { store.dispatch('AddHeaderNotice', {

View File

@ -1155,14 +1155,12 @@ export default {
return dataIdentifier return dataIdentifier
}, },
handleResponse (response, resourceName, resource, action, showLoading = true) { handleResponse (response, resourceName, resource, action, showLoading = true) {
return new Promise(resolve => {
let jobId = null
for (const obj in response) { for (const obj in response) {
if (obj.includes('response')) { if (obj.includes('response')) {
if (response[obj].jobid) { if (response[obj].jobid) {
return new Promise(resolve => { jobId = response[obj].jobid
const jobid = response[obj].jobid
eventBus.$emit('update-resource-state', this.selectedItems, resource, 'InProgress', jobid)
resolve(this.pollActionCompletion(jobid, action, resourceName, resource, showLoading))
})
} else { } else {
if (this.selectedItems.length > 0) { if (this.selectedItems.length > 0) {
eventBus.$emit('update-resource-state', this.selectedItems, resource, 'success') eventBus.$emit('update-resource-state', this.selectedItems, resource, 'success')
@ -1177,6 +1175,13 @@ export default {
message = message + ' - ' + this.$t(action.successMessage) message = message + ' - ' + this.$t(action.successMessage)
duration = 5 duration = 5
} }
if (this.selectedItems.length === 0) {
this.$message.success({
content: message,
key: action.label + resourceName,
duration: duration
})
}
break break
} }
} }
@ -1184,10 +1189,11 @@ export default {
this.$store.dispatch('UpdateConfiguration') this.$store.dispatch('UpdateConfiguration')
} }
if (jobId) { if (jobId) {
return resolve(this.pollActionCompletion(jobId, action, resourceName, showLoading)) eventBus.$emit('update-resource-state', this.selectedItems, resource, 'InProgress', jobId)
resolve(this.pollActionCompletion(jobId, action, resourceName, resource, showLoading))
}
resolve(false)
} }
return resolve(false)
}) })
}, },
execSubmit (e) { execSubmit (e) {

View File

@ -613,10 +613,8 @@ describe('Views > compute > MigrateWizard.vue', () => {
await wrapper.vm.submitForm() await wrapper.vm.submitForm()
setTimeout(() => { setTimeout(() => {
expect(actions.AddAsyncJob).toHaveBeenCalled()
expect(mocks.$pollJob).toHaveBeenCalled() expect(mocks.$pollJob).toHaveBeenCalled()
expect(wrapper.emitted()['close-action'][0]).toEqual([]) expect(wrapper.emitted()['close-action'][0]).toEqual([])
done() done()
}) })
}) })