X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0190f22c054d5257f67af66a9a1f1fa84e062fcc..59329caeae17903b97b90b167df5a8122a0c9d95:/src/views-components/dialog-forms/create-group-dialog.tsx

diff --git a/src/views-components/dialog-forms/create-group-dialog.tsx b/src/views-components/dialog-forms/create-group-dialog.tsx
index 10d60c3ad0..554ad79059 100644
--- a/src/views-components/dialog-forms/create-group-dialog.tsx
+++ b/src/views-components/dialog-forms/create-group-dialog.tsx
@@ -4,16 +4,22 @@
 
 import * as React from 'react';
 import { compose } from "redux";
-import { reduxForm, InjectedFormProps } from 'redux-form';
+import { reduxForm, InjectedFormProps, Field, WrappedFieldArrayProps, FieldArray } from 'redux-form';
 import { withDialog, WithDialogProps } from "~/store/dialog/with-dialog";
 import { FormDialog } from '~/components/form-dialog/form-dialog';
-import { CREATE_GROUP_DIALOG, CREATE_GROUP_FORM } from '~/store/groups-panel/groups-panel-actions';
+import { CREATE_GROUP_DIALOG, CREATE_GROUP_FORM, createGroup, CreateGroupFormData, CREATE_GROUP_NAME_FIELD_NAME, CREATE_GROUP_USERS_FIELD_NAME } from '~/store/groups-panel/groups-panel-actions';
+import { TextField } from '~/components/text-field/text-field';
+import { maxLength } from '~/validators/max-length';
+import { require } from '~/validators/require';
+import { PeopleSelect, Person } from '~/views-components/sharing-dialog/people-select';
 
 export const CreateGroupDialog = compose(
     withDialog(CREATE_GROUP_DIALOG),
-    reduxForm<{}>({
+    reduxForm<CreateGroupFormData>({
         form: CREATE_GROUP_FORM,
-        onSubmit: (data, dispatch) => { return; }
+        onSubmit: (data, dispatch) => {
+            dispatch(createGroup(data));
+        }
     })
 )(
     (props: CreateGroupDialogComponentProps) =>
@@ -25,8 +31,32 @@ export const CreateGroupDialog = compose(
         />
 );
 
-type CreateGroupDialogComponentProps = WithDialogProps<{}> & InjectedFormProps<{}>;
+type CreateGroupDialogComponentProps = WithDialogProps<{}> & InjectedFormProps<CreateGroupFormData>;
 
-const CreateGroupFormFields = (props: CreateGroupDialogComponentProps) => <span>
-    CreateGroupFormFields
-</span>;
+const CreateGroupFormFields = () =>
+    <>
+        <GroupNameField />
+        <UsersField />
+    </>;
+
+const GroupNameField = () =>
+    <Field
+        name={CREATE_GROUP_NAME_FIELD_NAME}
+        component={TextField}
+        validate={GROUP_NAME_VALIDATION}
+        label="Name"
+        autoFocus={true} />;
+
+const GROUP_NAME_VALIDATION = [require, maxLength(255)];
+
+const UsersField = () =>
+    <FieldArray
+        name={CREATE_GROUP_USERS_FIELD_NAME}
+        component={UsersSelect} />;
+
+const UsersSelect = ({ fields }: WrappedFieldArrayProps<Person>) =>
+    <PeopleSelect
+        label='Enter email adresses '
+        items={fields.getAll() || []}
+        onSelect={fields.push}
+        onDelete={fields.remove} />;
