18123: Add group rename dialog
authorStephen Smith <stephen@curii.com>
Tue, 9 Nov 2021 20:40:06 +0000 (15:40 -0500)
committerStephen Smith <stephen@curii.com>
Fri, 19 Nov 2021 19:36:15 +0000 (14:36 -0500)
Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen@curii.com>

src/views-components/dialog-forms/rename-group-dialog.tsx [new file with mode: 0644]

diff --git a/src/views-components/dialog-forms/rename-group-dialog.tsx b/src/views-components/dialog-forms/rename-group-dialog.tsx
new file mode 100644 (file)
index 0000000..72f09d7
--- /dev/null
@@ -0,0 +1,55 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import React from 'react';
+import { compose, Dispatch } from 'redux';
+import { reduxForm, InjectedFormProps, Field } from 'redux-form';
+import { withDialog, WithDialogProps } from 'store/dialog/with-dialog';
+import { FormDialog } from 'components/form-dialog/form-dialog';
+import { DialogContentText } from '@material-ui/core';
+import { TextField } from 'components/text-field/text-field';
+import { GroupResource } from 'models/group';
+import { RENAME_GROUP_DIALOG, RENAME_GROUP_NAME_FIELD_NAME, RenameGroupFormData, renameGroup } from 'store/groups-panel/groups-panel-actions';
+// import { WarningCollection } from 'components/warning-collection/warning-collection';
+import { RENAME_FILE_VALIDATION } from 'validators/validators';
+
+export const RenameGroupDialog = compose(
+    withDialog(RENAME_GROUP_DIALOG),
+    reduxForm<RenameGroupFormData>({
+        form: RENAME_GROUP_DIALOG,
+        // touchOnChange: true,
+        onSubmit: (data: RenameGroupFormData, dispatch: Dispatch) => {
+            console.log(data);
+            // dispatch<any>(renameGroup(data));
+        }
+    })
+)((props: RenameGroupDialogProps) =>
+    <FormDialog
+        dialogTitle='Rename'
+        formFields={RenameGroupFormFields}
+        submitLabel='Ok'
+        {...props}
+    />);
+
+interface RenameGroupDataProps {
+    data: GroupResource;
+}
+
+type RenameGroupDialogProps = RenameGroupDataProps & WithDialogProps<{}> & InjectedFormProps<RenameGroupFormData>;
+
+const RenameGroupFormFields = (props: RenameGroupDialogProps) => {
+    // console.log(props);
+    return <>
+        <DialogContentText>
+            {`Please enter a new name for ${props.data.name}`}
+        </DialogContentText>
+        <Field
+            name={RENAME_GROUP_NAME_FIELD_NAME}
+            component={TextField as any}
+            autoFocus={true}
+            validate={RENAME_FILE_VALIDATION}
+        />
+        {/* <WarningCollection text="Renaming a file will change the collection's content address." /> */}
+    </>;
+}