18207: Makes 'working' status work in 'Shared with me' & 'Groups' DataExplorers
[arvados-workbench2.git] / src / views-components / user-dialog / manage-dialog.tsx
index a64b5082b7f8b78046a4a6a3710e28cb6c1ffc68..b812f5cb7b6fa36df9de2dce3aad798ef7130997 100644 (file)
@@ -2,16 +2,16 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from "react";
-import { Dialog, DialogTitle, DialogContent, DialogActions, Button, Typography } from "@material-ui/core";
-import { WithDialogProps } from "~/store/dialog/with-dialog";
-import { withDialog } from '~/store/dialog/with-dialog';
-import { WithStyles, withStyles } from '@material-ui/core/styles';
-import { ArvadosTheme } from '~/common/custom-theme';
+import React from "react";
 import { compose, Dispatch } from "redux";
-import { USER_MANAGE_DIALOG, openSetupShellAccount, loginAs } from "~/store/users/users-actions";
-import { UserResource } from "~/models/user";
 import { connect } from "react-redux";
+import { Dialog, DialogTitle, DialogContent, DialogActions, Button, Typography } from "@material-ui/core";
+import { WithDialogProps } from "store/dialog/with-dialog";
+import { withDialog } from 'store/dialog/with-dialog';
+import { WithStyles, withStyles } from '@material-ui/core/styles';
+import { ArvadosTheme } from 'common/custom-theme';
+import { USER_MANAGEMENT_DIALOG, openSetupShellAccount, loginAs } from "store/users/users-actions";
+import { getUserDisplayName } from "models/user";
 
 type CssRules = 'spacing';
 
@@ -23,7 +23,7 @@ const styles = withStyles<CssRules>((theme: ArvadosTheme) => ({
 }));
 
 interface UserManageDataProps {
-    data: UserResource;
+    data: any;
 }
 
 interface UserManageActionProps {
@@ -40,31 +40,34 @@ type UserManageProps = UserManageDataProps & UserManageActionProps & WithStyles<
 
 export const UserManageDialog = compose(
     connect(null, mapDispatchToProps),
-    withDialog(USER_MANAGE_DIALOG),
+    withDialog(USER_MANAGEMENT_DIALOG),
     styles)(
         (props: WithDialogProps<UserManageProps> & UserManageProps) =>
             <Dialog open={props.open}
                 onClose={props.closeDialog}
                 fullWidth
                 maxWidth="md">
-                <DialogTitle>{`Manage - ${props.data.firstName} ${props.data.lastName}`}</DialogTitle>
-                <DialogContent>
-                    <Typography variant="body2" className={props.classes.spacing}>
-                        As an admin, you can log in as this user. When you’ve finished, you will need to log out and log in again with your own account.
+                {props.data &&
+                    <span>
+                        <DialogTitle>{`Manage - ${getUserDisplayName(props.data)}`}</DialogTitle>
+                        <DialogContent>
+                            <Typography variant='body1' className={props.classes.spacing}>
+                                As an admin, you can log in as this user. When you’ve finished, you will need to log out and log in again with your own account.
                     </Typography>
-                    <Button variant="contained" color="primary" onClick={() => props.loginAs(props.data.uuid)}>
-                        {`LOG IN AS ${props.data.firstName} ${props.data.lastName}`}
-                    </Button>
-                    <Typography variant="body2" className={props.classes.spacing}>
-                        As an admin, you can setup a shell account for this user. The login name is automatically generated from the user's e-mail address.
+                            <Button variant="contained" color="primary" onClick={() => props.loginAs(props.data.uuid)}>
+                                {`LOG IN AS ${getUserDisplayName(props.data)}`}
+                            </Button>
+                            <Typography variant='body1' className={props.classes.spacing}>
+                                As an admin, you can setup a shell account for this user. The login name is automatically generated from the user's e-mail address.
                     </Typography>
-                    <Button variant="contained" color="primary" onClick={() => props.openSetupShellAccount(props.data.uuid)} disabled>
-                        {`SETUP SHELL ACCOUNT FOR ${props.data.firstName} ${props.data.lastName}`}
-                    </Button>
-                </DialogContent>
+                            <Button variant="contained" color="primary" onClick={() => props.openSetupShellAccount(props.data.uuid)}>
+                                {`SETUP SHELL ACCOUNT FOR ${getUserDisplayName(props.data)}`}
+                            </Button>
+                        </DialogContent></span>}
+
                 <DialogActions>
                     <Button
-                        variant='flat'
+                        variant='text'
                         color='primary'
                         onClick={props.closeDialog}>
                         Close