Merge branch 'master' into 14565-admin-managing-user
[arvados.git] / src / views-components / user-dialog / manage-dialog.tsx
index 953e312eea5341550b50f3cf76d10e4ce946f335..8db1e053a49ac081a36799887ab17c5251ee1d57 100644 (file)
@@ -8,9 +8,10 @@ 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 { compose } from "redux";
-import { USER_MANAGE_DIALOG } from "~/store/users/users-actions";
+import { compose, Dispatch } from "redux";
+import { USER_MANAGEMENT_DIALOG, openSetupShellAccount, loginAs } from "~/store/users/users-actions";
 import { UserResource } from "~/models/user";
+import { connect } from "react-redux";
 
 type CssRules = 'spacing';
 
@@ -25,10 +26,21 @@ interface UserManageDataProps {
     data: UserResource;
 }
 
-type UserManageProps = UserManageDataProps & WithStyles<CssRules>;
+interface UserManageActionProps {
+    openSetupShellAccount: (uuid: string) => void;
+    loginAs: (uuid: string) => void;
+}
+
+const mapDispatchToProps = (dispatch: Dispatch) => ({
+    openSetupShellAccount: (uuid: string) => dispatch<any>(openSetupShellAccount(uuid)),
+    loginAs: (uuid: string) => dispatch<any>(loginAs(uuid))
+});
+
+type UserManageProps = UserManageDataProps & UserManageActionProps & WithStyles<CssRules>;
 
 export const UserManageDialog = compose(
-    withDialog(USER_MANAGE_DIALOG),
+    connect(null, mapDispatchToProps),
+    withDialog(USER_MANAGEMENT_DIALOG),
     styles)(
         (props: WithDialogProps<UserManageProps> & UserManageProps) =>
             <Dialog open={props.open}
@@ -40,13 +52,13 @@ export const UserManageDialog = compose(
                     <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.
                     </Typography>
-                    <Button variant="contained" color="primary">
+                    <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.
                     </Typography>
-                    <Button variant="contained" color="primary">
+                    <Button variant="contained" color="primary" onClick={() => props.openSetupShellAccount(props.data.uuid)}>
                         {`SETUP SHELL ACCOUNT FOR ${props.data.firstName} ${props.data.lastName}`}
                     </Button>
                 </DialogContent>