From: Pawel Kowalczyk Date: Tue, 18 Dec 2018 09:09:50 +0000 (+0100) Subject: Merge branch 'master' into 14565-admin-managing-user X-Git-Tag: 1.4.0~86^2~4 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/6faff5910b3e7bdaf47ab5ede7cf8094a1b4adb9?hp=b6f9b49e6fed67626ae969a6864f45f002fcfd47 Merge branch 'master' into 14565-admin-managing-user refs #14565 Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk --- diff --git a/src/store/users/users-actions.ts b/src/store/users/users-actions.ts index 585a3663..9e76396d 100644 --- a/src/store/users/users-actions.ts +++ b/src/store/users/users-actions.ts @@ -16,10 +16,11 @@ 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 const SETUP_SHELL_ACCOUNT_DIALOG = 'setupShellAccountDialog'; export interface UserCreateFormDialogData { email: string; - identityUrl: string; virtualMachineName: string; groupVirtualMachine: string; } @@ -31,6 +32,21 @@ 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(uuid)(resources); + dispatch(dialogActions.OPEN_DIALOG({ id: USER_MANAGE_DIALOG, data })); + }; + +export const openSetupShellAccount = (uuid: string) => + async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + const { resources } = getState(); + const user = getResource(uuid)(resources); + const virtualMachines = await services.virtualMachineService.list(); + dispatch(dialogActions.OPEN_DIALOG({ id: SETUP_SHELL_ACCOUNT_DIALOG, data: { user, ...virtualMachines } })); + }; + export const openUserCreateDialog = () => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { const userUuid = await services.authService.getUuid(); 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 7b0884e6..c1b559fe 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 @@ -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(openAdvancedTabDialog(uuid)); } -}, -{ +}, { name: "Manage", icon: UserPanelIcon, execute: (dispatch, { uuid }) => { - dispatch(openAdvancedTabDialog(uuid)); + dispatch(openUserManage(uuid)); } }]]; diff --git a/src/views-components/dialog-create/dialog-user-create.tsx b/src/views-components/dialog-create/dialog-user-create.tsx index 14365af7..06db5873 100644 --- a/src/views-components/dialog-create/dialog-user-create.tsx +++ b/src/views-components/dialog-create/dialog-user-create.tsx @@ -6,7 +6,7 @@ import * as React from 'react'; import { InjectedFormProps } from 'redux-form'; import { WithDialogProps } from '~/store/dialog/with-dialog'; import { FormDialog } from '~/components/form-dialog/form-dialog'; -import { UserEmailField, UserIdentityUrlField, UserVirtualMachineField, UserGroupsVirtualMachineField } from '~/views-components/form-fields/user-form-fields'; +import { UserEmailField, UserVirtualMachineField, UserGroupsVirtualMachineField } from '~/views-components/form-fields/user-form-fields'; export type DialogUserProps = WithDialogProps<{}> & InjectedFormProps; @@ -20,7 +20,6 @@ export const UserRepositoryCreate = (props: DialogUserProps) => const UserAddFields = (props: DialogUserProps) => - ; diff --git a/src/views-components/dialog-forms/setup-shell-account-dialog.tsx b/src/views-components/dialog-forms/setup-shell-account-dialog.tsx new file mode 100644 index 00000000..8b9a6b61 --- /dev/null +++ b/src/views-components/dialog-forms/setup-shell-account-dialog.tsx @@ -0,0 +1,79 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 +import * as React from 'react'; +import { compose } from "redux"; +import { reduxForm, InjectedFormProps, Field } from 'redux-form'; +import { withDialog, WithDialogProps } from "~/store/dialog/with-dialog"; +import { FormDialog } from '~/components/form-dialog/form-dialog'; +import { TextField } from '~/components/text-field/text-field'; +import { VirtualMachinesResource } from '~/models/virtual-machines'; +import { USER_LENGTH_VALIDATION } from '~/validators/validators'; +import { InputLabel } from '@material-ui/core'; +import { NativeSelectField } from '~/components/select-field/select-field'; +import { SETUP_SHELL_ACCOUNT_DIALOG, createUser } from '~/store/users/users-actions'; + +interface SetupShellAccountFormDialogData { + email: string; + virtualMachineName: string; + groupVirtualMachine: string; +} + +export const SetupShellAccountDialog = compose( + withDialog(SETUP_SHELL_ACCOUNT_DIALOG), + reduxForm({ + form: SETUP_SHELL_ACCOUNT_DIALOG, + onSubmit: (data, dispatch) => { + dispatch(createUser(data)); + } + }) +)( + (props: SetupShellAccountDialogComponentProps) => + +); + +const UserEmailField = ({ data }: any) => + ; + +const UserVirtualMachineField = ({ data }: any) => +
+ Virtual Machine + +
; + +const UserGroupsVirtualMachineField = () => + ; + +const getVirtualMachinesList = (virtualMachines: VirtualMachinesResource[]) => { + const mappedVirtualMachines = virtualMachines.map(it => ({ key: it.hostname, value: it.hostname })); + return mappedVirtualMachines; +}; + +type SetupShellAccountDialogComponentProps = WithDialogProps<{}> & InjectedFormProps; + +const SetupShellAccountFormFields = (props: SetupShellAccountDialogComponentProps) => + <> + + + + ; + + + diff --git a/src/views-components/form-fields/user-form-fields.tsx b/src/views-components/form-fields/user-form-fields.tsx index 85634449..11d7d802 100644 --- a/src/views-components/form-fields/user-form-fields.tsx +++ b/src/views-components/form-fields/user-form-fields.tsx @@ -18,13 +18,6 @@ export const UserEmailField = () => autoFocus={true} label="Email" />; -export const UserIdentityUrlField = () => - ; - export const UserVirtualMachineField = ({ data }: any) =>
Virtual Machine diff --git a/src/views-components/user-dialog/manage-dialog.tsx b/src/views-components/user-dialog/manage-dialog.tsx new file mode 100644 index 00000000..ddf73fb3 --- /dev/null +++ b/src/views-components/user-dialog/manage-dialog.tsx @@ -0,0 +1,72 @@ +// 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, Dispatch } from "redux"; +import { USER_MANAGE_DIALOG, openSetupShellAccount } from "~/store/users/users-actions"; +import { UserResource } from "~/models/user"; +import { connect } from "react-redux"; + +type CssRules = 'spacing'; + +const styles = withStyles((theme: ArvadosTheme) => ({ + spacing: { + paddingBottom: theme.spacing.unit * 2, + paddingTop: theme.spacing.unit * 2, + } +})); + +interface UserManageDataProps { + data: UserResource; +} + +interface UserManageActionProps { + openSetupShellAccount: (uuid: string) => void; +} + +const mapDispatchToProps = (dispatch: Dispatch) => ({ + openSetupShellAccount: (uuid: string) => dispatch(openSetupShellAccount(uuid)) +}); + +type UserManageProps = UserManageDataProps & UserManageActionProps & WithStyles; + +export const UserManageDialog = compose( + connect(null, mapDispatchToProps), + withDialog(USER_MANAGE_DIALOG), + styles)( + (props: WithDialogProps & UserManageProps) => + + {`Manage - ${props.data.firstName} ${props.data.lastName}`} + + + 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. + + + + 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. + + + + + + + + ); diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx index bff328e8..6c7c2438 100644 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@ -79,6 +79,8 @@ 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'; +import { SetupShellAccountDialog } from '~/views-components/dialog-forms/setup-shell-account-dialog'; import { GroupsPanel } from '~/views/groups-panel/groups-panel'; import { CreateGroupDialog } from '~/views-components/dialog-forms/create-group-dialog'; import { RemoveGroupDialog } from '~/views-components/groups-dialog/remove-dialog'; @@ -223,12 +225,14 @@ export const WorkbenchPanel = + + ); \ No newline at end of file