1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { Field, WrappedFieldProps, FieldArray, WrappedFieldArrayProps } from 'redux-form';
7 import { Grid, FormControl, InputLabel } from '@material-ui/core';
8 import { PermissionSelect, parsePermissionLevel, formatPermissionLevel } from './permission-select';
9 import { ParticipantSelect, Participant } from './participant-select';
12 <Grid container spacing={8}>
13 <Grid data-cy="invite-people-field" item xs={8}>
14 <InvitedPeopleField />
16 <Grid data-cy="permission-select-field" item xs={4}>
17 <PermissionSelectField />
21 const InvitedPeopleField = () =>
24 component={InvitedPeopleFieldComponent as any} />;
27 const InvitedPeopleFieldComponent = ({ fields }: WrappedFieldArrayProps<Participant>) =>
29 items={fields.getAll() || []}
30 onSelect={fields.push}
31 onDelete={fields.remove} />;
33 const PermissionSelectField = () =>
36 component={PermissionSelectComponent}
37 format={formatPermissionLevel}
38 parse={parsePermissionLevel} />;
40 const PermissionSelectComponent = ({ input }: WrappedFieldProps) =>
41 <FormControl fullWidth>
42 <InputLabel>Authorization</InputLabel>
43 <PermissionSelect {...input} />