18559: Move user admin functions to context menu
authorStephen Smith <stephen@curii.com>
Mon, 28 Mar 2022 20:11:51 +0000 (16:11 -0400)
committerStephen Smith <stephen@curii.com>
Mon, 28 Mar 2022 20:11:51 +0000 (16:11 -0400)
Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen@curii.com>

src/components/icon/icon.tsx
src/store/user-profile/user-profile-actions.ts
src/views-components/context-menu/action-sets/user-action-set.ts
src/views/user-profile-panel/user-profile-panel-root.tsx
src/views/user-profile-panel/user-profile-panel.tsx

index 54b7bee6cd827b044af7dd88197ae7c76e4a8d82..20ce62c12996bb0f90a3d25d5327b1cfe73a050a 100644 (file)
@@ -65,11 +65,13 @@ import VpnKey from '@material-ui/icons/VpnKey';
 import LinkOutlined from '@material-ui/icons/LinkOutlined';
 import RemoveRedEye from '@material-ui/icons/RemoveRedEye';
 import Computer from '@material-ui/icons/Computer';
+import CropFreeSharp from '@material-ui/icons/CropFreeSharp';
+import Cancel from '@material-ui/icons/Cancel';
+import ExitToApp from '@material-ui/icons/ExitToApp';
 
 // Import FontAwesome icons
 import { library } from '@fortawesome/fontawesome-svg-core';
 import { faPencilAlt, faSlash, faUsers, faEllipsisH } from '@fortawesome/free-solid-svg-icons';
-import { CropFreeSharp } from '@material-ui/icons';
 library.add(
     faPencilAlt,
     faSlash,
@@ -173,3 +175,5 @@ export const CanReadIcon: IconType = (props) => <RemoveRedEye {...props} />;
 export const CanWriteIcon: IconType = (props) => <Edit {...props} />;
 export const CanManageIcon: IconType = (props) => <Computer {...props} />;
 export const AddUserIcon: IconType = (props) => <PersonAdd {...props} />;
+export const DeactivateUserIcon: IconType = (props) => <Cancel {...props} />;
+export const LoginAsIcon: IconType = (props) => <ExitToApp {...props} />;
index 6042efa9984c1bcefdf28cbef94060ead45298b5..c8556862a1db7be46ff78fb18ad97a87594919d2 100644 (file)
@@ -75,7 +75,6 @@ export const openSetupDialog = (uuid: string) =>
   }));
 }
 
-
 export const setup = (uuid: string) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         try {
index 2edb12d9fdb1e22a2d4b8255cc6205a5cceb9147..0b2ff379b04928c817fbc769b4f89e7f98f9b103 100644 (file)
@@ -3,9 +3,18 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { ContextMenuActionSet } from "views-components/context-menu/context-menu-action-set";
-import { AdvancedIcon, ProjectIcon, AttributesIcon } from "components/icon/icon";
+import {
+    AdvancedIcon,
+    ProjectIcon,
+    AttributesIcon,
+    DeactivateUserIcon,
+    UserPanelIcon,
+    LoginAsIcon,
+    AdminMenuIcon,
+} from "components/icon/icon";
 import { openAdvancedTabDialog } from 'store/advanced-tab/advanced-tab';
-import { openUserAttributes, openUserProjects } from "store/users/users-actions";
+import { loginAs, openUserAttributes, openUserProjects } from "store/users/users-actions";
+import { openSetupDialog, openDeactivateDialog } from "store/user-profile/user-profile-actions";
 
 export const userActionSet: ContextMenuActionSet = [[{
     name: "Attributes",
@@ -25,13 +34,30 @@ export const userActionSet: ContextMenuActionSet = [[{
     execute: (dispatch, { uuid }) => {
         dispatch<any>(openAdvancedTabDialog(uuid));
     }
-}, /*
-    // Neither of the buttons on this dialog work correctly (bugs #16114 and #16124) so hide it for now.
-    {
-    name: "Manage",
+}, {
+    name: "Account Settings",
     icon: UserPanelIcon,
     execute: (dispatch, { uuid }) => {
-        dispatch<any>(openUserManagement(uuid));
+        dispatch<any>(openAdvancedTabDialog(uuid));
+    }
+}, {
+    name: "Setup User",
+    icon: AdminMenuIcon,
+    execute: (dispatch, { uuid }) => {
+        dispatch<any>(openSetupDialog(uuid));
+    }
+}, {
+    name: "Deactivate User",
+    icon: DeactivateUserIcon,
+    execute: (dispatch, { uuid }) => {
+        dispatch<any>(openDeactivateDialog(uuid));
+    }
+}, {
+    name: "Login As User",
+    icon: LoginAsIcon,
+    execute: (dispatch, { uuid }) => {
+        dispatch<any>(loginAs(uuid));
     }
-} */
+},
+
 ]];
index 4fab7efd404b4396b018926d0fbed3d28a4c43c1..0beeab4fbc020fa60978e3c4f1def37d245c7032 100644 (file)
@@ -13,7 +13,6 @@ import {
     StyleRulesCallback,
     WithStyles,
     withStyles,
-    Card,
     CardContent,
     Button,
     Typography,
@@ -84,9 +83,6 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
 });
 
 export interface UserProfilePanelRootActionProps {
-    openSetupDialog: (uuid: string) => void;
-    loginAs: (uuid: string) => void;
-    openDeactivateDialog: (uuid: string) => void;
     handleContextMenu: (event, resource: UserResource) => void;
 }
 
@@ -124,7 +120,6 @@ export enum UserProfileGroupsColumnNames {
 enum TABS {
     PROFILE = "PROFILE",
     GROUPS = "GROUPS",
-    ADMIN = "ADMIN",
 
 }
 
@@ -202,7 +197,6 @@ export const UserProfilePanelRoot = withStyles(styles)(
                 <Tabs value={this.state.value} onChange={this.handleChange} variant={"fullWidth"}>
                     <Tab label={TABS.PROFILE} value={TABS.PROFILE} />
                     <Tab label={TABS.GROUPS} value={TABS.GROUPS} />
-                    {this.props.isAdmin && <Tab label={TABS.ADMIN} value={TABS.ADMIN} />}
                 </Tabs>
                 {this.state.value === TABS.PROFILE &&
                     <CardContent>
@@ -335,84 +329,6 @@ export const UserProfilePanelRoot = withStyles(styles)(
                                         messages={['Group list is empty.']} />
                                 } />
                     </div>}
-                {this.props.isAdmin && this.state.value === TABS.ADMIN &&
-                    <Paper elevation={0} className={this.props.classes.adminRoot}>
-                        <Card elevation={0}>
-                            <CardContent>
-                                <Grid container
-                                    direction="row"
-                                    justify={'flex-end'}
-                                    alignItems={'center'}>
-                                    <Grid item xs>
-                                        <Typography variant="h6" className={this.props.classes.title}>
-                                            Setup Account
-                                        </Typography>
-                                        <Typography variant="body1" className={this.props.classes.description}>
-                                            This button sets up a user. After setup, they will be able use Arvados. This dialog box also allows you to optionally set up a shell account for this user. The login name is automatically generated from the user's e-mail address.
-                                        </Typography>
-                                    </Grid>
-                                    <Grid item sm={'auto'} xs={12}>
-                                        <Button variant="contained"
-                                            color="primary"
-                                            onClick={() => {this.props.openSetupDialog(this.props.userUuid)}}
-                                            disabled={false}>
-                                            Setup Account
-                                        </Button>
-                                    </Grid>
-                                </Grid>
-                            </CardContent>
-                        </Card>
-                        <Card elevation={0}>
-                            <CardContent>
-                                <Grid container
-                                    direction="row"
-                                    justify={'flex-end'}
-                                    alignItems={'center'}>
-                                    <Grid item xs>
-                                        <Typography variant="h6" className={this.props.classes.title}>
-                                            Deactivate
-                                        </Typography>
-                                        <Typography variant="body1" className={this.props.classes.description}>
-                                            As an admin, you can deactivate and reset this user. This will remove all repository/VM permissions for the user. If you "setup" the user again, the user will have to sign the user agreement again. You may also want to reassign data ownership.
-                                        </Typography>
-                                    </Grid>
-                                    <Grid item sm={'auto'} xs={12}>
-                                        <Button variant="contained"
-                                            color="primary"
-                                            onClick={() => {this.props.openDeactivateDialog(this.props.userUuid)}}
-                                            disabled={false}>
-                                            Deactivate
-                                        </Button>
-                                    </Grid>
-                                </Grid>
-                            </CardContent>
-                        </Card>
-                        <Card elevation={0}>
-                            <CardContent>
-                                <Grid container
-                                    direction="row"
-                                    justify={'flex-end'}
-                                    alignItems={'center'}>
-                                    <Grid item xs>
-                                        <Typography variant="h6" className={this.props.classes.title}>
-                                            Log In
-                                        </Typography>
-                                        <Typography variant="body1" className={this.props.classes.description}>
-                                            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>
-                                    </Grid>
-                                    <Grid item sm={'auto'} xs={12}>
-                                        <Button variant="contained"
-                                            color="primary"
-                                            onClick={() => {this.props.loginAs(this.props.userUuid)}}
-                                            disabled={false}>
-                                            Log In
-                                        </Button>
-                                    </Grid>
-                                </Grid>
-                            </CardContent>
-                        </Card>
-                    </Paper>}
             </Paper >;
         }
 
index 7a55faf3300c2f5e6f218c010f429b34d7e95d0e..207a98fee171df5e779086ae9b1ca5c7eaf53189 100644 (file)
@@ -9,9 +9,8 @@ import { connect } from 'react-redux';
 import { UserResource } from 'models/user';
 import { saveEditedUser } from 'store/user-profile/user-profile-actions';
 import { UserProfilePanelRoot, UserProfilePanelRootDataProps } from 'views/user-profile-panel/user-profile-panel-root';
-import { openSetupDialog, openDeactivateDialog, USER_PROFILE_FORM } from "store/user-profile/user-profile-actions";
+import { USER_PROFILE_FORM } from "store/user-profile/user-profile-actions";
 import { matchUserProfileRoute } from 'routes/routes';
-import { loginAs } from 'store/users/users-actions';
 import { openUserContextMenu } from 'store/context-menu/context-menu-actions';
 
 const mapStateToProps = (state: RootState): UserProfilePanelRootDataProps => {
@@ -30,9 +29,6 @@ const mapStateToProps = (state: RootState): UserProfilePanelRootDataProps => {
 }};
 
 const mapDispatchToProps = (dispatch: Dispatch) => ({
-    openSetupDialog: (uuid: string) => dispatch<any>(openSetupDialog(uuid)),
-    loginAs: (uuid: string) => dispatch<any>(loginAs(uuid)),
-    openDeactivateDialog: (uuid: string) => dispatch<any>(openDeactivateDialog(uuid)),
     handleContextMenu: (event, resource: UserResource) => dispatch<any>(openUserContextMenu(event, resource)),
 });