From 864465d579c4b2caf06fce87b1861674758135f6 Mon Sep 17 00:00:00 2001 From: Stephen Smith Date: Mon, 28 Mar 2022 16:11:51 -0400 Subject: [PATCH] 18559: Move user admin functions to context menu Arvados-DCO-1.1-Signed-off-by: Stephen Smith --- src/components/icon/icon.tsx | 6 +- .../user-profile/user-profile-actions.ts | 1 - .../action-sets/user-action-set.ts | 42 ++++++++-- .../user-profile-panel-root.tsx | 84 ------------------- .../user-profile-panel/user-profile-panel.tsx | 6 +- 5 files changed, 40 insertions(+), 99 deletions(-) diff --git a/src/components/icon/icon.tsx b/src/components/icon/icon.tsx index 54b7bee6..20ce62c1 100644 --- a/src/components/icon/icon.tsx +++ b/src/components/icon/icon.tsx @@ -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) => ; export const CanWriteIcon: IconType = (props) => ; export const CanManageIcon: IconType = (props) => ; export const AddUserIcon: IconType = (props) => ; +export const DeactivateUserIcon: IconType = (props) => ; +export const LoginAsIcon: IconType = (props) => ; diff --git a/src/store/user-profile/user-profile-actions.ts b/src/store/user-profile/user-profile-actions.ts index 6042efa9..c8556862 100644 --- a/src/store/user-profile/user-profile-actions.ts +++ b/src/store/user-profile/user-profile-actions.ts @@ -75,7 +75,6 @@ export const openSetupDialog = (uuid: string) => })); } - export const setup = (uuid: string) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { try { diff --git a/src/views-components/context-menu/action-sets/user-action-set.ts b/src/views-components/context-menu/action-sets/user-action-set.ts index 2edb12d9..0b2ff379 100644 --- a/src/views-components/context-menu/action-sets/user-action-set.ts +++ b/src/views-components/context-menu/action-sets/user-action-set.ts @@ -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(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(openUserManagement(uuid)); + dispatch(openAdvancedTabDialog(uuid)); + } +}, { + name: "Setup User", + icon: AdminMenuIcon, + execute: (dispatch, { uuid }) => { + dispatch(openSetupDialog(uuid)); + } +}, { + name: "Deactivate User", + icon: DeactivateUserIcon, + execute: (dispatch, { uuid }) => { + dispatch(openDeactivateDialog(uuid)); + } +}, { + name: "Login As User", + icon: LoginAsIcon, + execute: (dispatch, { uuid }) => { + dispatch(loginAs(uuid)); } -} */ +}, + ]]; diff --git a/src/views/user-profile-panel/user-profile-panel-root.tsx b/src/views/user-profile-panel/user-profile-panel-root.tsx index 4fab7efd..0beeab4f 100644 --- a/src/views/user-profile-panel/user-profile-panel-root.tsx +++ b/src/views/user-profile-panel/user-profile-panel-root.tsx @@ -13,7 +13,6 @@ import { StyleRulesCallback, WithStyles, withStyles, - Card, CardContent, Button, Typography, @@ -84,9 +83,6 @@ const styles: StyleRulesCallback = (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)( - {this.props.isAdmin && } {this.state.value === TABS.PROFILE && @@ -335,84 +329,6 @@ export const UserProfilePanelRoot = withStyles(styles)( messages={['Group list is empty.']} /> } /> } - {this.props.isAdmin && this.state.value === TABS.ADMIN && - - - - - - - Setup Account - - - 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. - - - - - - - - - - - - - - Deactivate - - - 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. - - - - - - - - - - - - - - Log In - - - 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. - - - - - - - - - } ; } diff --git a/src/views/user-profile-panel/user-profile-panel.tsx b/src/views/user-profile-panel/user-profile-panel.tsx index 7a55faf3..207a98fe 100644 --- a/src/views/user-profile-panel/user-profile-panel.tsx +++ b/src/views/user-profile-panel/user-profile-panel.tsx @@ -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(openSetupDialog(uuid)), - loginAs: (uuid: string) => dispatch(loginAs(uuid)), - openDeactivateDialog: (uuid: string) => dispatch(openDeactivateDialog(uuid)), handleContextMenu: (event, resource: UserResource) => dispatch(openUserContextMenu(event, resource)), }); -- 2.30.2