X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/32f8f97903802e58b48ed307669c236750d8ee3e..4c34de655fc7f8839b205b48f460a168f302dd63:/src/views-components/form-fields/user-form-fields.tsx

diff --git a/src/views-components/form-fields/user-form-fields.tsx b/src/views-components/form-fields/user-form-fields.tsx
index 6dd635b5..12fc91e2 100644
--- a/src/views-components/form-fields/user-form-fields.tsx
+++ b/src/views-components/form-fields/user-form-fields.tsx
@@ -2,53 +2,55 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from "react";
+import React from "react";
 import { Field } from "redux-form";
-import { TextField } from "~/components/text-field/text-field";
-import { USER_EMAIL_VALIDATION, USER_LENGTH_VALIDATION } from "~/validators/validators";
-import { NativeSelectField } from "~/components/select-field/select-field";
+import { TextField } from "components/text-field/text-field";
+import { USER_EMAIL_VALIDATION, CHOOSE_VM_VALIDATION } from "validators/validators";
+import { NativeSelectField } from "components/select-field/select-field";
+import { InputLabel } from "@material-ui/core";
+import { VirtualMachinesResource } from "models/virtual-machines";
+import { VIRTUAL_MACHINE_ADD_LOGIN_GROUPS_FIELD, VIRTUAL_MACHINE_ADD_LOGIN_VM_FIELD } from "store/virtual-machines/virtual-machines-actions";
+import { GroupArrayInput } from "views-components/virtual-machines-dialog/group-array-input";
 
-export const UserFirstNameField = () =>
-    <Field
-        name='firstName'
-        component={TextField}
-        validate={USER_LENGTH_VALIDATION}
-        autoFocus={true}
-        label="First name" />;
-
-export const UserLastNameField = () =>
-    <Field
-        name='lastName'
-        component={TextField}
-        validate={USER_LENGTH_VALIDATION}
-        autoFocus={true}
-        label="Last name" />;
+interface VirtualMachinesProps {
+    data: {
+        items: VirtualMachinesResource[];
+    };
+}
 
 export const UserEmailField = () =>
     <Field
         name='email'
-        component={TextField}
+        component={TextField as any}
         validate={USER_EMAIL_VALIDATION}
         autoFocus={true}
         label="Email" />;
 
-export const UserIdentityUrlField = () =>
-    <Field
-        name='identityUrl'
-        component={TextField}
-        validate={USER_LENGTH_VALIDATION}
-        label="Identity URL Prefix" />;
+export const RequiredUserVirtualMachineField = ({ data }: VirtualMachinesProps) =>
+    <div style={{ marginBottom: '21px' }}>
+        <InputLabel>Virtual Machine</InputLabel>
+        <Field
+            name={VIRTUAL_MACHINE_ADD_LOGIN_VM_FIELD}
+            component={NativeSelectField as any}
+            validate={CHOOSE_VM_VALIDATION}
+            items={getVirtualMachinesList(data.items)} />
+    </div>;
 
-export const UserVirtualMachineField = () =>
-    <Field
-        name='virtualMachine'
-        component={NativeSelectField}
-        validate={USER_LENGTH_VALIDATION}
-        items={['shell']} />;
+export const UserVirtualMachineField = ({ data }: VirtualMachinesProps) =>
+    <div style={{ marginBottom: '21px' }}>
+        <InputLabel>Virtual Machine</InputLabel>
+        <Field
+            name={VIRTUAL_MACHINE_ADD_LOGIN_VM_FIELD}
+            component={NativeSelectField as any}
+            items={getVirtualMachinesList(data.items)} />
+    </div>;
 
 export const UserGroupsVirtualMachineField = () =>
-    <Field
-        name='virtualMachine'
-        component={TextField}
-        validate={USER_LENGTH_VALIDATION}
-        label="Groups for virtual machine (comma separated list)" />;
\ No newline at end of file
+    <GroupArrayInput
+        name={VIRTUAL_MACHINE_ADD_LOGIN_GROUPS_FIELD}
+        input={{id:"Add groups to VM login (eg: docker, sudo)", disabled:false}}
+        required={false}
+    />
+
+const getVirtualMachinesList = (virtualMachines: VirtualMachinesResource[]) =>
+    [{ key: "", value: "" }].concat(virtualMachines.map(it => ({ key: it.uuid, value: it.hostname })));
