diff --git a/src/components/vm/consoles/consoles.jsx b/src/components/vm/consoles/consoles.jsx index 578f2a12b..8a3e51dbd 100644 --- a/src/components/vm/consoles/consoles.jsx +++ b/src/components/vm/consoles/consoles.jsx @@ -20,10 +20,17 @@ 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 { Split, SplitItem } from "@patternfly/react-core/dist/esm/layouts/Split/index.js"; +import { useDialogs } from 'dialogs.jsx'; +import { fmt_to_fragments } from "utils.js"; 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 +41,57 @@ 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(); + } + + let vnc_info; + let vnc_action; + + if (!vnc) { + vnc_info = _("not supported"); + vnc_action = ( + ); + } else { + if (vnc.port == -1) + vnc_info = _("supported"); + else + vnc_info = fmt_to_fragments(_("supported, port $0"), vnc.port); + + vnc_action = ( + ); + } + return (
- {_("Please start the virtual machine to access its console.")} +

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

+
+ + + {_("Graphical console:")} {vnc_info} + + + {vnc_action} + +
); }; @@ -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; }