1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from "react";
6 import { compose, Dispatch } from "redux";
7 import { connect } from "react-redux";
8 import { Dialog, DialogTitle, DialogContent, DialogActions, Button, Typography } from "@material-ui/core";
9 import { WithDialogProps } from "store/dialog/with-dialog";
10 import { withDialog } from 'store/dialog/with-dialog';
11 import { WithStyles, withStyles } from '@material-ui/core/styles';
12 import { ArvadosTheme } from 'common/custom-theme';
13 import { USER_MANAGEMENT_DIALOG } from "store/users/users-actions";
14 import { openSetupShellAccount, loginAs } from 'store/users/users-actions';
15 import { getUserDisplayName } from "models/user";
17 type CssRules = 'spacing';
19 const styles = withStyles<CssRules>((theme: ArvadosTheme) => ({
21 paddingBottom: theme.spacing.unit * 2,
22 paddingTop: theme.spacing.unit * 2,
26 interface UserManageDataProps {
30 interface UserManageActionProps {
31 openSetupShellAccount: (uuid: string) => void;
32 loginAs: (uuid: string) => void;
35 const mapDispatchToProps = (dispatch: Dispatch) => ({
36 openSetupShellAccount: (uuid: string) => dispatch<any>(openSetupShellAccount(uuid)),
37 loginAs: (uuid: string) => dispatch<any>(loginAs(uuid))
40 type UserManageProps = UserManageDataProps & UserManageActionProps & WithStyles<CssRules>;
42 export const UserManageDialog = compose(
43 connect(null, mapDispatchToProps),
44 withDialog(USER_MANAGEMENT_DIALOG),
46 (props: WithDialogProps<UserManageProps> & UserManageProps) =>
47 <Dialog open={props.open}
48 onClose={props.closeDialog}
53 <DialogTitle>{`Manage - ${getUserDisplayName(props.data)}`}</DialogTitle>
55 <Typography variant='body1' className={props.classes.spacing}>
56 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.
58 <Button variant="contained" color="primary" onClick={() => props.loginAs(props.data.uuid)}>
59 {`LOG IN AS ${getUserDisplayName(props.data)}`}
61 <Typography variant='body1' className={props.classes.spacing}>
62 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.
64 <Button variant="contained" color="primary" onClick={() => props.openSetupShellAccount(props.data.uuid)}>
65 {`SETUP SHELL ACCOUNT FOR ${getUserDisplayName(props.data)}`}
67 </DialogContent></span>}
73 onClick={props.closeDialog}>