From feddcd247aef3b94aea66d3860093642f30b24c0 Mon Sep 17 00:00:00 2001 From: Yiya Chen Date: Fri, 6 Jun 2025 12:27:15 +0800 Subject: [PATCH] feat: add confirmation modal for vm soft reboot and restart (#327) * feat: add confirmation for vm softreboot and restart Signed-off-by: Yi-Ya Chen * refactor: update wordings Signed-off-by: Yi-Ya Chen * feat: handle bulk action Signed-off-by: Yi-Ya Chen --------- Signed-off-by: Yi-Ya Chen --- pkg/harvester/l10n/en-us.yaml | 11 ++++--- .../models/kubevirt.io.virtualmachine.js | 29 +++++++++++++------ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/pkg/harvester/l10n/en-us.yaml b/pkg/harvester/l10n/en-us.yaml index 34feb902..531284dc 100644 --- a/pkg/harvester/l10n/en-us.yaml +++ b/pkg/harvester/l10n/en-us.yaml @@ -49,9 +49,13 @@ dialog: } protip: "Tip: Hold the {alternateLabel} key while clicking action to bypass this confirmation" stop: - message: "Are you sure you want to continue stop the {type} {names}?" + message: "Are you sure you want to stop the {type} {names}?" pause: - message: "Are you sure you want to continue pause the {type} {names}?" + message: "Are you sure you want to pause the {type} {names}?" + restart: + message: "Are you sure you want to restart the {type} {names}?" + softreboot: + message: "Are you sure you want to soft reboot the {type} {names}?" promptRemove: title: "Delete {type}" warningMessage: "Deleting the selected {type} permanently removes all resources on {thisOrThese} {type}. This action is irreversible. Do you want to continue?" @@ -66,7 +70,6 @@ harvester: tip: 'Upload an icon to replace the Harvester favicon in the browser tab. Max file size is 20KB' productLabel: 'Harvester' modal: - backup: success: 'Backup { backUpName } has been initiated.' addBackup: Add Backup @@ -897,7 +900,7 @@ harvester: releaseTip: Please read the upgrade documentation carefully. You can view details on the Harvester Release Notes. checkReady: I have read and understood the upgrade instructions related to this Harvester version. pending: Pending - upload: + upload: duplicatedFile: The file you are trying to upload already exists. repoInfo: upgradeStatus: Upgrade Status diff --git a/pkg/harvester/models/kubevirt.io.virtualmachine.js b/pkg/harvester/models/kubevirt.io.virtualmachine.js index 770b546d..eaf9fb05 100644 --- a/pkg/harvester/models/kubevirt.io.virtualmachine.js +++ b/pkg/harvester/models/kubevirt.io.virtualmachine.js @@ -131,11 +131,12 @@ export default class VirtVm extends HarvesterResource { label: this.t('harvester.action.unpause') }, { - action: 'restartVM', - enabled: !!this.actions?.restart, - icon: 'icon icon-refresh', - label: this.t('harvester.action.restart'), - bulkable: true + action: 'restartVM', + enabled: !!this.actions?.restart, + icon: 'icon icon-refresh', + label: this.t('harvester.action.restart'), + bulkable: true, + bulkAction: 'restartVM' }, { action: 'softrebootVM', @@ -312,12 +313,22 @@ export default class VirtVm extends HarvesterResource { this.metadata.annotations[HCI_ANNOTATIONS.VOLUME_CLAIM_TEMPLATE] = JSON.stringify(deleteDataSource); } - restartVM() { - this.doActionGrowl('restart', {}); + restartVM(resources = this) { + this.$dispatch('promptModal', { + resources, + action: 'restart', + warningMessageKey: 'dialog.confirmExecution.restart.message', + component: 'ConfirmExecutionDialog' + }); } - softrebootVM() { - this.doActionGrowl('softreboot', {}); + softrebootVM(resources = this) { + this.$dispatch('promptModal', { + resources, + action: 'softreboot', + warningMessageKey: 'dialog.confirmExecution.softreboot.message', + component: 'ConfirmExecutionDialog' + }); } openLogs() {