This is an automated email from the ASF dual-hosted git repository. rohit pushed a commit to branch 4.16 in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.16 by this push: new 4392cc4 ui: refactoring $notification according to the old version (#5819) 4392cc4 is described below commit 4392cc4d485b31c90648871d970294f538624935 Author: Hoang Nguyen <hoan...@unitech.vn> AuthorDate: Mon Jan 3 22:29:49 2022 +0700 ui: refactoring $notification according to the old version (#5819) Related to PR #5549 changed the notification from $notification to $showNotification. This PR aims to change it back to the way it was for easier use while keeping the delete all button. --- ui/src/components/view/DetailSettings.vue | 3 +- ui/src/components/view/ListView.vue | 3 +- ui/src/components/view/ResourceLimitTab.vue | 3 +- ui/src/components/view/SettingsTab.vue | 3 +- ui/src/components/view/UploadResourceIcon.vue | 12 ++--- ui/src/config/section/compute.js | 6 +-- ui/src/core/lazy_lib/components_use.js | 1 - ui/src/utils/plugins.js | 56 ++++++++++++++-------- ui/src/views/AutogenView.vue | 3 +- ui/src/views/compute/AssignInstance.vue | 3 +- ui/src/views/compute/ChangeAffinity.vue | 3 +- ui/src/views/compute/CreateSSHKeyPair.vue | 3 +- ui/src/views/compute/CreateSnapshotWizard.vue | 3 +- ui/src/views/compute/DeployVM.vue | 23 ++++----- ui/src/views/compute/KubernetesServiceTab.vue | 3 +- ui/src/views/compute/MigrateWizard.vue | 3 +- ui/src/views/compute/ScaleVM.vue | 3 +- ui/src/views/compute/StartVirtualMachine.vue | 9 ++-- ui/src/views/compute/backup/BackupSchedule.vue | 3 +- ui/src/views/compute/backup/FormSchedule.vue | 3 +- ui/src/views/iam/AddAccount.vue | 15 ++---- ui/src/views/iam/AddLdapAccount.vue | 6 +-- ui/src/views/iam/AddUser.vue | 18 +++---- ui/src/views/iam/ChangeUserPassword.vue | 3 +- ui/src/views/iam/ConfigureSamlSsoAuth.vue | 6 +-- ui/src/views/iam/CreateRole.vue | 3 +- ui/src/views/iam/DomainActionForm.vue | 6 +-- ui/src/views/iam/DomainView.vue | 3 +- ui/src/views/iam/EditUser.vue | 6 +-- ui/src/views/iam/ImportRole.vue | 6 +-- ui/src/views/image/IsoZones.vue | 3 +- ui/src/views/image/RegisterOrUploadIso.vue | 15 ++---- ui/src/views/image/RegisterOrUploadTemplate.vue | 12 ++--- ui/src/views/image/TemplateZones.vue | 3 +- .../views/image/UpdateTemplateIsoPermissions.vue | 3 +- ui/src/views/infra/AddPrimaryStorage.vue | 3 +- ui/src/views/infra/AddSecondaryStorage.vue | 3 +- ui/src/views/infra/ClusterAdd.vue | 9 ++-- ui/src/views/infra/HostAdd.vue | 6 +-- ui/src/views/infra/InfraSummary.vue | 6 +-- ui/src/views/infra/MigrateData.vue | 6 +-- ui/src/views/infra/PodAdd.vue | 6 +-- ui/src/views/infra/network/DedicatedVLANTab.vue | 3 +- ui/src/views/infra/network/EditTrafficLabel.vue | 3 +- ui/src/views/infra/network/IpRangesTabPublic.vue | 15 ++---- ui/src/views/infra/network/ServiceProvidersTab.vue | 6 +-- .../infra/network/providers/AddF5LoadBalancer.vue | 3 +- .../network/providers/AddNetscalerLoadBalancer.vue | 3 +- .../infra/network/providers/AddNiciraNvpDevice.vue | 3 +- .../network/providers/AddPaloAltoFirewall.vue | 3 +- .../infra/network/providers/AddSrxFirewall.vue | 3 +- .../views/infra/network/providers/ProviderItem.vue | 3 +- .../infra/network/providers/ProviderListView.vue | 6 +-- ui/src/views/infra/zone/ZoneWizardLaunchZone.vue | 3 +- ui/src/views/network/AclListRulesTab.vue | 3 +- ui/src/views/network/CreateIsolatedNetworkForm.vue | 3 +- ui/src/views/network/CreateL2NetworkForm.vue | 3 +- ui/src/views/network/CreateSharedNetworkForm.vue | 6 +-- ui/src/views/network/CreateVlanIpRange.vue | 6 +-- ui/src/views/network/InternalLBAssignVmForm.vue | 3 +- ui/src/views/network/IpAddressesTab.vue | 6 +-- ui/src/views/network/VpcTiersTab.vue | 3 +- ui/src/views/network/VpnDetails.vue | 3 +- ui/src/views/offering/UpdateOfferingAccess.vue | 3 +- .../views/plugins/quota/EditTariffValueWizard.vue | 3 +- ui/src/views/project/iam/ProjectRoleTab.vue | 9 ++-- ui/src/views/storage/FormSchedule.vue | 3 +- ui/src/views/storage/ResizeVolume.vue | 3 +- ui/src/views/storage/ScheduledSnapshots.vue | 3 +- ui/src/views/storage/UploadLocalVolume.vue | 9 ++-- ui/src/views/tools/ImportUnmanagedInstance.vue | 21 +++----- ui/tests/unit/views/AutogenView.spec.js | 33 +++++++------ ui/tests/unit/views/compute/MigrateWizard.spec.js | 20 ++++++-- 73 files changed, 198 insertions(+), 295 deletions(-) diff --git a/ui/src/components/view/DetailSettings.vue b/ui/src/components/view/DetailSettings.vue index 07f0a49..2588c11 100644 --- a/ui/src/components/view/DetailSettings.vue +++ b/ui/src/components/view/DetailSettings.vue @@ -219,8 +219,7 @@ export default { apiName = 'updateTemplate' } if (!(apiName in this.$store.getters.apis)) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('error.execute.api.failed') + ' ' + apiName, description: this.$t('message.user.not.permitted.api') }) diff --git a/ui/src/components/view/ListView.vue b/ui/src/components/view/ListView.vue index 0918dd6..7ea3e39 100644 --- a/ui/src/components/view/ListView.vue +++ b/ui/src/components/view/ListView.vue @@ -514,8 +514,7 @@ export default { json.updateconfigurationresponse.configuration && !json.updateconfigurationresponse.configuration.isdynamic && ['Admin'].includes(this.$store.getters.userInfo.roletype)) { - this.$showNotification({ - type: 'warning', + this.$notification.warning({ message: this.$t('label.status'), description: this.$t('message.restart.mgmt.server') }) diff --git a/ui/src/components/view/ResourceLimitTab.vue b/ui/src/components/view/ResourceLimitTab.vue index 2bf9619..93cce68 100644 --- a/ui/src/components/view/ResourceLimitTab.vue +++ b/ui/src/components/view/ResourceLimitTab.vue @@ -107,8 +107,7 @@ export default { this.dataResource = await this.listResourceLimits(params) this.formLoading = false } catch (e) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: e }) diff --git a/ui/src/components/view/SettingsTab.vue b/ui/src/components/view/SettingsTab.vue index 4f71e19..349d516 100644 --- a/ui/src/components/view/SettingsTab.vue +++ b/ui/src/components/view/SettingsTab.vue @@ -164,8 +164,7 @@ export default { }).catch(error => { console.error(error) this.$message.error(this.$t('message.error.save.setting')) - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('label.error'), description: this.$t('message.error.try.save.setting') }) diff --git a/ui/src/components/view/UploadResourceIcon.vue b/ui/src/components/view/UploadResourceIcon.vue index cd8eb2f..ecf6d66 100644 --- a/ui/src/components/view/UploadResourceIcon.vue +++ b/ui/src/components/view/UploadResourceIcon.vue @@ -234,15 +234,13 @@ export default { }).then(json => { console.log(this.resource) if (json?.uploadresourceiconresponse?.success) { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.upload.icon'), description: `${this.$t('message.success.upload.icon')} ${resourceType}: ` + (this.resource.name || this.resource.username || resourceid) }) } }).catch((error) => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('label.upload.icon'), description: error?.response?.data?.uploadresourceiconresponse?.errortext || '', duration: 0 @@ -266,15 +264,13 @@ export default { resourceids: resourceid }).then(json => { if (json?.deleteresourceiconresponse?.success) { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.delete.icon'), description: `${this.$t('message.success.delete.icon')} ${resourceType}: ` + (this.resource.name || this.resource.username || resourceid) }) } }).catch((error) => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('label.delete.icon'), description: error?.response?.data?.deleteresourceiconresponse?.errortext || '', duration: 0 diff --git a/ui/src/config/section/compute.js b/ui/src/config/section/compute.js index 416fa98..835923d 100644 --- a/ui/src/config/section/compute.js +++ b/ui/src/config/section/compute.js @@ -152,8 +152,7 @@ export default { const vm = result.jobresult.virtualmachine || {} if (result.jobstatus === 1 && vm.password) { const name = vm.displayname || vm.name || vm.id - obj.$showNotification({ - type: 'success', + obj.$notification.success({ message: `${obj.$t('label.reinstall.vm')}: ` + name, description: `${obj.$t('label.password.reset.confirm')}: ` + vm.password, duration: 0 @@ -362,8 +361,7 @@ export default { const vm = result.jobresult.virtualmachine || {} if (result.jobstatus === 1 && vm.password) { const name = vm.displayname || vm.name || vm.id - obj.$showNotification({ - type: 'success', + obj.$notification.success({ message: `${obj.$t('label.reset.ssh.key.pair.on.vm')}: ` + name, description: `${obj.$t('label.password.reset.confirm')}: ` + vm.password, duration: 0 diff --git a/ui/src/core/lazy_lib/components_use.js b/ui/src/core/lazy_lib/components_use.js index a9adc5d..b0bfcca 100644 --- a/ui/src/core/lazy_lib/components_use.js +++ b/ui/src/core/lazy_lib/components_use.js @@ -122,7 +122,6 @@ Vue.use(VueCropper) Vue.prototype.$confirm = Modal.confirm Vue.prototype.$message = message -Vue.prototype.$notification = notification Vue.prototype.$info = Modal.info Vue.prototype.$success = Modal.success Vue.prototype.$error = Modal.error diff --git a/ui/src/utils/plugins.js b/ui/src/utils/plugins.js index 5f32cf2..1693750 100644 --- a/ui/src/utils/plugins.js +++ b/ui/src/utils/plugins.js @@ -237,33 +237,47 @@ export const notifierPlugin = { }) } - Vue.prototype.$showNotification = function (config) { - let countNotify = store.getters.countNotify - countNotify++ - store.commit('SET_COUNT_NOTIFY', countNotify) - const defaultConfig = { + Vue.prototype.$notification = { + defaultConfig: { top: '65px', onClose: () => { let countNotify = store.getters.countNotify countNotify > 0 ? countNotify-- : countNotify = 0 store.commit('SET_COUNT_NOTIFY', countNotify) } - } - config = Object.assign({}, defaultConfig, config) - switch (config.type) { - case 'info': - notification.info(config) - break - case 'error': - notification.error(config) - break - case 'success': - notification.success(config) - break - case 'warning': - notification.warning(config) - break - } + }, + setCountNotify: () => { + let countNotify = store.getters.countNotify + countNotify++ + store.commit('SET_COUNT_NOTIFY', countNotify) + }, + info: (config) => { + Vue.prototype.$notification.setCountNotify() + config = Object.assign({}, Vue.prototype.$notification.defaultConfig, config) + notification.info(config) + }, + error: (config) => { + Vue.prototype.$notification.setCountNotify() + config = Object.assign({}, Vue.prototype.$notification.defaultConfig, config) + notification.error(config) + }, + success: (config) => { + Vue.prototype.$notification.setCountNotify() + config = Object.assign({}, Vue.prototype.$notification.defaultConfig, config) + notification.success(config) + }, + warning: (config) => { + Vue.prototype.$notification.setCountNotify() + config = Object.assign({}, Vue.prototype.$notification.defaultConfig, config) + notification.warning(config) + }, + warn: (config) => { + Vue.prototype.$notification.setCountNotify() + config = Object.assign({}, Vue.prototype.$notification.defaultConfig, config) + notification.warn(config) + }, + close: (key) => notification.close(key), + destroy: () => notification.destroy() } } } diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue index 705a439..4c128a7 100644 --- a/ui/src/views/AutogenView.vue +++ b/ui/src/views/AutogenView.vue @@ -1128,8 +1128,7 @@ export default { if (action.response) { const description = action.response(result.jobresult) if (description) { - this.$showNotification({ - type: 'info', + this.$notification.info({ message: this.$t(action.label), description: (<span domPropsInnerHTML={description}></span>), duration: 0 diff --git a/ui/src/views/compute/AssignInstance.vue b/ui/src/views/compute/AssignInstance.vue index bba7ee4..9341064 100644 --- a/ui/src/views/compute/AssignInstance.vue +++ b/ui/src/views/compute/AssignInstance.vue @@ -294,8 +294,7 @@ export default { [variableKey]: variableValue, networkids: this.selectedNetwork }).then(response => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.loadbalancerinstance') }) this.$parent.$parent.close() diff --git a/ui/src/views/compute/ChangeAffinity.vue b/ui/src/views/compute/ChangeAffinity.vue index 5f97c25..d1dabeb 100644 --- a/ui/src/views/compute/ChangeAffinity.vue +++ b/ui/src/views/compute/ChangeAffinity.vue @@ -149,8 +149,7 @@ export default { id: this.resource.id, affinitygroupids: this.selectedRowKeys.join(',') }).then(response => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('message.success.change.affinity.group') }) this.$parent.$parent.close() diff --git a/ui/src/views/compute/CreateSSHKeyPair.vue b/ui/src/views/compute/CreateSSHKeyPair.vue index f244fe2..15a6f97 100644 --- a/ui/src/views/compute/CreateSSHKeyPair.vue +++ b/ui/src/views/compute/CreateSSHKeyPair.vue @@ -198,8 +198,7 @@ export default { this.hiddenElement.click() }, notifyCopied () { - this.$showNotification({ - type: 'info', + this.$notification.info({ message: this.$t('message.success.copy.clipboard') }) }, diff --git a/ui/src/views/compute/CreateSnapshotWizard.vue b/ui/src/views/compute/CreateSnapshotWizard.vue index 061fa87..ed4fbc9 100644 --- a/ui/src/views/compute/CreateSnapshotWizard.vue +++ b/ui/src/views/compute/CreateSnapshotWizard.vue @@ -141,8 +141,7 @@ export default { const volumeId = result.jobresult.snapshot.volumeid const snapshotId = result.jobresult.snapshot.id const message = `${this.$t('label.create.snapshot.for.volume')} ${volumeId} ${this.$t('label.with.snapshotid')} ${snapshotId}` - this.$showNotification({ - type: 'success', + this.$notification.success({ message: message, duration: 0 }) diff --git a/ui/src/views/compute/DeployVM.vue b/ui/src/views/compute/DeployVM.vue index 37008fc..bc59d58 100644 --- a/ui/src/views/compute/DeployVM.vue +++ b/ui/src/views/compute/DeployVM.vue @@ -1491,7 +1491,7 @@ export default { this.form.validateFieldsAndScroll(options, async (err, values) => { if (err) { if (err.licensesaccepted) { - this.$showNotification({ + this.$notification.error({ type: 'error', message: this.$t('message.license.agreements.not.accepted'), description: this.$t('message.step.license.agreements.continue') @@ -1499,8 +1499,7 @@ export default { return } - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: this.$t('error.form.message') }) @@ -1508,31 +1507,27 @@ export default { } if (!values.templateid && !values.isoid) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: this.$t('message.template.iso') }) return } else if (values.isoid && (!values.diskofferingid || values.diskofferingid === '0')) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: this.$t('message.step.3.continue') }) return } if (!values.computeofferingid) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: this.$t('message.step.2.continue') }) return } if (this.error) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: this.$t('error.form.message') }) @@ -1645,8 +1640,7 @@ export default { } } } else { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: this.$t('message.step.4.continue') }) @@ -1708,8 +1702,7 @@ export default { const vm = result.jobresult.virtualmachine const name = vm.displayname || vm.name || vm.id if (vm.password) { - this.$showNotification({ - type: 'success', + this.$notification.error({ message: password + ` ${this.$t('label.for')} ` + name, description: vm.password, duration: 0 diff --git a/ui/src/views/compute/KubernetesServiceTab.vue b/ui/src/views/compute/KubernetesServiceTab.vue index 55254dd..97f1c54 100644 --- a/ui/src/views/compute/KubernetesServiceTab.vue +++ b/ui/src/views/compute/KubernetesServiceTab.vue @@ -321,8 +321,7 @@ export default { config.configdata !== '') { this.clusterConfig = config.configdata } else { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: this.$t('message.error.retrieve.kubeconfig') }) diff --git a/ui/src/views/compute/MigrateWizard.vue b/ui/src/views/compute/MigrateWizard.vue index 39493b8..3107998 100644 --- a/ui/src/views/compute/MigrateWizard.vue +++ b/ui/src/views/compute/MigrateWizard.vue @@ -220,8 +220,7 @@ export default { }) this.$emit('close-action') }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message, duration: 0 diff --git a/ui/src/views/compute/ScaleVM.vue b/ui/src/views/compute/ScaleVM.vue index 4a9087d..a0cf5b1 100644 --- a/ui/src/views/compute/ScaleVM.vue +++ b/ui/src/views/compute/ScaleVM.vue @@ -166,8 +166,7 @@ export default { this.$pollJob({ jobId, successMethod: result => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('message.success.change.offering') }) }, diff --git a/ui/src/views/compute/StartVirtualMachine.vue b/ui/src/views/compute/StartVirtualMachine.vue index d751545..db8412c 100644 --- a/ui/src/views/compute/StartVirtualMachine.vue +++ b/ui/src/views/compute/StartVirtualMachine.vue @@ -143,8 +143,7 @@ export default { api('listPods', params).then(json => { this.pods = json.listpodsresponse.pod || [] if (this.pods.length === 0) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: 'No pods found', duration: 0 }) @@ -163,8 +162,7 @@ export default { api('listClusters', params).then(json => { this.clusters = json.listclustersresponse.cluster || [] if (this.clusters.length === 0) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: 'No clusters found', duration: 0 }) @@ -186,8 +184,7 @@ export default { api('listHosts', params).then(json => { this.hosts = json.listhostsresponse.host || [] if (this.hosts.length === 0) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: 'No hosts found', duration: 0 }) diff --git a/ui/src/views/compute/backup/BackupSchedule.vue b/ui/src/views/compute/backup/BackupSchedule.vue index d1d78d8..66b7dc7 100644 --- a/ui/src/views/compute/backup/BackupSchedule.vue +++ b/ui/src/views/compute/backup/BackupSchedule.vue @@ -157,8 +157,7 @@ export default { this.actionLoading = true api('deleteBackupSchedule', params).then(json => { if (json.deletebackupscheduleresponse.success) { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.scheduled.backups'), description: this.$t('message.success.delete.backup.schedule') }) diff --git a/ui/src/views/compute/backup/FormSchedule.vue b/ui/src/views/compute/backup/FormSchedule.vue index ffac01c..1220315 100644 --- a/ui/src/views/compute/backup/FormSchedule.vue +++ b/ui/src/views/compute/backup/FormSchedule.vue @@ -284,8 +284,7 @@ export default { } this.actionLoading = true api('createBackupSchedule', params).then(json => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.scheduled.backups'), description: this.$t('message.success.config.backup.schedule') }) diff --git a/ui/src/views/iam/AddAccount.vue b/ui/src/views/iam/AddAccount.vue index 864e4a1..940adde 100644 --- a/ui/src/views/iam/AddAccount.vue +++ b/ui/src/views/iam/AddAccount.vue @@ -266,8 +266,7 @@ export default { this.domainsList = response.listdomainsresponse.domain || [] this.selectedDomain = this.domainsList[0].id || '' }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.errorresponse.errortext }) @@ -342,8 +341,7 @@ export default { api('createAccount', {}, 'POST', params).then(response => { this.$emit('refresh-data') - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.create.account'), description: `${this.$t('message.success.create.account')} ${params.username}` }) @@ -355,14 +353,12 @@ export default { entityid: values.samlentity, userid: users[i].id }).then(response => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.samlenable'), description: this.$t('message.success.enable.saml.auth') }) }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message, duration: 0 @@ -372,8 +368,7 @@ export default { } this.closeAction() }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message, duration: 0 diff --git a/ui/src/views/iam/AddLdapAccount.vue b/ui/src/views/iam/AddLdapAccount.vue index 821ff31..982cebd 100644 --- a/ui/src/views/iam/AddLdapAccount.vue +++ b/ui/src/views/iam/AddLdapAccount.vue @@ -410,15 +410,13 @@ export default { this.authorizeUsersForSamlSSO(users, entityId) } } else if (apiName === 'importLdapUsers' && response.ldapuserresponse && values.samlEnable) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: this.$t('message.error.enable.saml') }) } else { if (apiName === 'ldapCreateAccount') { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.add.ldap.account'), description: response.createaccountresponse.account.name }) diff --git a/ui/src/views/iam/AddUser.vue b/ui/src/views/iam/AddUser.vue index 4b4c0ce..f57585c 100644 --- a/ui/src/views/iam/AddUser.vue +++ b/ui/src/views/iam/AddUser.vue @@ -238,8 +238,7 @@ export default { this.domainsList = response.listdomainsresponse.domain || [] this.selectedDomain = this.domainsList[0].id || '' }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.errorresponse.errortext }) @@ -253,8 +252,7 @@ export default { api('listAccounts', { listAll: true, showicon: true }).then(response => { this.accountList = response.listaccountsresponse.account || [] }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.errorresponse.errortext }) @@ -321,8 +319,7 @@ export default { api('createUser', {}, 'POST', params).then(response => { this.$emit('refresh-data') - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.create.user'), description: `${this.$t('message.success.create.user')} ${params.username}` }) @@ -333,14 +330,12 @@ export default { entityid: values.samlentity, userid: user.id }).then(response => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.samlenable'), description: this.$t('message.success.enable.saml.auth') }) }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message, duration: 0 @@ -349,8 +344,7 @@ export default { } this.closeAction() }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message, duration: 0 diff --git a/ui/src/views/iam/ChangeUserPassword.vue b/ui/src/views/iam/ChangeUserPassword.vue index 3e19738..ae74535 100644 --- a/ui/src/views/iam/ChangeUserPassword.vue +++ b/ui/src/views/iam/ChangeUserPassword.vue @@ -128,8 +128,7 @@ export default { params.currentpassword = values.currentpassword } api('updateUser', {}, 'POST', params).then(json => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.action.change.password'), description: `${this.$t('message.success.change.password')} ${this.resource.username}` }) diff --git a/ui/src/views/iam/ConfigureSamlSsoAuth.vue b/ui/src/views/iam/ConfigureSamlSsoAuth.vue index 34f9254..63ba49a 100644 --- a/ui/src/views/iam/ConfigureSamlSsoAuth.vue +++ b/ui/src/views/iam/ConfigureSamlSsoAuth.vue @@ -108,16 +108,14 @@ export default { userid: this.resource.id, entityid: values.samlEntity }).then(response => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: values.samlEnable ? this.$t('label.saml.enable') : this.$t('label.saml.disable'), description: values.samlEnable ? `${this.$t('message.success.enable.saml.auth')} ${this.$t('label.for')} ${this.resource.username}` : `${this.$t('message.success.disable.saml.auth')} ${this.$t('label.for')} ${this.resource.username}` }) this.handleClose() }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message, duration: 0 diff --git a/ui/src/views/iam/CreateRole.vue b/ui/src/views/iam/CreateRole.vue index 88c42b9..9b80397 100644 --- a/ui/src/views/iam/CreateRole.vue +++ b/ui/src/views/iam/CreateRole.vue @@ -174,8 +174,7 @@ export default { const role = json.createroleresponse.role if (role) { this.$emit('refresh-data') - this.$showNotification({ - type: 'success', + this.$notification.success({ message: 'Create Role', description: 'Sucessfully created role ' + params.name }) diff --git a/ui/src/views/iam/DomainActionForm.vue b/ui/src/views/iam/DomainActionForm.vue index ae5b069..1696d52 100644 --- a/ui/src/views/iam/DomainActionForm.vue +++ b/ui/src/views/iam/DomainActionForm.vue @@ -253,8 +253,7 @@ export default { if (this.action.response) { const description = this.action.response(result.jobresult) if (description) { - this.$showNotification({ - type: 'info', + this.$notification.info({ message: this.$t(this.action.label), description: (<span domPropsInnerHTML={description}></span>), duration: 0 @@ -290,8 +289,7 @@ export default { } this.parentCloseAction() }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message }) diff --git a/ui/src/views/iam/DomainView.vue b/ui/src/views/iam/DomainView.vue index 6f11967..e69edc5 100644 --- a/ui/src/views/iam/DomainView.vue +++ b/ui/src/views/iam/DomainView.vue @@ -187,8 +187,7 @@ export default { return } - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: error.response.headers['x-description'], duration: 0 diff --git a/ui/src/views/iam/EditUser.vue b/ui/src/views/iam/EditUser.vue index dedfcfd..7009e01 100644 --- a/ui/src/views/iam/EditUser.vue +++ b/ui/src/views/iam/EditUser.vue @@ -178,15 +178,13 @@ export default { api('updateUser', params).then(response => { this.$emit('refresh-data') - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.edit.user'), description: `${this.$t('message.success.update.user')} ${params.username}` }) this.closeAction() }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message, duration: 0 diff --git a/ui/src/views/iam/ImportRole.vue b/ui/src/views/iam/ImportRole.vue index 2e18873..b285ace 100644 --- a/ui/src/views/iam/ImportRole.vue +++ b/ui/src/views/iam/ImportRole.vue @@ -128,8 +128,7 @@ export default { }, handleChange (info) { if (info.file.status === 'error') { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('label.error.file.upload'), description: this.$t('label.error.file.upload') }) @@ -186,8 +185,7 @@ export default { const role = json.importroleresponse.role if (role) { this.$emit('refresh-data') - this.$showNotification({ - type: 'success', + this.$notification.success({ message: 'Import Role', description: 'Sucessfully imported role ' + params.name }) diff --git a/ui/src/views/image/IsoZones.vue b/ui/src/views/image/IsoZones.vue index 7396f35..f838262 100644 --- a/ui/src/views/image/IsoZones.vue +++ b/ui/src/views/image/IsoZones.vue @@ -455,8 +455,7 @@ export default { catchMessage: this.$t('error.fetching.async.job.result') }) }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message }) diff --git a/ui/src/views/image/RegisterOrUploadIso.vue b/ui/src/views/image/RegisterOrUploadIso.vue index 0c2ab4e..e4ab970 100644 --- a/ui/src/views/image/RegisterOrUploadIso.vue +++ b/ui/src/views/image/RegisterOrUploadIso.vue @@ -265,8 +265,7 @@ export default { handleUpload () { const { fileList } = this if (this.fileList.length > 1) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.upload.iso.failed'), description: this.$t('message.error.upload.iso.description'), duration: 0 @@ -291,16 +290,14 @@ export default { }, timeout: 86400000 }).then((json) => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('message.success.upload'), description: this.$t('message.success.upload.description') }) this.closeAction() this.$emit('refresh-data') }).catch(e => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.upload.failed'), description: `${this.$t('message.upload.iso.failed.description')} - ${e}`, duration: 0 @@ -345,8 +342,7 @@ export default { if (this.currentForm === 'Create') { this.loading = true api('registerIso', params).then(json => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.action.register.iso'), description: `${this.$t('message.success.register.iso')} ${params.name}` }) @@ -367,8 +363,7 @@ export default { this.uploadParams = (json.postuploadisoresponse && json.postuploadisoresponse.getuploadparams) ? json.postuploadisoresponse.getuploadparams : '' const response = this.handleUpload() if (response === 'upload successful') { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('message.success.upload'), description: this.$t('message.success.upload.iso.description') }) diff --git a/ui/src/views/image/RegisterOrUploadTemplate.vue b/ui/src/views/image/RegisterOrUploadTemplate.vue index ce9ea56..c411601 100644 --- a/ui/src/views/image/RegisterOrUploadTemplate.vue +++ b/ui/src/views/image/RegisterOrUploadTemplate.vue @@ -511,16 +511,14 @@ export default { }, timeout: 86400000 }).then((json) => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('message.success.upload'), description: this.$t('message.success.upload.template.description') }) this.$emit('refresh-data') this.closeAction() }).catch(e => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.upload.failed'), description: `${this.$t('message.upload.template.failed.description')} - ${e}`, duration: 0 @@ -889,8 +887,7 @@ export default { if (this.currentForm === 'Create') { this.loading = true api('registerTemplate', params).then(json => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.register.template'), description: `${this.$t('message.success.register.template')} ${params.name}` }) @@ -904,8 +901,7 @@ export default { } else { this.loading = true if (this.fileList.length > 1) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.error.upload.template'), description: this.$t('message.error.upload.template.description'), duration: 0 diff --git a/ui/src/views/image/TemplateZones.vue b/ui/src/views/image/TemplateZones.vue index bc5d72d..ca83293 100644 --- a/ui/src/views/image/TemplateZones.vue +++ b/ui/src/views/image/TemplateZones.vue @@ -554,8 +554,7 @@ export default { catchMessage: this.$t('error.fetching.async.job.result') }) }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message }) diff --git a/ui/src/views/image/UpdateTemplateIsoPermissions.vue b/ui/src/views/image/UpdateTemplateIsoPermissions.vue index f27e72e..f731f7e 100644 --- a/ui/src/views/image/UpdateTemplateIsoPermissions.vue +++ b/ui/src/views/image/UpdateTemplateIsoPermissions.vue @@ -289,8 +289,7 @@ export default { featured: this.resource.featured, op: this.selectedOperation.toLowerCase() }).then(response => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: `${this.$t('label.success.updated')} ${resourceType} ${this.$t('label.permissions')}` }) this.closeModal() diff --git a/ui/src/views/infra/AddPrimaryStorage.vue b/ui/src/views/infra/AddPrimaryStorage.vue index 461af06..dbab19e 100644 --- a/ui/src/views/infra/AddPrimaryStorage.vue +++ b/ui/src/views/infra/AddPrimaryStorage.vue @@ -709,8 +709,7 @@ export default { } this.loading = true api('createStoragePool', {}, 'POST', params).then(json => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.add.primary.storage'), description: this.$t('label.add.primary.storage') }) diff --git a/ui/src/views/infra/AddSecondaryStorage.vue b/ui/src/views/infra/AddSecondaryStorage.vue index e57e016..0d34e6f 100644 --- a/ui/src/views/infra/AddSecondaryStorage.vue +++ b/ui/src/views/infra/AddSecondaryStorage.vue @@ -293,8 +293,7 @@ export default { this.loading = true api('addImageStore', data).then(json => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.add.secondary.storage'), description: this.$t('label.add.secondary.storage') }) diff --git a/ui/src/views/infra/ClusterAdd.vue b/ui/src/views/infra/ClusterAdd.vue index 8e66428..d3c25c6 100644 --- a/ui/src/views/infra/ClusterAdd.vue +++ b/ui/src/views/infra/ClusterAdd.vue @@ -257,8 +257,7 @@ export default { } this.addCluster() }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.listvmwaredcsresponse.errortext, duration: 0 @@ -309,8 +308,7 @@ export default { this.parentToggleLoading() this.$parent.$parent.close() }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.addclusterresponse.errortext, duration: 0 @@ -345,8 +343,7 @@ export default { } }) }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.errorresponse.errortext, duration: 0 diff --git a/ui/src/views/infra/HostAdd.vue b/ui/src/views/infra/HostAdd.vue index 1003031..e4edfbc 100644 --- a/ui/src/views/infra/HostAdd.vue +++ b/ui/src/views/infra/HostAdd.vue @@ -362,8 +362,7 @@ export default { this.parentFetchData() this.$parent.$parent.close() }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.addhostresponse.errortext, duration: 0 @@ -398,8 +397,7 @@ export default { } }) }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.errorresponse.errortext, duration: 0 diff --git a/ui/src/views/infra/InfraSummary.vue b/ui/src/views/infra/InfraSummary.vue index 6953419..5656dc5 100644 --- a/ui/src/views/infra/InfraSummary.vue +++ b/ui/src/views/infra/InfraSummary.vue @@ -241,14 +241,12 @@ export default { const result = json.queryasyncjobresultresponse if (result.jobstatus === 1 && this.maxCerts === count) { this.$message.success(`${this.$t('label.certificate.upload')}: ${result.jobresult.customcertificate.message}`) - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.certificate.upload'), description: result.jobresult.customcertificate.message || this.$t('message.success.certificate.upload') }) } else if (result.jobstatus === 2) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('label.certificate.upload.failed'), description: result.jobresult.errortext || this.$t('label.certificate.upload.failed.description'), duration: 0 diff --git a/ui/src/views/infra/MigrateData.vue b/ui/src/views/infra/MigrateData.vue index 6d1af24..6ebe653 100644 --- a/ui/src/views/infra/MigrateData.vue +++ b/ui/src/views/infra/MigrateData.vue @@ -154,14 +154,12 @@ export default { const success = result.imagestore.success || false const message = result.imagestore.message || '' if (success) { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: title, description: message }) } else { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: title, description: message, duration: 0 diff --git a/ui/src/views/infra/PodAdd.vue b/ui/src/views/infra/PodAdd.vue index 8434be6..1fffa56 100644 --- a/ui/src/views/infra/PodAdd.vue +++ b/ui/src/views/infra/PodAdd.vue @@ -207,8 +207,7 @@ export default { this.parentFetchData() this.$parent.$parent.close() }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.createpodresponse.errortext, duration: 0 @@ -243,8 +242,7 @@ export default { } }) }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.errorresponse.errortext, duration: 0 diff --git a/ui/src/views/infra/network/DedicatedVLANTab.vue b/ui/src/views/infra/network/DedicatedVLANTab.vue index 1aca626..a2b5e55 100644 --- a/ui/src/views/infra/network/DedicatedVLANTab.vue +++ b/ui/src/views/infra/network/DedicatedVLANTab.vue @@ -254,8 +254,7 @@ export default { this.items = response.listdedicatedguestvlanrangesresponse.dedicatedguestvlanrange || [] this.totalCount = response.listdedicatedguestvlanrangesresponse.count || 0 }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.errorresponse.errortext, duration: 0 diff --git a/ui/src/views/infra/network/EditTrafficLabel.vue b/ui/src/views/infra/network/EditTrafficLabel.vue index 4afe9a0..a56165e 100644 --- a/ui/src/views/infra/network/EditTrafficLabel.vue +++ b/ui/src/views/infra/network/EditTrafficLabel.vue @@ -133,8 +133,7 @@ export default { this.traffictype = this.trafficTypes[0].traffictype || undefined }) .catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.errorresponse.errortext }) diff --git a/ui/src/views/infra/network/IpRangesTabPublic.vue b/ui/src/views/infra/network/IpRangesTabPublic.vue index c94223a..ff1976f 100644 --- a/ui/src/views/infra/network/IpRangesTabPublic.vue +++ b/ui/src/views/infra/network/IpRangesTabPublic.vue @@ -504,8 +504,7 @@ export default { handleDeleteIpRange (id) { this.componentLoading = true api('deleteVlanIpRange', { id }).then(() => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: 'Removed IP Range' }) }).catch(error => { @@ -541,13 +540,11 @@ export default { params.networkid = this.network.id } api('createVlanIpRange', params).then(() => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('message.success.add.iprange') }) }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.createvlaniprangeresponse ? error.response.data.createvlaniprangeresponse.errortext : error.response.data.errorresponse.errortext, @@ -575,13 +572,11 @@ export default { forsystemvms: values.forsystemvms } api('updateVlanIpRange', params).then(() => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('message.success.update.iprange') }) }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.updatevlaniprangeresponse ? error.response.data.updatevlaniprangeresponse.errortext : error.response.data.errorresponse.errortext, diff --git a/ui/src/views/infra/network/ServiceProvidersTab.vue b/ui/src/views/infra/network/ServiceProvidersTab.vue index c8f6bbd..1017621 100644 --- a/ui/src/views/infra/network/ServiceProvidersTab.vue +++ b/ui/src/views/infra/network/ServiceProvidersTab.vue @@ -1219,8 +1219,7 @@ export default { this.onCloseAction() } catch (error) { this.actionLoading = false - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: error }) @@ -1356,8 +1355,7 @@ export default { this.onCloseAction() } catch (message) { this.actionLoading = false - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: message }) diff --git a/ui/src/views/infra/network/providers/AddF5LoadBalancer.vue b/ui/src/views/infra/network/providers/AddF5LoadBalancer.vue index d10e570..227520c 100644 --- a/ui/src/views/infra/network/providers/AddF5LoadBalancer.vue +++ b/ui/src/views/infra/network/providers/AddF5LoadBalancer.vue @@ -253,8 +253,7 @@ export default { this.loading = false } catch (error) { this.loading = false - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message }) diff --git a/ui/src/views/infra/network/providers/AddNetscalerLoadBalancer.vue b/ui/src/views/infra/network/providers/AddNetscalerLoadBalancer.vue index 41f0b6d..7e12f54 100644 --- a/ui/src/views/infra/network/providers/AddNetscalerLoadBalancer.vue +++ b/ui/src/views/infra/network/providers/AddNetscalerLoadBalancer.vue @@ -288,8 +288,7 @@ export default { this.loading = false } catch (error) { this.loading = false - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message }) diff --git a/ui/src/views/infra/network/providers/AddNiciraNvpDevice.vue b/ui/src/views/infra/network/providers/AddNiciraNvpDevice.vue index 512da75..60a33b5 100644 --- a/ui/src/views/infra/network/providers/AddNiciraNvpDevice.vue +++ b/ui/src/views/infra/network/providers/AddNiciraNvpDevice.vue @@ -160,8 +160,7 @@ export default { this.loading = false } catch (error) { this.loading = false - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message }) diff --git a/ui/src/views/infra/network/providers/AddPaloAltoFirewall.vue b/ui/src/views/infra/network/providers/AddPaloAltoFirewall.vue index a8c8db9..aff9d57 100644 --- a/ui/src/views/infra/network/providers/AddPaloAltoFirewall.vue +++ b/ui/src/views/infra/network/providers/AddPaloAltoFirewall.vue @@ -377,8 +377,7 @@ export default { this.loading = false } catch (error) { this.loading = false - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message }) diff --git a/ui/src/views/infra/network/providers/AddSrxFirewall.vue b/ui/src/views/infra/network/providers/AddSrxFirewall.vue index 6c4b679..8a61d5f 100644 --- a/ui/src/views/infra/network/providers/AddSrxFirewall.vue +++ b/ui/src/views/infra/network/providers/AddSrxFirewall.vue @@ -322,8 +322,7 @@ export default { this.loading = false } catch (error) { this.loading = false - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message }) diff --git a/ui/src/views/infra/network/providers/ProviderItem.vue b/ui/src/views/infra/network/providers/ProviderItem.vue index ec4a84e..73931bd 100644 --- a/ui/src/views/infra/network/providers/ProviderItem.vue +++ b/ui/src/views/infra/network/providers/ProviderItem.vue @@ -188,8 +188,7 @@ export default { this.listData[args.title].loading = false } catch (error) { this.listData[args.title].loading = false - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message }) diff --git a/ui/src/views/infra/network/providers/ProviderListView.vue b/ui/src/views/infra/network/providers/ProviderListView.vue index a1a498b..ac23545 100644 --- a/ui/src/views/infra/network/providers/ProviderListView.vue +++ b/ui/src/views/infra/network/providers/ProviderListView.vue @@ -300,8 +300,7 @@ export default { this.actionLoading = false } catch (error) { this.actionLoading = false - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message }) @@ -337,8 +336,7 @@ export default { this.actionLoading = false } catch (error) { this.actionLoading = false - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message }) diff --git a/ui/src/views/infra/zone/ZoneWizardLaunchZone.vue b/ui/src/views/infra/zone/ZoneWizardLaunchZone.vue index 9831e6d..eb18181 100644 --- a/ui/src/views/infra/zone/ZoneWizardLaunchZone.vue +++ b/ui/src/views/infra/zone/ZoneWizardLaunchZone.vue @@ -1547,8 +1547,7 @@ export default { this.$emit('refresh-data') } catch (e) { this.loading = false - await this.$showNotification({ - type: 'error', + await this.$notification.error({ message: this.$t('message.request.failed'), description: e }) diff --git a/ui/src/views/network/AclListRulesTab.vue b/ui/src/views/network/AclListRulesTab.vue index e47dddf..673d338 100644 --- a/ui/src/views/network/AclListRulesTab.vue +++ b/ui/src/views/network/AclListRulesTab.vue @@ -571,8 +571,7 @@ export default { data.aclid = this.resource.id api('createNetworkACL', {}, 'POST', data).then(() => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.success'), description: this.$t('message.success.add.rule') }) diff --git a/ui/src/views/network/CreateIsolatedNetworkForm.vue b/ui/src/views/network/CreateIsolatedNetworkForm.vue index 58ae028..1f71771 100644 --- a/ui/src/views/network/CreateIsolatedNetworkForm.vue +++ b/ui/src/views/network/CreateIsolatedNetworkForm.vue @@ -442,8 +442,7 @@ export default { } } api('createNetwork', params).then(json => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: 'Network', description: this.$t('message.success.create.isolated.network') }) diff --git a/ui/src/views/network/CreateL2NetworkForm.vue b/ui/src/views/network/CreateL2NetworkForm.vue index 8243226..32c394f 100644 --- a/ui/src/views/network/CreateL2NetworkForm.vue +++ b/ui/src/views/network/CreateL2NetworkForm.vue @@ -393,8 +393,7 @@ export default { } } api('createNetwork', params).then(json => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: 'Network', description: this.$t('message.success.create.l2.network') }) diff --git a/ui/src/views/network/CreateSharedNetworkForm.vue b/ui/src/views/network/CreateSharedNetworkForm.vue index 554b6f6..79af46d 100644 --- a/ui/src/views/network/CreateSharedNetworkForm.vue +++ b/ui/src/views/network/CreateSharedNetworkForm.vue @@ -703,8 +703,7 @@ export default { !this.isValidTextValueForKey(values, 'ip6gateway') && !this.isValidTextValueForKey(values, 'ip6cidr') && !this.isValidTextValueForKey(values, 'startipv6') && !this.isValidTextValueForKey(values, 'endipv6')) ) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: this.$t('message.error.add.guest.network') }) @@ -789,8 +788,7 @@ export default { params.hideipaddressusage = true } api('createNetwork', params).then(json => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.network'), description: this.$t('message.success.add.guest.network') }) diff --git a/ui/src/views/network/CreateVlanIpRange.vue b/ui/src/views/network/CreateVlanIpRange.vue index 59fba39..71a7f06 100644 --- a/ui/src/views/network/CreateVlanIpRange.vue +++ b/ui/src/views/network/CreateVlanIpRange.vue @@ -248,15 +248,13 @@ export default { api('createVlanIpRange', params) .then(() => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('message.success.add.iprange') }) this.closeAction() this.$emit('refresh-data') }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.createvlaniprangeresponse ? error.response.data.createvlaniprangeresponse.errortext : error.response.data.errorresponse.errortext, diff --git a/ui/src/views/network/InternalLBAssignVmForm.vue b/ui/src/views/network/InternalLBAssignVmForm.vue index cb07fa4..ff68940 100644 --- a/ui/src/views/network/InternalLBAssignVmForm.vue +++ b/ui/src/views/network/InternalLBAssignVmForm.vue @@ -223,8 +223,7 @@ export default { }) this.closeModal() }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.errorresponse.errortext, duration: 0 diff --git a/ui/src/views/network/IpAddressesTab.vue b/ui/src/views/network/IpAddressesTab.vue index ebea8d4..65c6933 100644 --- a/ui/src/views/network/IpAddressesTab.vue +++ b/ui/src/views/network/IpAddressesTab.vue @@ -359,8 +359,7 @@ export default { }) this.onCloseModal() }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.errorresponse.errortext, duration: 0 @@ -427,8 +426,7 @@ export default { }) }).catch(error => { this.fetchLoading = false - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.errorresponse.errortext, duration: 0 diff --git a/ui/src/views/network/VpcTiersTab.vue b/ui/src/views/network/VpcTiersTab.vue index a788170..25dee12 100644 --- a/ui/src/views/network/VpcTiersTab.vue +++ b/ui/src/views/network/VpcTiersTab.vue @@ -664,8 +664,7 @@ export default { } api('createNetwork', params).then(() => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('message.success.add.vpc.network') }) }).catch(error => { diff --git a/ui/src/views/network/VpnDetails.vue b/ui/src/views/network/VpnDetails.vue index d0633a2..7f112fe 100644 --- a/ui/src/views/network/VpnDetails.vue +++ b/ui/src/views/network/VpnDetails.vue @@ -132,8 +132,7 @@ export default { jobId: response.createremoteaccessvpnresponse.jobid, successMethod: result => { const res = result.jobresult.remoteaccessvpn - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.status'), description: `${this.$t('message.enabled.vpn')} ${res.publicip}. ${this.$t('message.enabled.vpn.ip.sec')} ${res.presharedkey}`, diff --git a/ui/src/views/offering/UpdateOfferingAccess.vue b/ui/src/views/offering/UpdateOfferingAccess.vue index 6162319..8ad7b11 100644 --- a/ui/src/views/offering/UpdateOfferingAccess.vue +++ b/ui/src/views/offering/UpdateOfferingAccess.vue @@ -297,8 +297,7 @@ export default { this.loading = true api('update' + this.offeringType, params).then(json => { this.$emit('refresh-data') - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.action.update.offering.access'), description: this.$t('label.action.update.offering.access') }) diff --git a/ui/src/views/plugins/quota/EditTariffValueWizard.vue b/ui/src/views/plugins/quota/EditTariffValueWizard.vue index 32a3795..ef02b0c 100644 --- a/ui/src/views/plugins/quota/EditTariffValueWizard.vue +++ b/ui/src/views/plugins/quota/EditTariffValueWizard.vue @@ -125,8 +125,7 @@ export default { this.$message.success(`${this.$t('message.setting.updated')} ${this.resource.description}`) this.onClose() }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message }) diff --git a/ui/src/views/project/iam/ProjectRoleTab.vue b/ui/src/views/project/iam/ProjectRoleTab.vue index 001cc9d..befbd69 100644 --- a/ui/src/views/project/iam/ProjectRoleTab.vue +++ b/ui/src/views/project/iam/ProjectRoleTab.vue @@ -229,8 +229,7 @@ export default { params[key] = input } api('updateProjectRole', params).then(response => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.update.project.role'), description: this.$t('label.update.project.role') }) @@ -269,8 +268,7 @@ export default { params[key] = input } api('createProjectRole', params).then(response => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.create.project.role'), description: this.$t('label.create.project.role') }) @@ -289,8 +287,7 @@ export default { projectid: this.resource.id, id: role.id }).then(response => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.delete.project.role'), description: this.$t('label.delete.project.role') }) diff --git a/ui/src/views/storage/FormSchedule.vue b/ui/src/views/storage/FormSchedule.vue index 09c5035..4416328 100644 --- a/ui/src/views/storage/FormSchedule.vue +++ b/ui/src/views/storage/FormSchedule.vue @@ -385,8 +385,7 @@ export default { this.actionLoading = true api('createSnapshotPolicy', params).then(json => { this.$emit('refresh') - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.action.recurring.snapshot'), description: this.$t('message.success.recurring.snapshot') }) diff --git a/ui/src/views/storage/ResizeVolume.vue b/ui/src/views/storage/ResizeVolume.vue index 369067f..8c23fa3 100644 --- a/ui/src/views/storage/ResizeVolume.vue +++ b/ui/src/views/storage/ResizeVolume.vue @@ -125,8 +125,7 @@ export default { }) this.closeModal() }).catch(error => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: `${this.$t('label.error')} ${error.response.status}`, description: error.response.data.errorresponse.errortext, duration: 0 diff --git a/ui/src/views/storage/ScheduledSnapshots.vue b/ui/src/views/storage/ScheduledSnapshots.vue index ea1f429..fc1610f 100644 --- a/ui/src/views/storage/ScheduledSnapshots.vue +++ b/ui/src/views/storage/ScheduledSnapshots.vue @@ -162,8 +162,7 @@ export default { this.actionLoading = true api('deleteSnapshotPolicies', params).then(json => { if (json.deletesnapshotpoliciesresponse.success) { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('label.delete.snapshot.policy'), description: this.$t('message.success.delete.snapshot.policy') }) diff --git a/ui/src/views/storage/UploadLocalVolume.vue b/ui/src/views/storage/UploadLocalVolume.vue index 5388aca..c4f1d56 100644 --- a/ui/src/views/storage/UploadLocalVolume.vue +++ b/ui/src/views/storage/UploadLocalVolume.vue @@ -191,8 +191,7 @@ export default { this.uploadParams = (json.postuploadvolumeresponse && json.postuploadvolumeresponse.getuploadparams) ? json.postuploadvolumeresponse.getuploadparams : '' const { fileList } = this if (this.fileList.length > 1) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.upload.volume.failed'), description: this.$t('message.upload.file.limit'), duration: 0 @@ -217,15 +216,13 @@ export default { }, timeout: 86400000 }).then((json) => { - this.$showNotification({ - type: 'success', + this.$notification.success({ message: this.$t('message.success.upload'), description: this.$t('message.success.upload.volume.description') }) this.closeAction() }).catch(e => { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.upload.failed'), description: `${this.$t('message.upload.iso.failed.description')} - ${e}`, duration: 0 diff --git a/ui/src/views/tools/ImportUnmanagedInstance.vue b/ui/src/views/tools/ImportUnmanagedInstance.vue index 77788c0..ecde62f 100644 --- a/ui/src/views/tools/ImportUnmanagedInstance.vue +++ b/ui/src/views/tools/ImportUnmanagedInstance.vue @@ -631,8 +631,7 @@ export default { displayname: values.displayname } if (!this.computeOffering || !this.computeOffering.id) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: this.$t('message.step.2.continue') }) @@ -643,8 +642,7 @@ export default { var details = [this.cpuNumberKey, this.cpuSpeedKey, this.memoryKey] for (var detail of details) { if (!(values[detail] || this.computeOffering[detail])) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: this.$t('message.please.enter.valid.value') + ': ' + this.$t('label.' + detail.toLowerCase()) }) @@ -659,8 +657,7 @@ export default { var iopsDetails = [this.minIopsKey, this.maxIopsKey] for (var iopsDetail of iopsDetails) { if (!values[iopsDetail] || values[iopsDetail] < 0) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: this.$t('message.please.enter.valid.value') + ': ' + this.$t('label.' + iopsDetail.toLowerCase()) }) @@ -669,8 +666,7 @@ export default { params['details[0].' + iopsDetail] = values[iopsDetail] } if (values[this.minIopsKey] > values[this.maxIopsKey]) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: this.$t('error.form.message') }) @@ -688,8 +684,7 @@ export default { var diskOfferingIndex = 0 for (var diskId in this.dataDisksOfferingsMapping) { if (!this.dataDisksOfferingsMapping[diskId]) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: this.$t('message.select.disk.offering') + ': ' + diskId }) @@ -703,8 +698,7 @@ export default { var nicIpIndex = 0 for (var nicId in this.nicsNetworksMapping) { if (!this.nicsNetworksMapping[nicId].network) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: this.$t('message.select.nic.network') + ': ' + nicId }) @@ -715,8 +709,7 @@ export default { nicNetworkIndex++ if ('ipAddress' in this.nicsNetworksMapping[nicId]) { if (!this.nicsNetworksMapping[nicId].ipAddress) { - this.$showNotification({ - type: 'error', + this.$notification.error({ message: this.$t('message.request.failed'), description: this.$t('message.enter.valid.nic.ip') + ': ' + nicId }) diff --git a/ui/tests/unit/views/AutogenView.spec.js b/ui/tests/unit/views/AutogenView.spec.js index f8a67cd..9a20a0a 100644 --- a/ui/tests/unit/views/AutogenView.spec.js +++ b/ui/tests/unit/views/AutogenView.spec.js @@ -52,14 +52,20 @@ mocks = { $notifyError: jest.fn((error) => { return error }), - $showNotification: jest.fn((option) => { - return { - type: option.type, - message: option.message, - description: 'test-description', - duration: option.duration - } - }), + $notification: { + error: jest.fn((option) => { + return option + }), + info: jest.fn((option) => { + return option + }), + success: jest.fn((option) => { + return option + }), + warning: jest.fn((option) => { + return option + }) + }, $message: { success: jest.fn((obj) => { return obj @@ -1570,7 +1576,7 @@ describe('Views > AutogenView.vue', () => { }) describe('pollActionCompletion()', () => { - it('check $showNotification when pollActionCompletion() is called with action is empty', (done) => { + it('check $notification when pollActionCompletion() is called with action is empty', (done) => { const mockData = { queryasyncjobresultresponse: { jobstatus: 1, @@ -1588,7 +1594,7 @@ describe('Views > AutogenView.vue', () => { wrapper.vm.pollActionCompletion(jobId, action) setTimeout(() => { - expect(mocks.$showNotification).not.toHaveBeenCalled() + expect(mocks.$notification.info).not.toHaveBeenCalled() expect(mockAxios).toHaveBeenCalled() expect(mockAxios).toHaveBeenCalledWith({ url: '/', @@ -1605,7 +1611,7 @@ describe('Views > AutogenView.vue', () => { }) }) - it('check $showNotification when pollActionCompletion() is called with action is not empty', (done) => { + it('check $notification when pollActionCompletion() is called with action is not empty', (done) => { const mockData = { queryasyncjobresultresponse: { jobstatus: 1, @@ -1626,9 +1632,8 @@ describe('Views > AutogenView.vue', () => { wrapper.vm.pollActionCompletion(jobId, action) setTimeout(() => { - expect(mocks.$showNotification).toHaveBeenCalled() - expect(mocks.$showNotification).toHaveLastReturnedWith({ - type: 'info', + expect(mocks.$notification.info).toHaveBeenCalled() + expect(mocks.$notification.info).toHaveLastReturnedWith({ message: 'test-name-en', description: 'test-description', duration: 0 diff --git a/ui/tests/unit/views/compute/MigrateWizard.spec.js b/ui/tests/unit/views/compute/MigrateWizard.spec.js index 6a99fc6..2ee6b8e 100644 --- a/ui/tests/unit/views/compute/MigrateWizard.spec.js +++ b/ui/tests/unit/views/compute/MigrateWizard.spec.js @@ -29,7 +29,20 @@ mocks = { $message: { error: jest.fn((message) => {}) }, - $showNotification: jest.fn((obj) => {}), + $notification: { + error: jest.fn((option) => { + return option + }), + info: jest.fn((option) => { + return option + }), + success: jest.fn((option) => { + return option + }), + warning: jest.fn((option) => { + return option + }) + }, $pollJob: jest.fn((obj) => { switch (obj.jobId) { case 'test-job-id-case-1': @@ -752,9 +765,8 @@ describe('Views > compute > MigrateWizard.vue', () => { await wrapper.vm.submitForm() setTimeout(() => { - expect(mocks.$showNotification).toHaveBeenCalled() - expect(mocks.$showNotification).toHaveBeenCalledWith({ - type: 'error', + expect(mocks.$notification.error).toHaveBeenCalled() + expect(mocks.$notification.error).toHaveBeenCalledWith({ message: i18n.t('message.request.failed'), description: 'Error: throw error message', duration: 0