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 { UserResource } from "~/models/user";
14 import { connect } from "react-redux";
16 type CssRules = 'spacing';
18 const styles = withStyles<CssRules>((theme: ArvadosTheme) => ({
20 paddingBottom: theme.spacing.unit * 2,
21 paddingTop: theme.spacing.unit * 2,
25 interface UserManageDataProps {
29 interface UserManageActionProps {
30 openSetupShellAccount: (uuid: string) => void;
31 loginAs: (uuid: string) => void;
34 const mapDispatchToProps = (dispatch: Dispatch) => ({
35 openSetupShellAccount: (uuid: string) => dispatch<any>(openSetupShellAccount(uuid)),
36 loginAs: (uuid: string) => dispatch<any>(loginAs(uuid))
39 type UserManageProps = UserManageDataProps & UserManageActionProps & WithStyles<CssRules>;
41 export const UserManageDialog = compose(
42 connect(null, mapDispatchToProps),
43 withDialog(USER_MANAGEMENT_DIALOG),
45 (props: WithDialogProps<UserManageProps> & UserManageProps) =>
46 <Dialog open={props.open}
47 onClose={props.closeDialog}
52 <DialogTitle>{`Manage - ${props.data.user.firstName} ${props.data.user.lastName}`}</DialogTitle>
54 <Typography variant="body2" className={props.classes.spacing}>
55 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.
57 <Button variant="contained" color="primary" onClick={() => props.loginAs(props.data.client.uuid)}>
58 {`LOG IN AS ${props.data.user.firstName} ${props.data.user.lastName}`}
60 <Typography variant="body2" className={props.classes.spacing}>
61 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.
63 <Button variant="contained" color="primary" onClick={() => props.openSetupShellAccount(props.data.uuid)}>
64 {`SETUP SHELL ACCOUNT FOR ${props.data.user.firstName} ${props.data.user.lastName}`}
66 </DialogContent></span>}
72 onClick={props.closeDialog}>