X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/ba71587fc2058276b9b70c342b990aa6508690a9..750b2c391b5418bfd3db88e59429abad9fde6c1e:/src/views/site-manager-panel/site-manager-panel-root.tsx

diff --git a/src/views/site-manager-panel/site-manager-panel-root.tsx b/src/views/site-manager-panel/site-manager-panel-root.tsx
index e75aa1f955..246bc8758c 100644
--- a/src/views/site-manager-panel/site-manager-panel-root.tsx
+++ b/src/views/site-manager-panel/site-manager-panel-root.tsx
@@ -2,12 +2,13 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from 'react';
+import React from 'react';
 import {
     Card,
     CardContent,
     CircularProgress,
     Grid,
+    IconButton,
     StyleRulesCallback,
     Table,
     TableBody,
@@ -18,16 +19,17 @@ import {
     WithStyles,
     withStyles
 } from '@material-ui/core';
-import { ArvadosTheme } from '~/common/custom-theme';
-import { Session, SessionStatus } from "~/models/session";
+import { ArvadosTheme } from 'common/custom-theme';
+import { Session, SessionStatus } from "models/session";
 import Button from "@material-ui/core/Button";
 import { compose, Dispatch } from "redux";
 import { Field, FormErrors, InjectedFormProps, reduxForm, reset, stopSubmit } from "redux-form";
-import { TextField } from "~/components/text-field/text-field";
-import { addSession } from "~/store/auth/auth-action-session";
-import { SITE_MANAGER_REMOTE_HOST_VALIDATION } from "~/validators/validators";
-import { Config } from '~/common/config';
-import { ResourceCluster } from '~/views-components/data-explorer/renderers';
+import { TextField } from "components/text-field/text-field";
+import { addSession } from "store/auth/auth-action-session";
+import { SITE_MANAGER_REMOTE_HOST_VALIDATION } from "validators/validators";
+import { Config } from 'common/config';
+import { ResourceCluster } from 'views-components/data-explorer/renderers';
+import { TrashIcon } from "components/icon/icon";
 
 type CssRules = 'root' | 'link' | 'buttonContainer' | 'table' | 'tableRow' |
     'remoteSiteInfo' | 'buttonAdd' | 'buttonLoggedIn' | 'buttonLoggedOut' |
@@ -86,11 +88,13 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
 
 export interface SiteManagerPanelRootActionProps {
     toggleSession: (session: Session) => void;
+    removeSession: (session: Session) => void;
 }
 
 export interface SiteManagerPanelRootDataProps {
     sessions: Session[];
     remoteHostsConfig: { [key: string]: Config };
+    localClusterConfig: Config;
 }
 
 type SiteManagerPanelRootProps = SiteManagerPanelRootDataProps & SiteManagerPanelRootActionProps & WithStyles<CssRules> & InjectedFormProps;
@@ -98,7 +102,7 @@ const SITE_MANAGER_FORM_NAME = 'siteManagerForm';
 
 const submitSession = (remoteHost: string) =>
     (dispatch: Dispatch) => {
-        dispatch<any>(addSession(remoteHost)).then(() => {
+        dispatch<any>(addSession(remoteHost, undefined, true)).then(() => {
             dispatch(reset(SITE_MANAGER_FORM_NAME));
         }).catch((e: any) => {
             const errors = {
@@ -117,7 +121,7 @@ export const SiteManagerPanelRoot = compose(
         }
     }),
     withStyles(styles))
-    (({ classes, sessions, handleSubmit, toggleSession, remoteHostsConfig }: SiteManagerPanelRootProps) =>
+    (({ classes, sessions, handleSubmit, toggleSession, removeSession, localClusterConfig, remoteHostsConfig }: SiteManagerPanelRootProps) =>
         <Card className={classes.root}>
             <CardContent>
                 <Grid container direction="row">
@@ -133,9 +137,10 @@ export const SiteManagerPanelRoot = compose(
                             <TableRow className={classes.tableRow}>
                                 <TableCell>Cluster ID</TableCell>
                                 <TableCell>Host</TableCell>
-                                <TableCell>Username</TableCell>
                                 <TableCell>Email</TableCell>
+                                <TableCell>UUID</TableCell>
                                 <TableCell>Status</TableCell>
+                                <TableCell>Actions</TableCell>
                             </TableRow>
                         </TableHead>
                         <TableBody>
@@ -146,16 +151,26 @@ export const SiteManagerPanelRoot = compose(
                                         <a href={remoteHostsConfig[session.clusterId].workbench2Url} style={{ textDecoration: 'none' }}> <ResourceCluster uuid={session.clusterId} /></a>
                                         : session.clusterId}</TableCell>
                                     <TableCell>{session.remoteHost}</TableCell>
-                                    <TableCell>{validating ? <CircularProgress size={20} /> : session.username}</TableCell>
                                     <TableCell>{validating ? <CircularProgress size={20} /> : session.email}</TableCell>
+                                    <TableCell>{validating ? <CircularProgress size={20} /> : session.uuid}</TableCell>
                                     <TableCell className={classes.statusCell}>
                                         <Button fullWidth
                                             disabled={validating || session.status === SessionStatus.INVALIDATED || session.active}
                                             className={session.loggedIn ? classes.buttonLoggedIn : classes.buttonLoggedOut}
                                             onClick={() => toggleSession(session)}>
-                                            {validating ? "Validating" : (session.loggedIn ? "Logged in" : "Logged out")}
+                                            {validating ? "Validating"
+                                                : (session.loggedIn ?
+                                                    (session.userIsActive ? "Logged in" : "Inactive")
+                                                    : "Logged out")}
                                         </Button>
                                     </TableCell>
+                                    <TableCell>
+                                        {session.clusterId !== localClusterConfig.uuidPrefix &&
+                                            !localClusterConfig.clusterConfig.RemoteClusters[session.clusterId] &&
+                                            <IconButton onClick={() => removeSession(session)}>
+                                                <TrashIcon />
+                                            </IconButton>}
+                                    </TableCell>
                                 </TableRow>;
                             })}
                         </TableBody>
@@ -172,7 +187,7 @@ export const SiteManagerPanelRoot = compose(
                             <Field
                                 name='remoteHost'
                                 validate={SITE_MANAGER_REMOTE_HOST_VALIDATION}
-                                component={TextField}
+                                component={TextField as any}
                                 placeholder="zzzz.arvadosapi.com"
                                 margin="normal"
                                 label="New cluster"
