diff --git a/packages/teleport/src/cluster/components/Sessions/SessionList/DescCell.tsx b/packages/teleport/src/cluster/components/Sessions/SessionList/DescCell.tsx
index 05931cbc4..16517d275 100644
--- a/packages/teleport/src/cluster/components/Sessions/SessionList/DescCell.tsx
+++ b/packages/teleport/src/cluster/components/Sessions/SessionList/DescCell.tsx
@@ -19,26 +19,23 @@ import styled, { useTheme } from 'styled-components';
import { Cell } from 'design/DataTable';
import { Session } from 'teleport/services/ssh';
import * as Icons from 'design/Icon/Icon';
-import { NavLink } from 'react-router-dom';
import cfg from 'teleport/config';
export default function TypeCell(props: any) {
const { rowIndex, data } = props;
- const { sid, serverId, login, hostname } = data[rowIndex] as Session;
+ const { sid, login, hostname } = data[rowIndex] as Session;
- // DELETE IN: 5.2 remove check for hostname.
- // Older teleport versions do not set/retrieve hostname.
- const nodeDesc = hostname || serverId;
const url = cfg.getSshSessionRoute({ sid });
const theme = useTheme();
- const text = `Session is in progress [${login}@${nodeDesc}]`;
+ const text = `Session is in progress [${login}@${hostname}]`;
return (
- {nodeName} {nodeAddr}
+ {hostname} {nodeAddr}
|
);
}
diff --git a/packages/teleport/src/cluster/components/Sessions/Sessions.story.tsx b/packages/teleport/src/cluster/components/Sessions/Sessions.story.tsx
index 1c0790b66..fe3f5a4e0 100644
--- a/packages/teleport/src/cluster/components/Sessions/Sessions.story.tsx
+++ b/packages/teleport/src/cluster/components/Sessions/Sessions.story.tsx
@@ -72,23 +72,4 @@ const sessions = [
},
],
},
- {
- id: 'AB',
- namespace: 'AG',
- login: 'root',
- active: 'AZ',
- created: new Date('2019-04-22T00:00:51.543Z'),
- durationText: '5 min',
- serverId: '10_128_0_6.demo.gravitational.io',
- clusterId: '',
- hostname: undefined,
- sid: 'sid1',
- addr: undefined,
- parties: [
- {
- user: 'hehwawe@aw.sg',
- remoteAddr: '129.232.123.132',
- },
- ],
- },
];
diff --git a/packages/teleport/src/cluster/components/Sessions/__snapshots__/Sessions.story.test.tsx.snap b/packages/teleport/src/cluster/components/Sessions/__snapshots__/Sessions.story.test.tsx.snap
index 65c4407a5..4a860679d 100644
--- a/packages/teleport/src/cluster/components/Sessions/__snapshots__/Sessions.story.test.tsx.snap
+++ b/packages/teleport/src/cluster/components/Sessions/__snapshots__/Sessions.story.test.tsx.snap
@@ -273,12 +273,12 @@ exports[`loaded 1`] = `
-
- 2
+ 1
of
- 2
+ 1
Session is in progress [root@localhost]
@@ -379,55 +377,6 @@ exports[`loaded 1`] = `
-
-
-
-
- Session is in progress [root@10_128_0_6.demo.gravitational.io]
-
- |
-
- sid1
- |
-
- hehwawe@aw.sg [129.232.123.132]
- |
-
- 10_128_0_6.demo.gravitational.io
-
-
- |
-
- 5 min
- |
-
-
- |
-
diff --git a/packages/teleport/src/components/NodeList/NodeList.tsx b/packages/teleport/src/components/NodeList/NodeList.tsx
index 91e6dc92d..3b5f6c492 100644
--- a/packages/teleport/src/components/NodeList/NodeList.tsx
+++ b/packages/teleport/src/components/NodeList/NodeList.tsx
@@ -129,8 +129,8 @@ const LoginCell: React.FC> = props => {
const { rowIndex, data, onOpen, onSelect } = props;
- const { hostname, id } = data[rowIndex] as Node;
- const serverId = hostname || id;
+ const { id } = data[rowIndex] as Node;
+ const serverId = id;
function handleOnOpen() {
return onOpen(serverId);
}
diff --git a/packages/teleport/src/components/QuickLaunch/QuickLaunch.jsx b/packages/teleport/src/components/QuickLaunch/QuickLaunch.jsx
index 809561c2e..3ff8bfb05 100644
--- a/packages/teleport/src/components/QuickLaunch/QuickLaunch.jsx
+++ b/packages/teleport/src/components/QuickLaunch/QuickLaunch.jsx
@@ -31,11 +31,11 @@ export default function FieldInputSsh({
function onKeyPress(e) {
const value = e.target.value;
if ((e.key === 'Enter' || e.type === 'click') && value) {
- const valid = check(value);
- setHasError(!valid);
- if (valid) {
- const [login, serverId] = value.split('@');
- onPress(login, serverId);
+ const match = check(value);
+ setHasError(!match);
+ if (match) {
+ const { username, host } = match.groups;
+ onPress(username, host);
}
} else {
setHasError(false);
@@ -63,10 +63,11 @@ export default function FieldInputSsh({
);
}
-const SSH_STR_REGEX = /(^(\w+-?\w+)+@(\S+)$)/;
+// Checks for spaces between chars, and
+// captures two named groups: username and host.
+const SSH_STR_REGEX = /^(?:(?[^\s]+)@)(?[^\s]+)$/;
const check = value => {
- const match = SSH_STR_REGEX.exec(value);
- return match !== null;
+ return SSH_STR_REGEX.exec(value.trim());
};
const StyledInput = styled(Input)(
diff --git a/packages/teleport/src/console/stores/storeDocs.ts b/packages/teleport/src/console/stores/storeDocs.ts
index bbcea0224..426556351 100644
--- a/packages/teleport/src/console/stores/storeDocs.ts
+++ b/packages/teleport/src/console/stores/storeDocs.ts
@@ -82,7 +82,7 @@ export default class StoreDocs extends Store {
}
findByUrl(url: string) {
- return this.state.items.find(i => i.url === url);
+ return this.state.items.find(i => i.url === encodeURI(url));
}
getNodeDocuments() {