From a6fff3efaf195a82d9d912fa9ab134a9d9e05c48 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Tue, 4 Feb 2020 17:56:12 -0500 Subject: [PATCH] Neither "log in as user" nor "setup VM for user" works, so hide it To be reenabled when the corresponding bugs are fixed: refs #16114 refs #16124 Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- src/store/users/users-actions.ts | 23 +++++++++++++++++++ src/validators/validators.tsx | 2 ++ .../action-sets/user-action-set.ts | 11 +++++---- .../setup-shell-account-dialog.tsx | 19 ++++----------- 4 files changed, 37 insertions(+), 18 deletions(-) diff --git a/src/store/users/users-actions.ts b/src/store/users/users-actions.ts index f6287260..7b12fe75 100644 --- a/src/store/users/users-actions.ts +++ b/src/store/users/users-actions.ts @@ -27,6 +27,12 @@ export interface UserCreateFormDialogData { groupVirtualMachine: string; } +export interface SetupShellAccountFormDialogData { + email: string; + virtualMachineName: string; + groupVirtualMachine: string; +} + export const openUserAttributes = (uuid: string) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { const { resources } = getState(); @@ -94,6 +100,23 @@ export const createUser = (user: UserCreateFormDialogData) => } }; + +export const setupUserVM = (setupData: SetupShellAccountFormDialogData) => + async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + dispatch(startSubmit(USER_CREATE_FORM_NAME)); + try { + // TODO: make correct API call + // const setupResult = await services.userService.setup({ ...setupData }); + dispatch(dialogActions.CLOSE_DIALOG({ id: SETUP_SHELL_ACCOUNT_DIALOG })); + dispatch(reset(SETUP_SHELL_ACCOUNT_DIALOG)); + dispatch(snackbarActions.OPEN_SNACKBAR({ message: "User has been added to VM.", hideDuration: 2000, kind: SnackbarKind.SUCCESS })); + dispatch(loadUsersPanel()); + dispatch(userBindedActions.REQUEST_ITEMS()); + } catch (e) { + return; + } + }; + export const openUserPanel = () => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { const user = getState().auth.user; diff --git a/src/validators/validators.tsx b/src/validators/validators.tsx index 605d051c..d9eca97f 100644 --- a/src/validators/validators.tsx +++ b/src/validators/validators.tsx @@ -38,3 +38,5 @@ export const SSH_KEY_NAME_VALIDATION = [require, maxLength(255)]; export const SITE_MANAGER_REMOTE_HOST_VALIDATION = [require, isRemoteHost, maxLength(255)]; export const MY_ACCOUNT_VALIDATION = [require]; + +export const CHOOSE_VM_VALIDATION = [require]; 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 d2b97d15..2582800e 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,9 @@ // SPDX-License-Identifier: AGPL-3.0 import { ContextMenuActionSet } from "~/views-components/context-menu/context-menu-action-set"; -import { AdvancedIcon, ProjectIcon, AttributesIcon, UserPanelIcon } from "~/components/icon/icon"; +import { AdvancedIcon, ProjectIcon, AttributesIcon } from "~/components/icon/icon"; import { openAdvancedTabDialog } from '~/store/advanced-tab/advanced-tab'; -import { openUserAttributes, openUserProjects, openUserManagement } from "~/store/users/users-actions"; +import { openUserAttributes, openUserProjects } from "~/store/users/users-actions"; export const userActionSet: ContextMenuActionSet = [[{ name: "Attributes", @@ -25,10 +25,13 @@ 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", icon: UserPanelIcon, execute: (dispatch, { uuid }) => { dispatch(openUserManagement(uuid)); } -}]]; +} */ +]]; diff --git a/src/views-components/dialog-forms/setup-shell-account-dialog.tsx b/src/views-components/dialog-forms/setup-shell-account-dialog.tsx index c53f53c2..7e8a657a 100644 --- a/src/views-components/dialog-forms/setup-shell-account-dialog.tsx +++ b/src/views-components/dialog-forms/setup-shell-account-dialog.tsx @@ -8,24 +8,18 @@ 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 { USER_LENGTH_VALIDATION, CHOOSE_VM_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'; +import { SetupShellAccountFormDialogData, SETUP_SHELL_ACCOUNT_DIALOG, setupUserVM } from '~/store/users/users-actions'; import { UserResource } from '~/models/user'; -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)); + dispatch(setupUserVM(data)); } }) )( @@ -68,7 +62,7 @@ const UserVirtualMachineField = ({ data }: VirtualMachinesProps) => ; @@ -80,7 +74,7 @@ const UserGroupsVirtualMachineField = () => label="Groups for virtual machine (comma separated list)" />; const getVirtualMachinesList = (virtualMachines: VirtualMachinesResource[]) => - virtualMachines.map(it => ({ key: it.hostname, value: it.hostname })); + [{ key: "", value: "" }].concat(virtualMachines.map(it => ({ key: it.hostname, value: it.hostname }))); type SetupShellAccountDialogComponentProps = WithDialogProps<{}> & InjectedFormProps; @@ -90,6 +84,3 @@ const SetupShellAccountFormFields = (props: SetupShellAccountDialogComponentProp ; - - - -- 2.30.2