Skip to content

Commit

Permalink
Show helper to set up SSH tunnel for Desktop Viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
skobyda committed May 24, 2023
1 parent bbc85b0 commit 242b8e2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/components/vm/consoles/desktopConsole.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
* along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
*/
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;

Expand All @@ -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 (
<DesktopViewer spice={spice}
vnc={vnc}
Expand All @@ -57,6 +65,12 @@ const DesktopConsoleDownload = ({ vnc, spice, onDesktopConsole }) => {
<p>
{fmt_to_fragments(_("Clicking \"Launch remote viewer\" will download a .vv file and launch $0."), <i>Remote Viewer</i>)}
</p>
{needsTunnel(address, serverAddress) && <p>
{_("SSH tunnel needs to be set up on client:")}
<CodeBlock>
<CodeBlockCode>{`ssh -L 5900:localhost:5900 -N ${loggedUser.name}@${serverAddress}`}</CodeBlockCode>
</CodeBlock>
</p>}
<p>
{fmt_to_fragments(_("$0 is available for most operating systems. To install it, search for it in GNOME Software or run the following:"), <i>Remote Viewer</i>)}
</p>
Expand Down
2 changes: 2 additions & 0 deletions test/check-machines-consoles
Original file line number Diff line number Diff line change
Expand Up @@ -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=""):
Expand Down

0 comments on commit 242b8e2

Please sign in to comment.