Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Lisa/minor fixes #123

Merged
merged 5 commits into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Cell>
<StyledEventType>
<Icons.Cli
as={NavLink}
to={url}
as="a"
href={url}
target="_blank"
p="1"
mr="3"
bg="bgTerminal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ import { Session } from 'teleport/services/ssh';

export default function DescCell(props: any) {
const { rowIndex, data } = props;
const { hostname, addr, serverId } = data[rowIndex] as Session;
// DELETE IN: 5.2 remove check for hostname/addr.
// Older teleport versions do not set/retrieve hostname or addr.
const nodeName = hostname || serverId;
const { hostname, addr } = data[rowIndex] as Session;
const nodeAddr = addr ? `[${addr}]` : '';

return (
<Cell>
{nodeName} {nodeAddr}
{hostname} {nodeAddr}
</Cell>
);
}
4 changes: 2 additions & 2 deletions packages/teleport/src/components/NodeList/NodeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ const LoginCell: React.FC<Required<{
[key: string]: any;
}>> = 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);
}
Expand Down
17 changes: 9 additions & 8 deletions packages/teleport/src/components/QuickLaunch/QuickLaunch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 = /^(?:(?<username>[^\s]+)@)(?<host>[^\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)(
Expand Down
2 changes: 1 addition & 1 deletion packages/teleport/src/console/stores/storeDocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default class StoreDocs extends Store<State> {
}

findByUrl(url: string) {
return this.state.items.find(i => i.url === url);
return this.state.items.find(i => i.url === encodeURI(url));
}

getNodeDocuments() {
Expand Down