18972: Records the last refresh click on localStorage for others to act on.
[arvados-workbench2.git] / src / views-components / sharing-dialog / sharing-invitation-form-component.tsx
index f1eb177becbfd8f33ae57378dbc3effa1ffda1dd..6c0b8d81a3c94f00c8bc223569666e46f6063812 100644 (file)
@@ -2,38 +2,40 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from 'react';
-import { Field, WrappedFieldProps } from 'redux-form';
-import { Grid, Input, FormControl, FormHelperText, FormLabel, InputLabel, Chip } from '@material-ui/core';
-import { ChipsInput } from '~/components/chips-input/chips-input';
-import { identity } from 'lodash';
-import { PermissionSelect } from './permission-select';
-import { PeopleSelect } from './people-select';
-import ChipInput from 'material-ui-chip-input';
+import React from 'react';
+import { Field, WrappedFieldProps, FieldArray, WrappedFieldArrayProps } from 'redux-form';
+import { Grid, FormControl, InputLabel } from '@material-ui/core';
+import { PermissionSelect, parsePermissionLevel, formatPermissionLevel } from './permission-select';
+import { ParticipantSelect, Participant } from './participant-select';
 
 export default () =>
     <Grid container spacing={8}>
-        <Grid item xs={8}>
+        <Grid data-cy="invite-people-field" item xs={8}>
             <InvitedPeopleField />
         </Grid>
-        <Grid item xs={4}>
+        <Grid data-cy="permission-select-field" item xs={4}>
             <PermissionSelectField />
         </Grid>
     </Grid>;
 
 const InvitedPeopleField = () =>
-    <Field
+    <FieldArray
         name='invitedPeople'
-        component={InvitedPeopleFieldComponent} />;
+        component={InvitedPeopleFieldComponent as any} />;
 
 
-const InvitedPeopleFieldComponent = (props: WrappedFieldProps) =>
-    <PeopleSelect suggestedPeople={[]} />;
+const InvitedPeopleFieldComponent = ({ fields }: WrappedFieldArrayProps<Participant>) =>
+    <ParticipantSelect
+        items={fields.getAll() || []}
+        onSelect={fields.push}
+        onDelete={fields.remove} />;
 
 const PermissionSelectField = () =>
     <Field
-        name='permission'
-        component={PermissionSelectComponent} />;
+        name='permissions'
+        component={PermissionSelectComponent}
+        format={formatPermissionLevel}
+        parse={parsePermissionLevel} />;
 
 const PermissionSelectComponent = ({ input }: WrappedFieldProps) =>
     <FormControl fullWidth>