Neither "log in as user" nor "setup VM for user" works, so hide it
[arvados-workbench2.git] / src / views-components / dialog-forms / setup-shell-account-dialog.tsx
index c53f53c2ad90346572ff53cdf7ccd7a975238218..7e8a657ac032e70e7c9884e1578667d2d5e889b4 100644 (file)
@@ -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<SetupShellAccountFormDialogData>({
         form: SETUP_SHELL_ACCOUNT_DIALOG,
         onSubmit: (data, dispatch) => {
-            dispatch(createUser(data));
+            dispatch(setupUserVM(data));
         }
     })
 )(
@@ -68,7 +62,7 @@ const UserVirtualMachineField = ({ data }: VirtualMachinesProps) =>
         <Field
             name='virtualMachine'
             component={NativeSelectField}
-            validate={USER_LENGTH_VALIDATION}
+            validate={CHOOSE_VM_VALIDATION}
             items={getVirtualMachinesList(data.items)} />
     </div>;
 
@@ -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<SetupShellAccountFormDialogData>;
 
@@ -90,6 +84,3 @@ const SetupShellAccountFormFields = (props: SetupShellAccountDialogComponentProp
         <UserVirtualMachineField data={props.data as DataProps} />
         <UserGroupsVirtualMachineField />
     </>;
-
-
-