1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from "react";
6 import { Field } from "redux-form";
7 import { TextField } from "components/text-field/text-field";
8 import { USER_EMAIL_VALIDATION, CHOOSE_VM_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 import { VIRTUAL_MACHINE_ADD_LOGIN_GROUPS_FIELD, VIRTUAL_MACHINE_ADD_LOGIN_VM_FIELD } from "store/virtual-machines/virtual-machines-actions";
13 import { GroupArrayInput } from "views-components/virtual-machines-dialog/group-array-input";
15 interface VirtualMachinesProps {
17 items: VirtualMachinesResource[];
21 export const UserEmailField = () =>
24 component={TextField as any}
25 validate={USER_EMAIL_VALIDATION}
29 export const RequiredUserVirtualMachineField = ({ data }: VirtualMachinesProps) =>
30 <div style={{ marginBottom: '21px' }}>
31 <InputLabel>Virtual Machine</InputLabel>
33 name={VIRTUAL_MACHINE_ADD_LOGIN_VM_FIELD}
34 component={NativeSelectField as any}
35 validate={CHOOSE_VM_VALIDATION}
36 items={getVirtualMachinesList(data.items)} />
39 export const UserVirtualMachineField = ({ data }: VirtualMachinesProps) =>
40 <div style={{ marginBottom: '21px' }}>
41 <InputLabel>Virtual Machine</InputLabel>
43 name={VIRTUAL_MACHINE_ADD_LOGIN_VM_FIELD}
44 component={NativeSelectField as any}
45 items={getVirtualMachinesList(data.items)} />
48 export const UserGroupsVirtualMachineField = () =>
50 name={VIRTUAL_MACHINE_ADD_LOGIN_GROUPS_FIELD}
51 input={{id:"Add groups to VM login (eg: docker, sudo)", disabled:false}}
55 const getVirtualMachinesList = (virtualMachines: VirtualMachinesResource[]) =>
56 [{ key: "", value: "" }].concat(virtualMachines.map(it => ({ key: it.uuid, value: it.hostname })));