refs #14565-login-as-someone-by-created-at-prop
[arvados-workbench2.git] / src / views-components / user-dialog / manage-dialog.tsx
index ddf73fb3de65f4da31ebda2e48ce7f527da9f342..59779928dae2f92af5697efe5e7849be3d38ca15 100644 (file)
@@ -9,7 +9,7 @@ import { withDialog } from '~/store/dialog/with-dialog';
 import { WithStyles, withStyles } from '@material-ui/core/styles';
 import { ArvadosTheme } from '~/common/custom-theme';
 import { compose, Dispatch } from "redux";
-import { USER_MANAGE_DIALOG, openSetupShellAccount } from "~/store/users/users-actions";
+import { USER_MANAGEMENT_DIALOG, openSetupShellAccount, loginAs } from "~/store/users/users-actions";
 import { UserResource } from "~/models/user";
 import { connect } from "react-redux";
 
@@ -28,17 +28,19 @@ interface UserManageDataProps {
 
 interface UserManageActionProps {
     openSetupShellAccount: (uuid: string) => void;
+    loginAs: (uuid: string) => void;
 }
 
 const mapDispatchToProps = (dispatch: Dispatch) => ({
-    openSetupShellAccount: (uuid: string) => dispatch<any>(openSetupShellAccount(uuid))
+    openSetupShellAccount: (uuid: string) => dispatch<any>(openSetupShellAccount(uuid)),
+    loginAs: (uuid: string) => dispatch<any>(loginAs(uuid))
 });
 
 type UserManageProps = UserManageDataProps & UserManageActionProps & WithStyles<CssRules>;
 
 export const UserManageDialog = compose(
     connect(null, mapDispatchToProps),
-    withDialog(USER_MANAGE_DIALOG),
+    withDialog(USER_MANAGEMENT_DIALOG),
     styles)(
         (props: WithDialogProps<UserManageProps> & UserManageProps) =>
             <Dialog open={props.open}
@@ -50,7 +52,7 @@ 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.createdAt)}>
                         {`LOG IN AS ${props.data.firstName} ${props.data.lastName}`}
                     </Button>
                     <Typography variant="body2" className={props.classes.spacing}>