Merge branch '16181-fix-vm-view' refs #16181
authorPeter Amstutz <peter.amstutz@curii.com>
Thu, 27 Feb 2020 19:51:31 +0000 (14:51 -0500)
committerPeter Amstutz <peter.amstutz@curii.com>
Thu, 27 Feb 2020 19:51:31 +0000 (14:51 -0500)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

src/common/config.ts
src/views-components/user-dialog/attributes-dialog.tsx
src/views/virtual-machine-panel/virtual-machine-user-panel.tsx

index 58fa13ae62e6ee946ada2ab931ee54064a8c6e8f..0a13f4e11664b7fe9fc945ac30e236682eb43572 100644 (file)
@@ -53,6 +53,7 @@ export interface ClusterConfigJSON {
         WelcomePageHTML: string;
         InactivePageHTML: string;
         SSHHelpPageHTML: string;
+        SSHHelpHostSuffix: string;
         SiteName: string;
     };
     Login: {
@@ -122,7 +123,7 @@ export const fetchConfig = () => {
             return Axios.get<ClusterConfigJSON>(getClusterConfigURL(workbenchConfig.API_HOST)).then(async response => {
                 const clusterConfigJSON = response.data;
                 const apiRevision = await getApiRevision(clusterConfigJSON.Services.Controller.ExternalURL);
-                const config = {...buildConfig(clusterConfigJSON), apiRevision};
+                const config = { ...buildConfig(clusterConfigJSON), apiRevision };
                 const warnLocalConfig = (varName: string) => console.warn(
                     `A value for ${varName} was found in ${WORKBENCH_CONFIG_URL}. To use the Arvados centralized configuration instead, \
 remove the entire ${varName} entry from ${WORKBENCH_CONFIG_URL}`);
@@ -181,6 +182,7 @@ export const mockClusterConfigJSON = (config: Partial<ClusterConfigJSON>): Clust
         WelcomePageHTML: "",
         InactivePageHTML: "",
         SSHHelpPageHTML: "",
+        SSHHelpHostSuffix: "",
         SiteName: "",
     },
     Login: {
index 67b267aeba16e14b182734b4f27ec20b1f360577..df44d62c52f12fe842c5abcfbc249366a6a2097a 100644 (file)
@@ -61,35 +61,38 @@ export const UserAttributesDialog = compose(
     );
 
 const attributes = (user: UserResource, classes: any) => {
-    const { uuid, ownerUuid, createdAt, modifiedAt, modifiedByClientUuid, modifiedByUserUuid, firstName, lastName, href, username } = user;
+    const { uuid, ownerUuid, createdAt, modifiedAt, modifiedByClientUuid, modifiedByUserUuid,
+        firstName, lastName, username, email, isActive, isAdmin } = user;
     return (
         <span>
             <Grid container direction="row">
                 <Grid item xs={5} className={classes.rightContainer}>
+                    {uuid && <Grid item>Uuid</Grid>}
                     {firstName && <Grid item>First name</Grid>}
                     {lastName && <Grid item>Last name</Grid>}
-                    {ownerUuid && <Grid item>Owner uuid</Grid>}
+                    {email && <Grid item>Email</Grid>}
+                    {username && <Grid item>Username</Grid>}
+                    {isActive && <Grid item>Is active</Grid>}
+                    {isAdmin && <Grid item>Is admin</Grid>}
                     {createdAt && <Grid item>Created at</Grid>}
                     {modifiedAt && <Grid item>Modified at</Grid>}
+                    {ownerUuid && <Grid item>Owner uuid</Grid>}
                     {modifiedByUserUuid && <Grid item>Modified by user uuid</Grid>}
                     {modifiedByClientUuid && <Grid item>Modified by client uuid</Grid>}
-                    {uuid && <Grid item>uuid</Grid>}
-                    {href && <Grid item>Href</Grid>}
-                    {username && <Grid item>Username</Grid>}
-                    {username && <Grid item>Username</Grid>}
                 </Grid>
                 <Grid item xs={7} className={classes.leftContainer}>
+                    <Grid item>{uuid}</Grid>
                     <Grid item>{firstName}</Grid>
                     <Grid item>{lastName}</Grid>
-                    <Grid item>{ownerUuid}</Grid>
+                    <Grid item>{email}</Grid>
+                    <Grid item>{username}</Grid>
+                    <Grid item>{isActive}</Grid>
+                    <Grid item>{isAdmin}</Grid>
                     <Grid item>{createdAt}</Grid>
                     <Grid item>{modifiedAt}</Grid>
+                    <Grid item>{ownerUuid}</Grid>
                     <Grid item>{modifiedByUserUuid}</Grid>
                     <Grid item>{modifiedByClientUuid}</Grid>
-                    <Grid item>{uuid}</Grid>
-                    <Grid item>{href}</Grid>
-                    <Grid item>{username}</Grid>
-                    <Grid item>{username}</Grid>
                 </Grid>
             </Grid>
         </span>
index a641ec63cd8b8c2a687e6fb68755ad7f2ecb17e2..49d880e5e2d87df537b10b5dc704132e8f8436de 100644 (file)
@@ -12,6 +12,7 @@ import { saveRequestedDate, loadVirtualMachinesUserData } from '~/store/virtual-
 import { RootState } from '~/store/store';
 import { ListResults } from '~/services/common-service/common-service';
 import { HelpIcon } from '~/components/icon/icon';
+// import * as CopyToClipboard from 'react-copy-to-clipboard';
 
 type CssRules = 'button' | 'codeSnippet' | 'link' | 'linkIcon' | 'rightAlign' | 'cardWithoutMachines' | 'icon';
 
@@ -59,6 +60,7 @@ const mapStateToProps = (state: RootState) => {
         requestedDate: state.virtualMachines.date,
         userUuid: state.auth.user!.uuid,
         helpText: state.auth.config.clusterConfig.Workbench.SSHHelpPageHTML,
+        hostSuffix: state.auth.config.clusterConfig.Workbench.SSHHelpHostSuffix || "",
         webShell: state.auth.config.clusterConfig.Services.WebShell.ExternalURL,
         ...state.virtualMachines
     };
@@ -75,6 +77,7 @@ interface VirtualMachinesPanelDataProps {
     userUuid: string;
     links: ListResults<any>;
     helpText: string;
+    hostSuffix: string;
     webShell: string;
 }
 
@@ -166,25 +169,30 @@ const virtualMachinesTable = (props: VirtualMachineProps) =>
             </TableRow>
         </TableHead>
         <TableBody>
-            {props.virtualMachines.items.map((it, index) =>
-                <TableRow key={index}>
-                    <TableCell>{it.hostname}</TableCell>
-                    <TableCell>{getUsername(props.links, props.userUuid)}</TableCell>
-                    <TableCell>ssh {getUsername(props.links, props.userUuid)}@{it.hostname}</TableCell>
-                    {props.webShell !== "" && <TableCell>
-                        <a href={`${props.webShell}${it.href}/webshell/${getUsername(props.links, props.userUuid)}`} target="_blank" className={props.classes.link}>
-                            Log in as {getUsername(props.links, props.userUuid)}
-                        </a>
-                    </TableCell>}
-                </TableRow>
-            )}
+            {props.virtualMachines.items.map(it =>
+                props.links.items.map(lk => {
+                    if (lk.tailUuid === props.userUuid) {
+                        const username = lk.properties.username;
+                        const command = `ssh ${username}@${it.hostname}${props.hostSuffix}`;
+                        return <TableRow key={lk.uuid}>
+                            <TableCell>{it.hostname}</TableCell>
+                            <TableCell>{username}</TableCell>
+                            <TableCell>
+                                {command}
+                            </TableCell>
+                            {props.webShell !== "" && <TableCell>
+                                <a href={`${props.webShell}${it.href}/webshell/${username}`} target="_blank" className={props.classes.link}>
+                                    Log in as {username}
+                                </a>
+                            </TableCell>}
+                        </TableRow>;
+                    }
+                    return;
+                }
+                ))}
         </TableBody>
     </Table>;
 
-const getUsername = (links: ListResults<any>, userUuid: string) => {
-    return links.items.map(it => it.tailUuid === userUuid ? it.properties.username : '');
-};
-
 const CardSSHSection = (props: VirtualMachineProps) =>
     <Grid item xs={12}>
         <Card>