[ARVADOS-WORKBENCH2] updated: 1.3.0-238-g50179896

Git user git at public.curoverse.com
Thu Dec 27 03:36:20 EST 2018


Summary of changes:
 src/store/auth/auth-action-session.ts              |  4 ++--
 src/store/users/users-actions.ts                   | 10 ++++++++++
 src/views-components/user-dialog/manage-dialog.tsx | 10 ++++++----
 src/views/user-panel/user-panel.tsx                | 13 +++----------
 4 files changed, 21 insertions(+), 16 deletions(-)

       via  5017989693137cabe7f00a00c51db35625f9b55f (commit)
      from  fe5d65e4e704358fab18d91dae5a97ff7659f5df (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 5017989693137cabe7f00a00c51db35625f9b55f
Author: Pawel Kowalczyk <pawel.kowalczyk at contractors.roche.com>
Date:   Thu Dec 27 09:36:04 2018 +0100

    login-as-someone
    
    Feature #14565
    
    Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk <pawel.kowalczyk at contractors.roche.com>

diff --git a/src/store/auth/auth-action-session.ts b/src/store/auth/auth-action-session.ts
index e5e2e575..d36d5a33 100644
--- a/src/store/auth/auth-action-session.ts
+++ b/src/store/auth/auth-action-session.ts
@@ -80,7 +80,7 @@ const getSaltedToken = (clusterId: string, tokenUuid: string, token: string) =>
     return `v2/${tokenUuid}/${hmac}`;
 };
 
-const clusterLogin = async (clusterId: string, baseUrl: string, activeSession: Session): Promise<{user: User, token: string}> => {
+const clusterLogin = async (clusterId: string, baseUrl: string, activeSession: Session): Promise<{ user: User, token: string }> => {
     const tokenUuid = await getTokenUuid(activeSession.baseUrl, activeSession.token);
     const saltedToken = getSaltedToken(clusterId, tokenUuid, activeSession.token);
     const user = await getUserDetails(baseUrl, saltedToken);
@@ -207,7 +207,7 @@ export const initSessions = (authService: AuthService, config: Config, user: Use
 export const loadSiteManagerPanel = () =>
     async (dispatch: Dispatch<any>) => {
         try {
-            dispatch(setBreadcrumbs([{ label: 'Site Manager'}]));
+            dispatch(setBreadcrumbs([{ label: 'Site Manager' }]));
             dispatch(validateSessions());
         } catch (e) {
             return;
diff --git a/src/store/users/users-actions.ts b/src/store/users/users-actions.ts
index 9e76396d..e4465ddc 100644
--- a/src/store/users/users-actions.ts
+++ b/src/store/users/users-actions.ts
@@ -12,6 +12,7 @@ import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions
 import { UserResource } from "~/models/user";
 import { getResource } from '~/store/resources/resources';
 import { navigateToProject, navigateToUsers, navigateToRootProject } from "~/store/navigation/navigation-action";
+import { saveApiToken } from '~/store/auth/auth-action';
 
 export const USERS_PANEL_ID = 'usersPanel';
 export const USER_ATTRIBUTES_DIALOG = 'userAttributesDialog';
@@ -44,9 +45,18 @@ export const openSetupShellAccount = (uuid: string) =>
         const { resources } = getState();
         const user = getResource<UserResource>(uuid)(resources);
         const virtualMachines = await services.virtualMachineService.list();
+        dispatch(dialogActions.CLOSE_DIALOG({ id: USER_MANAGE_DIALOG }));
         dispatch(dialogActions.OPEN_DIALOG({ id: SETUP_SHELL_ACCOUNT_DIALOG, data: { user, ...virtualMachines } }));
     };
 
+export const loginAs = (uuid: string) => 
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        const client = await services.apiClientAuthorizationService.get(uuid);
+        dispatch<any>(saveApiToken(client.apiToken));
+        location.reload();
+        dispatch<any>(navigateToRootProject);
+    };
+
 export const openUserCreateDialog = () =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         const userUuid = await services.authService.getUuid();
diff --git a/src/views-components/user-dialog/manage-dialog.tsx b/src/views-components/user-dialog/manage-dialog.tsx
index ddf73fb3..a64b5082 100644
--- a/src/views-components/user-dialog/manage-dialog.tsx
+++ b/src/views-components/user-dialog/manage-dialog.tsx
@@ -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_MANAGE_DIALOG, openSetupShellAccount, loginAs } from "~/store/users/users-actions";
 import { UserResource } from "~/models/user";
 import { connect } from "react-redux";
 
@@ -28,10 +28,12 @@ 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>;
@@ -50,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" onClick={() => props.openSetupShellAccount(props.data.uuid)}>
+                    <Button variant="contained" color="primary" onClick={() => props.openSetupShellAccount(props.data.uuid)} disabled>
                         {`SETUP SHELL ACCOUNT FOR ${props.data.firstName} ${props.data.lastName}`}
                     </Button>
                 </DialogContent>
diff --git a/src/views/user-panel/user-panel.tsx b/src/views/user-panel/user-panel.tsx
index b152896f..c42036ed 100644
--- a/src/views/user-panel/user-panel.tsx
+++ b/src/views/user-panel/user-panel.tsx
@@ -28,6 +28,7 @@ import { compose, Dispatch } from 'redux';
 import { UserResource } from '~/models/user';
 import { ShareMeIcon, AddIcon } from '~/components/icon/icon';
 import { USERS_PANEL_ID, openUserCreateDialog } from '~/store/users/users-actions';
+import { noop } from 'lodash';
 
 type UserPanelRules = "button";
 
@@ -165,8 +166,8 @@ export const UserPanel = compose(
                         <span>
                             <DataExplorer
                                 id={USERS_PANEL_ID}
-                                onRowClick={this.handleRowClick}
-                                onRowDoubleClick={this.handleRowDoubleClick}
+                                onRowClick={noop}
+                                onRowDoubleClick={noop}
                                 onContextMenu={this.handleContextMenu}
                                 contextMenuColumn={true}
                                 hideColumnSelector
@@ -205,13 +206,5 @@ export const UserPanel = compose(
                     });
                 }
             }
-
-            handleRowDoubleClick = (uuid: string) => {
-                this.props.handleRowDoubleClick(uuid);
-            }
-
-            handleRowClick = () => {
-                return;
-            }
         }
     );

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list