From c1bbd42932ed68fab85fd51b6870960699106109 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 17 Jan 2025 14:32:17 +0200 Subject: [PATCH] consoles: Also wait for address when connecting to VNC If the inactive XML config contains a port but not a address, we would try to connect too early, before the address was actually filled in. --- src/components/vm/consoles/vnc.jsx | 2 +- src/components/vm/consoles/vncBody.jsx | 8 ++------ src/components/vm/consoles/vncEdit.jsx | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/components/vm/consoles/vnc.jsx b/src/components/vm/consoles/vnc.jsx index 8afa873a7..fa1884e9a 100644 --- a/src/components/vm/consoles/vnc.jsx +++ b/src/components/vm/consoles/vnc.jsx @@ -69,7 +69,7 @@ class Vnc extends React.Component { } const { consoleDetail } = props; - if (!consoleDetail || consoleDetail.port == -1) { + if (!consoleDetail || consoleDetail.port == -1 || !consoleDetail.address) { logDebug('Vnc component: console detail not yet provided'); return; } diff --git a/src/components/vm/consoles/vncBody.jsx b/src/components/vm/consoles/vncBody.jsx index 06ce216e4..69792f910 100644 --- a/src/components/vm/consoles/vncBody.jsx +++ b/src/components/vm/consoles/vncBody.jsx @@ -84,14 +84,10 @@ export const VncRow = ({ idPrefix, onValueChanged, dialogValues, validationError export function validateDialogValues(values) { const res = { }; - console.log("port", JSON.stringify(values.vncPort), values.vncPort.match("^[0-9]+$")); - if (values.vncPort == "") ; // fine - else if (!values.vncPort.match("^[0-9]+$")) - res.vncPort = _("Port must be a positive number.") - else if (Number(values.vncPort) < 5900) - res.vncPort = _("Port must be 5900 or larger.") + else if (!values.vncPort.match("^[0-9]+$") || Number(values.vncPort) < 5900) + res.vncPort = _("Port must be 5900 or larger."); return Object.keys(res).length > 0 ? res : null; } diff --git a/src/components/vm/consoles/vncEdit.jsx b/src/components/vm/consoles/vncEdit.jsx index f98d3ea46..bda5da247 100644 --- a/src/components/vm/consoles/vncEdit.jsx +++ b/src/components/vm/consoles/vncEdit.jsx @@ -96,7 +96,7 @@ export class EditVNCModal extends React.Component { );