1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { CustomStyleRulesCallback } from 'common/custom-theme';
20 } from '@mui/material';
21 import { WithStyles } from '@mui/styles';
22 import withStyles from '@mui/styles/withStyles';
23 import { ArvadosTheme } from 'common/custom-theme';
24 import { SshKeyResource } from 'models/ssh-key';
25 import { AddIcon, MoreVerticalIcon, KeyIcon } from 'components/icon/icon';
27 type CssRules = 'root' | 'link' | 'buttonContainer' | 'table' | 'tableRow' | 'keyIcon';
29 const styles: CustomStyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
35 color: theme.palette.primary.main,
36 textDecoration: 'none',
43 marginTop: theme.spacing(1)
51 color: theme.palette.primary.main
55 export interface SshKeyPanelRootActionProps {
56 openSshKeyCreateDialog: () => void;
57 openRowOptions: (event: React.MouseEvent<HTMLElement>, sshKey: SshKeyResource) => void;
58 openPublicKeyDialog: (name: string, publicKey: string) => void;
61 export interface SshKeyPanelRootDataProps {
62 sshKeys: SshKeyResource[];
66 type SshKeyPanelRootProps = SshKeyPanelRootDataProps & SshKeyPanelRootActionProps & WithStyles<CssRules>;
68 export const SshKeyPanelRoot = withStyles(styles)(
69 ({ classes, sshKeys, openSshKeyCreateDialog, openPublicKeyDialog, hasKeys, openRowOptions }: SshKeyPanelRootProps) =>
70 <Card className={classes.root}>
72 <Grid container direction="row">
74 {!hasKeys && <Typography paragraph={true} >
75 You have not yet set up an SSH public key for use with Arvados.
76 <a href='https://doc.arvados.org/user/getting_started/ssh-access-unix.html'
77 target='blank' rel="noopener" className={classes.link}>
81 {!hasKeys && <Typography paragraph={true}>
82 When you have an SSH key you would like to use, add it using button below.
85 <Grid item xs={4} className={classes.buttonContainer}>
86 <Button onClick={openSshKeyCreateDialog} color="primary" variant="contained">
87 <AddIcon /> Add New Ssh Key
92 {hasKeys && <Table className={classes.table}>
94 <TableRow className={classes.tableRow}>
95 <TableCell>Name</TableCell>
96 <TableCell>UUID</TableCell>
97 <TableCell>Authorized user</TableCell>
98 <TableCell>Expires at</TableCell>
99 <TableCell>Key type</TableCell>
100 <TableCell>Public Key</TableCell>
105 {sshKeys.map((sshKey, index) =>
106 <TableRow key={index} className={classes.tableRow}>
107 <TableCell>{sshKey.name}</TableCell>
108 <TableCell>{sshKey.uuid}</TableCell>
109 <TableCell>{sshKey.authorizedUserUuid}</TableCell>
110 <TableCell>{sshKey.expiresAt || '(none)'}</TableCell>
111 <TableCell>{sshKey.keyType}</TableCell>
113 <Tooltip title="Public Key" disableFocusListener>
115 onClick={() => openPublicKeyDialog(sshKey.name, sshKey.publicKey)}
117 <KeyIcon className={classes.keyIcon} />
122 <Tooltip title="More options" disableFocusListener>
123 <IconButton onClick={event => openRowOptions(event, sshKey)} size="large">