17782: Fixes absolute import paths from '~/somedir/...' to 'somedir/...'
[arvados-workbench2.git] / src / views-components / form-fields / user-form-fields.tsx
index 6dd635b5a8077f60631fc901ad3f26c2780cad8b..92edf6a96fb27f2024c87a5f87d8660d86113707 100644 (file)
@@ -4,25 +4,11 @@
 
 import * as 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";
-
-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" />;
+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 { InputLabel } from "@material-ui/core";
+import { VirtualMachinesResource } from "models/virtual-machines";
 
 export const UserEmailField = () =>
     <Field
@@ -32,23 +18,24 @@ export const UserEmailField = () =>
         autoFocus={true}
         label="Email" />;
 
-export const UserIdentityUrlField = () =>
-    <Field
-        name='identityUrl'
-        component={TextField}
-        validate={USER_LENGTH_VALIDATION}
-        label="Identity URL Prefix" />;
-
-export const UserVirtualMachineField = () =>
-    <Field
-        name='virtualMachine'
-        component={NativeSelectField}
-        validate={USER_LENGTH_VALIDATION}
-        items={['shell']} />;
+export const UserVirtualMachineField = ({ data }: any) =>
+    <div style={{ marginBottom: '21px' }}>
+        <InputLabel>Virtual Machine</InputLabel>
+        <Field
+            name='virtualMachine'
+            component={NativeSelectField}
+            validate={USER_LENGTH_VALIDATION}
+            items={getVirtualMachinesList(data.items)} />
+    </div>;
 
 export const UserGroupsVirtualMachineField = () =>
     <Field
-        name='virtualMachine'
+        name='groups'
         component={TextField}
         validate={USER_LENGTH_VALIDATION}
-        label="Groups for virtual machine (comma separated list)" />;
\ No newline at end of file
+        label="Groups for virtual machine (comma separated list)" />;
+
+const getVirtualMachinesList = (virtualMachines: VirtualMachinesResource[]) => {
+    const mappedVirtualMachines = virtualMachines.map(it => ({ key: it.hostname, value: it.hostname }));
+    return mappedVirtualMachines;
+};