diff --git a/src/components/vm/consoles/desktopConsole.jsx b/src/components/vm/consoles/desktopConsole.jsx index 454551953..bad4a68d8 100644 --- a/src/components/vm/consoles/desktopConsole.jsx +++ b/src/components/vm/consoles/desktopConsole.jsx @@ -17,9 +17,12 @@ * along with Cockpit; If not, see . */ import React from "react"; +import { CodeBlock, CodeBlockCode } from "@patternfly/react-core/dist/esm/components/CodeBlock"; import { DesktopViewer } from '@patternfly/react-console'; +import { getServerAddress, needsTunnel } from "./utils.js"; import cockpit from "cockpit"; +import store from './../../../store.js'; const _ = cockpit.gettext; @@ -37,6 +40,11 @@ function fmt_to_fragments(fmt) { } const DesktopConsoleDownload = ({ vnc, spice, onDesktopConsole }) => { + // DesktopViewer prefers spice over vnc + const address = (spice && spice.address) || (vnc && vnc.address); + const serverAddress = getServerAddress(); + const loggedUser = store.getState().systemInfo.loggedUser; + return ( {

{fmt_to_fragments(_("Clicking \"Launch remote viewer\" will download a .vv file and launch $0."), Remote Viewer)}

+ {needsTunnel(address, serverAddress) &&

+ {_("SSH tunnel needs to be set up on client:")} + + {`ssh -L 5900:localhost:5900 -N ${loggedUser.name}@${serverAddress}`} + +

}

{fmt_to_fragments(_("$0 is available for most operating systems. To install it, search for it in GNOME Software or run the following:"), Remote Viewer)}

diff --git a/test/check-machines-consoles b/test/check-machines-consoles index f85ddbc24..e7e157972 100755 --- a/test/check-machines-consoles +++ b/test/check-machines-consoles @@ -67,6 +67,8 @@ class TestMachinesConsoles(VirtualMachinesCase): b.wait_in_text('.pf-c-expandable-section__content', 'Clicking "Launch remote viewer" will download') + b.wait_not_in_text('.pf-c-expandable-section__content', 'SSH tunnel needs to be set up on client') + b.assert_pixels("#vm-subVmTest1-consoles-page", "vm-details-console-external", skip_layouts=["rtl"]) def testInlineConsole(self, urlroot=""):