init-modal
authorPawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>
Mon, 17 Dec 2018 13:35:46 +0000 (14:35 +0100)
committerPawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>
Mon, 17 Dec 2018 13:35:46 +0000 (14:35 +0100)
Feature #14565

Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>

src/store/users/users-actions.ts
src/views-components/context-menu/action-sets/user-action-set.ts
src/views-components/user-dialog/manage-dialog.tsx [new file with mode: 0644]
src/views/workbench/workbench.tsx

index 585a3663bcdf5fabf7b34fe295f0d30981f08fd0..61b5aad43832efb93ba7cb7d83467e3bc4820f9d 100644 (file)
@@ -16,6 +16,7 @@ import { navigateToProject, navigateToUsers, navigateToRootProject } from "~/sto
 export const USERS_PANEL_ID = 'usersPanel';
 export const USER_ATTRIBUTES_DIALOG = 'userAttributesDialog';
 export const USER_CREATE_FORM_NAME = 'userCreateFormName';
+export const USER_MANAGE_DIALOG = 'userManageDialog';
 
 export interface UserCreateFormDialogData {
     email: string;
@@ -31,6 +32,13 @@ export const openUserAttributes = (uuid: string) =>
         dispatch(dialogActions.OPEN_DIALOG({ id: USER_ATTRIBUTES_DIALOG, data }));
     };
 
+export const openUserManage = (uuid: string) =>
+    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        const { resources } = getState();
+        const data = getResource<UserResource>(uuid)(resources);
+        dispatch(dialogActions.OPEN_DIALOG({ id: USER_MANAGE_DIALOG, data }));
+    };
+
 export const openUserCreateDialog = () =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         const userUuid = await services.authService.getUuid();
index 7b0884e668b02ef9f3c5f30bf4c2b2eab3607873..c1b559fe50b5e9241169260791423fb1dd500a75 100644 (file)
@@ -5,7 +5,7 @@
 import { ContextMenuActionSet } from "~/views-components/context-menu/context-menu-action-set";
 import { AdvancedIcon, ProjectIcon, AttributesIcon, UserPanelIcon } from "~/components/icon/icon";
 import { openAdvancedTabDialog } from '~/store/advanced-tab/advanced-tab';
-import { openUserAttributes, openUserProjects } from "~/store/users/users-actions";
+import { openUserAttributes, openUserProjects, openUserManage } from "~/store/users/users-actions";
 
 export const userActionSet: ContextMenuActionSet = [[{
     name: "Attributes",
@@ -25,11 +25,10 @@ export const userActionSet: ContextMenuActionSet = [[{
     execute: (dispatch, { uuid }) => {
         dispatch<any>(openAdvancedTabDialog(uuid));
     }
-},
-{
+}, {
     name: "Manage",
     icon: UserPanelIcon,
     execute: (dispatch, { uuid }) => {
-        dispatch<any>(openAdvancedTabDialog(uuid));
+        dispatch<any>(openUserManage(uuid));
     }
 }]];
diff --git a/src/views-components/user-dialog/manage-dialog.tsx b/src/views-components/user-dialog/manage-dialog.tsx
new file mode 100644 (file)
index 0000000..953e312
--- /dev/null
@@ -0,0 +1,62 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { Dialog, DialogTitle, DialogContent, DialogActions, Button, Typography } from "@material-ui/core";
+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 { UserResource } from "~/models/user";
+
+type CssRules = 'spacing';
+
+const styles = withStyles<CssRules>((theme: ArvadosTheme) => ({
+    spacing: {
+        paddingBottom: theme.spacing.unit * 2,
+        paddingTop: theme.spacing.unit * 2,
+    }
+}));
+
+interface UserManageDataProps {
+    data: UserResource;
+}
+
+type UserManageProps = UserManageDataProps & WithStyles<CssRules>;
+
+export const UserManageDialog = compose(
+    withDialog(USER_MANAGE_DIALOG),
+    styles)(
+        (props: WithDialogProps<UserManageProps> & UserManageProps) =>
+            <Dialog open={props.open}
+                onClose={props.closeDialog}
+                fullWidth
+                maxWidth="md">
+                <DialogTitle>{`Manage - ${props.data.firstName} ${props.data.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">
+                        {`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">
+                        {`SETUP SHELL ACCOUNT FOR ${props.data.firstName} ${props.data.lastName}`}
+                    </Button>
+                </DialogContent>
+                <DialogActions>
+                    <Button
+                        variant='flat'
+                        color='primary'
+                        onClick={props.closeDialog}>
+                        Close
+                </Button>
+                </DialogActions>
+            </Dialog>
+    );
index 025540e22ed89c6bab5ecd1a9dee6ddc11281a94..b9c41bef5a691db01a24070c3fea04355783b580 100644 (file)
@@ -79,6 +79,7 @@ import { UserPanel } from '~/views/user-panel/user-panel';
 import { UserAttributesDialog } from '~/views-components/user-dialog/attributes-dialog';
 import { CreateUserDialog } from '~/views-components/dialog-forms/create-user-dialog';
 import { HelpApiClientAuthorizationDialog } from '~/views-components/api-client-authorizations-dialog/help-dialog';
+import { UserManageDialog } from '~/views-components/user-dialog/manage-dialog';
 
 type CssRules = 'root' | 'container' | 'splitter' | 'asidePanel' | 'contentWrapper' | 'content';
 
@@ -213,6 +214,7 @@ export const WorkbenchPanel =
             <UpdateProcessDialog />
             <UpdateProjectDialog />
             <UserAttributesDialog />
+            <UserManageDialog />
             <VirtualMachineAttributesDialog />
         </Grid>
     );
\ No newline at end of file