diff --git a/ui/src/components/view/ActionButton.vue b/ui/src/components/view/ActionButton.vue index f919f4c77e4..5202cc6001d 100644 --- a/ui/src/components/view/ActionButton.vue +++ b/ui/src/components/view/ActionButton.vue @@ -145,7 +145,6 @@ export default { this.actionBadge = {} const arrAsync = [] const actionBadge = this.actions.filter(action => action.showBadge === true) - if ((actionBadge.dataView ? actionBadge.dataView : false) !== this.dataView) return if (actionBadge && actionBadge.length > 0) { const dataLength = actionBadge.length diff --git a/ui/src/utils/plugins.js b/ui/src/utils/plugins.js index 946a13ad9b1..64163897997 100644 --- a/ui/src/utils/plugins.js +++ b/ui/src/utils/plugins.js @@ -66,7 +66,7 @@ export const pollJobPlugin = { status: 'progress' }) - options.originalPage = options.originalPage ? options.originalPage : this.$router.currentRoute.path + options.originalPage = options.originalPage || this.$router.currentRoute.path api('queryAsyncJobResult', { jobId }).then(json => { const result = json.queryasyncjobresultresponse if (result.jobstatus === 1) { @@ -92,7 +92,7 @@ export const pollJobPlugin = { // Ensure we refresh on the same / parent page const currentPage = this.$router.currentRoute.path - const samePage = originalPage === currentPage || originalPage.startsWith(currentPage + '/') + const samePage = options.originalPage === currentPage || options.originalPage.startsWith(currentPage + '/') if (samePage && (!action || !('isFetchData' in action) || (action.isFetchData))) { eventBus.$emit('async-job-complete') } diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue index f1cf48b971b..0ddf530362e 100644 --- a/ui/src/views/AutogenView.vue +++ b/ui/src/views/AutogenView.vue @@ -1177,19 +1177,18 @@ export default { message = message + ' - ' + this.$t(action.successMessage) duration = 5 } - this.$message.success({ - content: message, - key: action.label + resourceName, - duration: duration - }) + break } - break } - } - if (['addLdapConfiguration', 'deleteLdapConfiguration'].includes(action.api)) { - this.$store.dispatch('UpdateConfiguration') - } - return false + if (['addLdapConfiguration', 'deleteLdapConfiguration'].includes(action.api)) { + this.$store.dispatch('UpdateConfiguration') + } + if (jobId) { + return resolve(this.pollActionCompletion(jobId, action, resourceName, showLoading)) + } + + return resolve(false) + }) }, execSubmit (e) { e.preventDefault() diff --git a/ui/src/views/infra/zone/ZoneWizardLaunchZone.vue b/ui/src/views/infra/zone/ZoneWizardLaunchZone.vue index b51e976ff07..3a086d12381 100644 --- a/ui/src/views/infra/zone/ZoneWizardLaunchZone.vue +++ b/ui/src/views/infra/zone/ZoneWizardLaunchZone.vue @@ -326,7 +326,7 @@ export default { params.dns1 = this.prefillContent.ipv4Dns1.value params.dns2 = this.prefillContent.ipv4Dns2 ? this.prefillContent.ipv4Dns2.value : null params.ip6dns1 = this.prefillContent.ipv6Dns1 ? this.prefillContent.ipv6Dns1.value : null - params.ip6dns2 = this.prefillContent.ipv6Dns1 ? this.prefillContent.ipv6Dns1.value : null + params.ip6dns2 = this.prefillContent.ipv6Dns2 ? this.prefillContent.ipv6Dns2.value : null params.internaldns1 = this.prefillContent.internalDns1 ? this.prefillContent.internalDns1.value : null params.internaldns2 = this.prefillContent.internalDns2 ? this.prefillContent.internalDns2.value : null params.domain = this.prefillContent.networkDomain ? this.prefillContent.networkDomain.value : null diff --git a/ui/tests/mockData/ActionButton.mock.json b/ui/tests/mockData/ActionButton.mock.json index 7c073d3819d..1135844cca2 100644 --- a/ui/tests/mockData/ActionButton.mock.json +++ b/ui/tests/mockData/ActionButton.mock.json @@ -33,4 +33,4 @@ } } ] -} \ No newline at end of file +} diff --git a/ui/tests/unit/views/AutogenView.spec.js b/ui/tests/unit/views/AutogenView.spec.js index 8823894dbcc..a866aaea1f6 100644 --- a/ui/tests/unit/views/AutogenView.spec.js +++ b/ui/tests/unit/views/AutogenView.spec.js @@ -36,9 +36,6 @@ const state = { store = common.createMockStore(state) i18n = common.createMockI18n('en', mockData.messages) -const actions = { - AddAsyncJob: jest.fn((jobId) => {}) -} const spyConsole = { log: null, warn: null @@ -2814,8 +2811,8 @@ describe('Views > AutogenView.vue', () => { }, 1000) }) - it('check pollActionCompletion() and action AddAsyncJob is called when api is called and response have jobId result', async (done) => { - store = common.createMockStore(state, actions) + it('check pollActionCompletion() is called when api is called and response have jobId result', async (done) => { + store = common.createMockStore(state) wrapper = factory({ store: store, data: { @@ -2851,14 +2848,13 @@ describe('Views > AutogenView.vue', () => { wrapper.vm.execSubmit(event) setTimeout(() => { - expect(actions.AddAsyncJob).toHaveBeenCalled() expect(spyPollAction).toHaveBeenCalled() done() }) }) - it('check $notification when api is called and response have not jobId result', async (done) => { + it('check $message, fetchData() is called when api response have not jobId result', async (done) => { wrapper = factory({ data: { showAction: true, @@ -2888,6 +2884,7 @@ describe('Views > AutogenView.vue', () => { } } + const spyFetchData = jest.spyOn(wrapper.vm, 'fetchData') mockAxios.mockResolvedValue(mockData) spyConsole.log = jest.spyOn(console, 'log').mockImplementation(() => {}) @@ -2903,6 +2900,7 @@ describe('Views > AutogenView.vue', () => { key: 'labelnametest-name-value', duration: 2 }) + expect(spyFetchData).toHaveBeenCalled() done() }) diff --git a/ui/tests/unit/views/compute/MigrateWizard.spec.js b/ui/tests/unit/views/compute/MigrateWizard.spec.js index eef8722e1b6..333a7d464d1 100644 --- a/ui/tests/unit/views/compute/MigrateWizard.spec.js +++ b/ui/tests/unit/views/compute/MigrateWizard.spec.js @@ -25,9 +25,6 @@ jest.mock('axios', () => mockAxios) let wrapper, i18n, store, mocks, router const state = {} -const actions = { - AddAsyncJob: jest.fn((jobObject) => {}) -} mocks = { $message: { error: jest.fn((message) => {}) @@ -56,7 +53,7 @@ mocks = { }) } i18n = common.createMockI18n('en', mockData.messages) -store = common.createMockStore(state, actions) +store = common.createMockStore(state) const factory = (opts = {}) => { i18n = opts.i18n || i18n @@ -564,7 +561,6 @@ describe('Views > compute > MigrateWizard.vue', () => { await wrapper.vm.submitForm() setTimeout(() => { - expect(actions.AddAsyncJob).toHaveBeenCalled() expect(mocks.$pollJob).toHaveBeenCalled() expect(wrapper.emitted()['close-action'][0]).toEqual([]) @@ -572,7 +568,7 @@ describe('Views > compute > MigrateWizard.vue', () => { }) }) - it('check store dispatch `AddAsyncJob` and $pollJob have successMethod() is called with requiresStorageMotion is false', async (done) => { + it('check $pollJob have successMethod() is called with requiresStorageMotion is false', async (done) => { const mockData = { migratevirtualmachineresponse: { jobid: 'test-job-id-case-2' @@ -670,7 +666,6 @@ describe('Views > compute > MigrateWizard.vue', () => { await wrapper.vm.submitForm() setTimeout(() => { - expect(actions.AddAsyncJob).toHaveBeenCalled() expect(mocks.$pollJob).toHaveBeenCalled() expect(wrapper.emitted()['close-action'][0]).toEqual([]) @@ -678,7 +673,7 @@ describe('Views > compute > MigrateWizard.vue', () => { }) }) - it('check store dispatch `AddAsyncJob` and $pollJob have errorMethod() is called', async (done) => { + it('check $pollJob have errorMethod() is called', async (done) => { const mockData = { migratesystemvmresponse: { jobid: 'test-job-id-case-3' @@ -713,7 +708,6 @@ describe('Views > compute > MigrateWizard.vue', () => { await wrapper.vm.submitForm() setTimeout(() => { - expect(actions.AddAsyncJob).toHaveBeenCalled() expect(mocks.$pollJob).toHaveBeenCalled() expect(wrapper.emitted()['close-action'][0]).toEqual([]) @@ -721,7 +715,7 @@ describe('Views > compute > MigrateWizard.vue', () => { }) }) - it('check store dispatch `AddAsyncJob` and $pollJob have catchMethod() is called', async (done) => { + it('check $pollJob have catchMethod() is called', async (done) => { const mockData = { migratesystemvmresponse: { jobid: 'test-job-id-case-4' @@ -750,7 +744,6 @@ describe('Views > compute > MigrateWizard.vue', () => { await wrapper.vm.submitForm() setTimeout(() => { - expect(actions.AddAsyncJob).toHaveBeenCalled() expect(mocks.$pollJob).toHaveBeenCalled() expect(wrapper.emitted()['close-action'][0]).toEqual([])