Merge branch '21412-user-profile-bugs'
[arvados.git] / services / workbench2 / src / views-components / dialog-create / dialog-user-create.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import React from 'react';
6 import { InjectedFormProps } from 'redux-form';
7 import { WithDialogProps } from 'store/dialog/with-dialog';
8 import { FormDialog } from 'components/form-dialog/form-dialog';
9 import { UserEmailField, UserVirtualMachineField, UserGroupsVirtualMachineField } from 'views-components/form-fields/user-form-fields';
10 import { UserCreateFormDialogData } from 'store/users/users-actions';
11 import { UserResource } from 'models/user';
12 import { VirtualMachinesResource } from 'models/virtual-machines';
13
14 export type DialogUserProps = WithDialogProps<{}> & InjectedFormProps<UserCreateFormDialogData>;
15
16 interface DataProps {
17     user: UserResource;
18     items: VirtualMachinesResource[];
19 }
20
21 export const UserRepositoryCreate = (props: DialogUserProps) =>
22     <FormDialog
23         dialogTitle='New user'
24         formFields={UserAddFields}
25         submitLabel='ADD NEW USER'
26         {...props}
27     />;
28
29 const UserAddFields = (props: DialogUserProps) => <span>
30     <UserEmailField />
31     <UserVirtualMachineField data={props.data as DataProps}/>
32     <UserGroupsVirtualMachineField />
33 </span>;