1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from "react";
6 import { Dialog, DialogTitle, DialogContent, DialogActions, Button, Typography } from "@material-ui/core";
7 import { WithDialogProps } from "~/store/dialog/with-dialog";
8 import { withDialog } from '~/store/dialog/with-dialog';
9 import { WithStyles, withStyles } from '@material-ui/core/styles';
10 import { ArvadosTheme } from '~/common/custom-theme';
11 import { compose, Dispatch } from "redux";
12 import { USER_MANAGEMENT_DIALOG, openSetupShellAccount, loginAs } from "~/store/users/users-actions";
13 import { connect } from "react-redux";
15 type CssRules = 'spacing';
17 const styles = withStyles<CssRules>((theme: ArvadosTheme) => ({
19 paddingBottom: theme.spacing.unit * 2,
20 paddingTop: theme.spacing.unit * 2,
24 interface UserManageDataProps {
28 interface UserManageActionProps {
29 openSetupShellAccount: (uuid: string) => void;
30 loginAs: (uuid: string) => void;
33 const mapDispatchToProps = (dispatch: Dispatch) => ({
34 openSetupShellAccount: (uuid: string) => dispatch<any>(openSetupShellAccount(uuid)),
35 loginAs: (uuid: string) => dispatch<any>(loginAs(uuid))
38 type UserManageProps = UserManageDataProps & UserManageActionProps & WithStyles<CssRules>;
40 export const UserManageDialog = compose(
41 connect(null, mapDispatchToProps),
42 withDialog(USER_MANAGEMENT_DIALOG),
44 (props: WithDialogProps<UserManageProps> & UserManageProps) =>
45 <Dialog open={props.open}
46 onClose={props.closeDialog}
51 <DialogTitle>{`Manage - ${props.data.firstName} ${props.data.lastName}`}</DialogTitle>
53 <Typography variant='body1' className={props.classes.spacing}>
54 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.
56 <Button variant="contained" color="primary" onClick={() => props.loginAs(props.data.uuid)}>
57 {`LOG IN AS ${props.data.firstName} ${props.data.lastName}`}
59 <Typography variant='body1' className={props.classes.spacing}>
60 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.
62 <Button variant="contained" color="primary" onClick={() => props.openSetupShellAccount(props.data.uuid)}>
63 {`SETUP SHELL ACCOUNT FOR ${props.data.firstName} ${props.data.lastName}`}
65 </DialogContent></span>}
71 onClick={props.closeDialog}>