17582: Adds integration test cases exposing the bug.
[arvados-workbench2.git] / src / views-components / form-fields / user-form-fields.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from "react";
6 import { Field } from "redux-form";
7 import { TextField } from "~/components/text-field/text-field";
8 import { USER_EMAIL_VALIDATION, USER_LENGTH_VALIDATION } from "~/validators/validators";
9 import { NativeSelectField } from "~/components/select-field/select-field";
10 import { InputLabel } from "@material-ui/core";
11 import { VirtualMachinesResource } from "~/models/virtual-machines";
12
13 export const UserEmailField = () =>
14     <Field
15         name='email'
16         component={TextField}
17         validate={USER_EMAIL_VALIDATION}
18         autoFocus={true}
19         label="Email" />;
20
21 export const UserVirtualMachineField = ({ data }: any) =>
22     <div style={{ marginBottom: '21px' }}>
23         <InputLabel>Virtual Machine</InputLabel>
24         <Field
25             name='virtualMachine'
26             component={NativeSelectField}
27             validate={USER_LENGTH_VALIDATION}
28             items={getVirtualMachinesList(data.items)} />
29     </div>;
30
31 export const UserGroupsVirtualMachineField = () =>
32     <Field
33         name='groups'
34         component={TextField}
35         validate={USER_LENGTH_VALIDATION}
36         label="Groups for virtual machine (comma separated list)" />;
37
38 const getVirtualMachinesList = (virtualMachines: VirtualMachinesResource[]) => {
39     const mappedVirtualMachines = virtualMachines.map(it => ({ key: it.hostname, value: it.hostname }));
40     return mappedVirtualMachines;
41 };