diff --git a/pkg/harvester/l10n/en-us.yaml b/pkg/harvester/l10n/en-us.yaml index 6d527f74..46c93a43 100644 --- a/pkg/harvester/l10n/en-us.yaml +++ b/pkg/harvester/l10n/en-us.yaml @@ -190,12 +190,16 @@ harvester: title: Restart Virtual Machine tip: Restart the virtual machine for configuration changes to take effect. cancel: Save + notification: title: succeed: Succeed info: Info warning: Warning error: Error + restartRequired: + title: '{count} {count, plural, =1 {Virtual Machine is} other {Virtual Machines are}} Pending Restart' + message: 'Please restart { vmNames } to apply updated configurations' action: createVM: Create Virtual Machine start: Start diff --git a/pkg/harvester/list/kubevirt.io.virtualmachine.vue b/pkg/harvester/list/kubevirt.io.virtualmachine.vue index 357cc68d..989ac640 100644 --- a/pkg/harvester/list/kubevirt.io.virtualmachine.vue +++ b/pkg/harvester/list/kubevirt.io.virtualmachine.vue @@ -110,11 +110,12 @@ export default { data() { return { - hasNode: false, - allVMs: [], - allVMIs: [], - allNodeNetworks: [], - allClusterNetworks: [], + hasNode: false, + allVMs: [], + allVMIs: [], + allNodeNetworks: [], + allClusterNetworks: [], + restartNotificationDisplayed: false, HCI }; }, @@ -174,6 +175,48 @@ export default { this['allVMIs'] = vmis; }, + beforeUnmount() { + // clear restart message before component unmount + this.$store.dispatch('growl/clear'); + }, + + watch: { + allVMs: { + handler(neu) { + const vmNames = []; + + neu.forEach((vm) => { + if (vm.isRestartRequired) { + vmNames.push(vm.metadata.name); + } + }); + const count = vmNames.length; + + if ( count === 0 && this.restartNotificationDisplayed) { + this.restartNotificationDisplayed = false; + + return; + } + + if (count > 0) { + // clear old notification before showing new one + if (this.restartNotificationDisplayed) { + this.$store.dispatch('growl/clear'); + } + } + + if (count > 0 && vmNames.length > 0) { + this.$store.dispatch('growl/warning', { + title: this.t('harvester.notification.restartRequired.title', { count }), + message: this.t('harvester.notification.restartRequired.message', { vmNames: vmNames.join(', ') }), + timeout: 10000, + }, { root: true }); + this.restartNotificationDisplayed = true; + } + }, + deep: true, + } + }, methods: { lockIconTooltipMessage(row) { const message = ''; @@ -243,6 +286,12 @@ export default { + +