From 97a84613764ae45a3b9be7daf96a120bbba29cc7 Mon Sep 17 00:00:00 2001 From: Simon Kobyda Date: Fri, 13 Oct 2023 12:21:17 +0200 Subject: [PATCH] Watchdog: Use 'reset' as default when no device is attached --- src/components/vm/overview/watchdog.jsx | 8 ++++---- test/check-machines-settings | 5 +---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/components/vm/overview/watchdog.jsx b/src/components/vm/overview/watchdog.jsx index de61809fd..bddef8c46 100644 --- a/src/components/vm/overview/watchdog.jsx +++ b/src/components/vm/overview/watchdog.jsx @@ -37,6 +37,8 @@ import { WATCHDOG_INFO_MESSAGE } from './helpers.jsx'; const _ = cockpit.gettext; +const SUPPORTEDACTIONS = ["reset", "poweroff", "inject-nmi", "pause"]; + const WatchdogModalAlert = ({ dialogError }) => { const [isExpanded, setIsExpanded] = useState(false); @@ -68,7 +70,7 @@ const WatchdogModalAlert = ({ dialogError }) => { export const WatchdogModal = ({ vm, isWatchdogAttached, idPrefix }) => { const [dialogError, setDialogError] = useState(); - const [watchdogAction, setWatchdogAction] = useState(vm.watchdog.action || "no-device"); + const [watchdogAction, setWatchdogAction] = useState(vm.watchdog.action || SUPPORTEDACTIONS[0]); // use first option as default const [inProgress, setInProgress] = useState(false); const [offerColdplug, setOfferColdplug] = useState(false); @@ -134,8 +136,6 @@ export const WatchdogModal = ({ vm, isWatchdogAttached, idPrefix }) => { .finally(() => setInProgress(false)); }; - const supportedActions = ["reset", "poweroff", "inject-nmi", "pause"]; - const needsShutdown = () => { if (vm.state === 'running' && isWatchdogAttached && vm.watchdog.action !== watchdogAction) return ; @@ -203,7 +203,7 @@ export const WatchdogModal = ({ vm, isWatchdogAttached, idPrefix }) => { fieldId="watchdog-action" hasNoPaddingTop isStack> - {supportedActions.map(action => ( + {SUPPORTEDACTIONS.map(action => (