};
export const openUserManagement = (uuid: string) =>
- (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
const { resources } = getState();
- const data = getResource<UserResource>(uuid)(resources);
- dispatch(dialogActions.OPEN_DIALOG({ id: USER_MANAGEMENT_DIALOG, data }));
+ const user = getResource<UserResource>(uuid)(resources);
+ const clients = await services.apiClientAuthorizationService.list();
+ dispatch(dialogActions.OPEN_DIALOG({ id: USER_MANAGEMENT_DIALOG, data: { user, ...clients } }));
};
export const openSetupShellAccount = (uuid: string) =>
dispatch(dialogActions.OPEN_DIALOG({ id: SETUP_SHELL_ACCOUNT_DIALOG, data: { user, ...virtualMachines } }));
};
-export const loginAs = (createdAt: string) =>
+export const loginAs = (uuid: string) =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const clients = await services.apiClientAuthorizationService.list();
- const client = clients.items.find(it => it.createdAt === createdAt);
- dispatch<any>(saveApiToken(client!.apiToken));
+ const client = await services.apiClientAuthorizationService.get(uuid);
+ dispatch<any>(saveApiToken(client.apiToken));
dispatch<any>(getUserDetails()).then(() => {
location.reload();
dispatch<any>(navigateToRootProject);
export const loadUsersPanel = () =>
(dispatch: Dispatch) => {
dispatch(userBindedActions.REQUEST_ITEMS());
- };
\ No newline at end of file
+ };
import { USER_MANAGEMENT_DIALOG, openSetupShellAccount, loginAs } from "~/store/users/users-actions";
import { UserResource } from "~/models/user";
import { connect } from "react-redux";
+import { ApiClientAuthorization } from '~/models/api-client-authorization';
type CssRules = 'spacing';
}));
interface UserManageDataProps {
- data: UserResource;
+ data: {
+ user: UserResource;
+ client: ApiClientAuthorization;
+ };
}
interface UserManageActionProps {
onClose={props.closeDialog}
fullWidth
maxWidth="md">
- <DialogTitle>{`Manage - ${props.data.firstName} ${props.data.lastName}`}</DialogTitle>
+ <DialogTitle>{`Manage - ${props.data.user.firstName} ${props.data.user.lastName}`}</DialogTitle>
<DialogContent>
<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" onClick={() => props.loginAs(props.data.createdAt)}>
- {`LOG IN AS ${props.data.firstName} ${props.data.lastName}`}
+ <Button variant="contained" color="primary" onClick={() => props.loginAs(props.data.client.uuid)}>
+ {`LOG IN AS ${props.data.user.firstName} ${props.data.user.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" onClick={() => props.openSetupShellAccount(props.data.uuid)}>
- {`SETUP SHELL ACCOUNT FOR ${props.data.firstName} ${props.data.lastName}`}
+ <Button variant="contained" color="primary" onClick={() => props.openSetupShellAccount(props.data.user.uuid)}>
+ {`SETUP SHELL ACCOUNT FOR ${props.data.user.firstName} ${props.data.user.lastName}`}
</Button>
</DialogContent>
<DialogActions>