From 2842ed045a4d822b3ee26eb8234f6156c20c2e3f Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Fri, 10 Jan 2025 16:37:18 +0200 Subject: [PATCH] consoles: Show VNC details also when VM is off So that people can edit them or add VNC if it is missing. --- src/components/vm/consoles/consoles.jsx | 63 +++++++++++++++++++++++-- src/components/vm/consoles/vnc.jsx | 14 +++++- 2 files changed, 71 insertions(+), 6 deletions(-) diff --git a/src/components/vm/consoles/consoles.jsx b/src/components/vm/consoles/consoles.jsx index 578f2a12b..87c379a3a 100644 --- a/src/components/vm/consoles/consoles.jsx +++ b/src/components/vm/consoles/consoles.jsx @@ -20,10 +20,16 @@ import React from 'react'; import PropTypes from 'prop-types'; import cockpit from 'cockpit'; import { AccessConsoles } from "@patternfly/react-console"; +import { Button } from "@patternfly/react-core/dist/esm/components/Button"; +import { DescriptionList, DescriptionListDescription, DescriptionListGroup, DescriptionListTerm } from "@patternfly/react-core/dist/esm/components/DescriptionList"; +import { useDialogs } from 'dialogs.jsx'; import SerialConsole from './serialConsole.jsx'; import Vnc from './vnc.jsx'; import DesktopConsole from './desktopConsole.jsx'; +import { AddVNC } from './vncAdd.jsx'; +import { EditVNCModal } from './vncEdit.jsx'; + import { domainCanConsole, domainDesktopConsole, @@ -34,10 +40,58 @@ import './consoles.css'; const _ = cockpit.gettext; -const VmNotRunning = () => { +const VmNotRunning = ({ vm, vnc }) => { + const Dialogs = useDialogs(); + + function add_vnc() { + Dialogs.show(); + } + + function edit_vnc() { + Dialogs.show(); + } + return (
- {_("Please start the virtual machine to access its console.")} +

{_("Please start the virtual machine to access its console.")}

+
+
+

{_("VNC")}

+ { vnc + ? <> + + + + {_("Listening address")} + + + {vnc.address || {_("default")}} + + + + + {_("Listening port")} + + + {vnc.port != -1 ? vnc.port : {_("automatic")}} + + + + + + : + }
); }; @@ -98,7 +152,7 @@ class Consoles extends React.Component { const vnc = vm.displays && vm.displays.find(display => display.type == 'vnc'); if (!domainCanConsole || !domainCanConsole(vm.state)) { - return (); + return (); } const onDesktopConsole = () => { // prefer spice over vnc @@ -116,14 +170,13 @@ class Consoles extends React.Component { connectionName={vm.connectionName} vmName={vm.name} spawnArgs={domainSerialConsoleCommand({ vm, alias: pty.alias })} />))} - {vnc && } + isExpanded={isExpanded} /> {(vnc || spice) && + + + {_("VNC support not enabled. Shut down the virtual machine to add support.")} + + + + ); + } + if (!path) { // postpone rendering until consoleDetail is known and channel ready return null; }