From: Stephen Smith Date: Wed, 9 Feb 2022 06:07:15 +0000 (-0500) Subject: 18284: Add shell login command copy button and style webshell button like a button. X-Git-Tag: 2.4.0~12^2 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/87ba49100005ac43690cd2f77b2f797154998d01 18284: Add shell login command copy button and style webshell button like a button. Arvados-DCO-1.1-Signed-off-by: Stephen Smith --- diff --git a/src/views/virtual-machine-panel/virtual-machine-user-panel.tsx b/src/views/virtual-machine-panel/virtual-machine-user-panel.tsx index 66ea017e..70f97daf 100644 --- a/src/views/virtual-machine-panel/virtual-machine-user-panel.tsx +++ b/src/views/virtual-machine-panel/virtual-machine-user-panel.tsx @@ -15,8 +15,11 @@ import { HelpIcon } from 'components/icon/icon'; import { SESSION_STORAGE } from "services/auth-service/auth-service"; // import * as CopyToClipboard from 'react-copy-to-clipboard'; import parse from "parse-duration"; +import { CopyIcon } from 'components/icon/icon'; +import CopyToClipboard from 'react-copy-to-clipboard'; +import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions'; -type CssRules = 'button' | 'codeSnippet' | 'link' | 'linkIcon' | 'rightAlign' | 'cardWithoutMachines' | 'icon' | 'chipsRoot'; +type CssRules = 'button' | 'codeSnippet' | 'link' | 'linkIcon' | 'rightAlign' | 'cardWithoutMachines' | 'icon' | 'chipsRoot' | 'copyIcon' | 'webshellButton'; const EXTRA_TOKEN = "exraToken"; @@ -60,6 +63,18 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ chipsRoot: { margin: `0px -${theme.spacing.unit / 2}px`, }, + copyIcon: { + marginLeft: theme.spacing.unit, + color: theme.palette.grey["500"], + cursor: 'pointer', + display: 'inline', + '& svg': { + fontSize: '1rem' + } + }, + webshellButton: { + textTransform: "initial", + }, }); const mapStateToProps = (state: RootState) => { @@ -76,9 +91,16 @@ const mapStateToProps = (state: RootState) => { }; }; -const mapDispatchToProps = (dispatch: Dispatch): Pick => ({ +const mapDispatchToProps = (dispatch: Dispatch): Pick => ({ saveRequestedDate: () => dispatch(saveRequestedDate()), loadVirtualMachinesData: () => dispatch(loadVirtualMachinesUserData()), + onCopy: (message: string) => { + dispatch(snackbarActions.OPEN_SNACKBAR({ + message, + hideDuration: 2000, + kind: SnackbarKind.SUCCESS + })); + }, }); interface VirtualMachinesPanelDataProps { @@ -97,6 +119,7 @@ interface VirtualMachinesPanelDataProps { interface VirtualMachinesPanelActionProps { saveRequestedDate: () => void; loadVirtualMachinesData: () => string; + onCopy: (message: string) => void; } type VirtualMachineProps = VirtualMachinesPanelActionProps & VirtualMachinesPanelDataProps & WithStyles; @@ -192,6 +215,7 @@ const virtualMachinesTable = (props: VirtualMachineProps) => if (props.tokenLocation === SESSION_STORAGE || props.tokenLocation === EXTRA_TOKEN) { tokenParam = `&token=${encodeURIComponent(props.token)}`; } + const loginHref = `/webshell/?host=${encodeURIComponent(props.webshellUrl + '/' + it.hostname)}&timeout=${props.idleTimeout}&login=${encodeURIComponent(username)}${tokenParam}`; return {it.hostname} {username} @@ -208,11 +232,24 @@ const virtualMachinesTable = (props: VirtualMachineProps) => {command} + + + props.onCopy!("Copied")}> + + + + - - Log in as {username} - + ; }