1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { connect } from 'react-redux';
7 import { Grid, Typography, Button, Card, CardContent } from '@material-ui/core';
8 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
9 import { ArvadosTheme } from '~/common/custom-theme';
10 import { DefaultCodeSnippet } from '~/components/default-code-snippet/default-code-snippet';
11 import { Link } from 'react-router-dom';
12 import { Dispatch } from 'redux';
13 import { saveRequestedDate, loadRequestedDate } from '~/store/virtual-machines/virtual-machines-actions';
14 import { RootState } from '~/store/store';
16 type CssRules = 'button' | 'codeSnippet' | 'link';
18 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
20 marginTop: theme.spacing.unit,
21 marginBottom: theme.spacing.unit * 2
24 borderRadius: theme.spacing.unit * 0.5,
26 borderColor: theme.palette.grey["400"],
30 textDecoration: 'none',
31 color: theme.palette.primary.main
35 const mapStateToProps = (state: RootState) => {
37 requestedDate: state.virtualMachines.date
41 const mapDispatchToProps = (dispatch: Dispatch) => ({
42 saveRequestedDate: () => dispatch<any>(saveRequestedDate()),
43 loadRequestedDate: () => dispatch<any>(loadRequestedDate())
46 interface VirtualMachinesPanelDataProps {
47 requestedDate: string;
50 interface VirtualMachinesPanelActionProps {
51 saveRequestedDate: () => void;
52 loadRequestedDate: () => string;
55 type VirtualMachineProps = VirtualMachinesPanelActionProps & VirtualMachinesPanelDataProps & WithStyles<CssRules>;
57 export const VirtualMachinePanel = withStyles(styles)(connect(mapStateToProps, mapDispatchToProps)(
58 class extends React.Component<VirtualMachineProps> {
60 this.props.loadRequestedDate();
64 const { classes, saveRequestedDate, requestedDate } = this.props;
66 <Grid container spacing={16}>
70 <Typography variant="body2">
71 You do not have access to any virtual machines. Some Arvados features require using the command line. You may request access to a hosted virtual machine with the command line shell.
73 <Button variant="contained" color="primary" className={classes.button} onClick={saveRequestedDate}>
74 SEND REQUEST FOR SHELL ACCESS
77 <Typography variant="body1">
78 A request for shell access was sent on {requestedDate}
86 <Typography variant="body2">
87 In order to access virtual machines using SSH, <Link to='' className={classes.link}>add an SSH key to your account</Link> and add a section like this to your SSH configuration file ( ~/.ssh/config):
90 className={classes.codeSnippet}
102 const textSSH = `Host *.arvados
104 ServerAliveInterval 60
105 ProxyCommand ssh -p2222 turnout@switchyard.api.ardev.roche.com -x -a $SSH_PROXY_FLAGS %h`;