From c1787278642d2ef02234ea27f94aaae9cdd52d40 Mon Sep 17 00:00:00 2001 From: Michal Klobukowski Date: Sat, 18 Aug 2018 11:20:35 +0200 Subject: [PATCH] Implement rename dialog usinf FormDialog Feature #14015 Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski --- src/components/form-dialog/form-dialog.tsx | 68 ++++++++----------- .../rename-file-dialog/rename-file-dialog.tsx | 36 +++++++--- 2 files changed, 58 insertions(+), 46 deletions(-) diff --git a/src/components/form-dialog/form-dialog.tsx b/src/components/form-dialog/form-dialog.tsx index 29c0b1635f..dee89249e2 100644 --- a/src/components/form-dialog/form-dialog.tsx +++ b/src/components/form-dialog/form-dialog.tsx @@ -8,7 +8,7 @@ import { Dialog, DialogActions, DialogContent, DialogTitle } from '@material-ui/ import { Button, StyleRulesCallback, WithStyles, withStyles, CircularProgress } from '@material-ui/core'; import { WithDialogProps } from '~/store/dialog/with-dialog'; -type CssRules = "button" | "lastButton" | "formContainer" | "textField" | "dialog" | "dialogTitle" | "progressIndicator" | "dialogActions"; +type CssRules = "button" | "lastButton" | "formContainer" | "dialogTitle" | "progressIndicator" | "dialogActions"; const styles: StyleRulesCallback = theme => ({ button: { @@ -26,13 +26,6 @@ const styles: StyleRulesCallback = theme => ({ dialogTitle: { paddingBottom: "0" }, - textField: { - marginTop: "32px", - }, - dialog: { - minWidth: "600px", - minHeight: "320px" - }, progressIndicator: { position: "absolute", minWidth: "20px", @@ -45,7 +38,7 @@ const styles: StyleRulesCallback = theme => ({ interface DialogProjectProps { cancelLabel?: string; dialogTitle: string; - formFields: React.ComponentType>; + formFields: React.ComponentType & WithDialogProps>; submitLabel?: string; } @@ -54,35 +47,34 @@ export const FormDialog = withStyles(styles)((props: DialogProjectProps & WithDi open={props.open} onClose={props.closeDialog} disableBackdropClick={props.submitting} - disableEscapeKeyDown={props.submitting}> -
-
- - {props.dialogTitle} - - - - - - - - -
-
+ disableEscapeKeyDown={props.submitting} + fullWidth> +
+ + {props.dialogTitle} + + + + + + + + +
); diff --git a/src/views-components/rename-file-dialog/rename-file-dialog.tsx b/src/views-components/rename-file-dialog/rename-file-dialog.tsx index 37028f9db5..f23d4c06a4 100644 --- a/src/views-components/rename-file-dialog/rename-file-dialog.tsx +++ b/src/views-components/rename-file-dialog/rename-file-dialog.tsx @@ -2,11 +2,14 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { Dispatch } from "redux"; -import { reduxForm, reset, startSubmit, stopSubmit } from "redux-form"; -import { withDialog } from "~/store/dialog/with-dialog"; +import * as React from 'react'; +import { Dispatch, compose } from 'redux'; +import { reduxForm, reset, startSubmit, stopSubmit, InjectedFormProps, Field } from 'redux-form'; +import { withDialog, WithDialogProps } from '~/store/dialog/with-dialog'; import { dialogActions } from "~/store/dialog/dialog-actions"; -import { RenameDialog } from "~/components/rename-dialog/rename-dialog"; +import { FormDialog } from '~/components/form-dialog/form-dialog'; +import { DialogContentText } from '@material-ui/core'; +import { TextField } from '~/components/text-field/text-field'; export const RENAME_FILE_DIALOG = 'renameFileDialog'; @@ -16,13 +19,30 @@ export const openRenameFileDialog = (originalName: string) => dispatch(dialogActions.OPEN_DIALOG({ id: RENAME_FILE_DIALOG, data: originalName })); }; -export const [RenameFileDialog] = [RenameDialog] - .map(withDialog(RENAME_FILE_DIALOG)) - .map(reduxForm({ +export const RenameFileDialog = compose( + withDialog(RENAME_FILE_DIALOG), + reduxForm({ form: RENAME_FILE_DIALOG, onSubmit: (data, dispatch) => { dispatch(startSubmit(RENAME_FILE_DIALOG)); // TODO: call collection file renaming action here setTimeout(() => dispatch(stopSubmit(RENAME_FILE_DIALOG, { name: 'Invalid name' })), 2000); } - })); + }) +)((props: WithDialogProps & InjectedFormProps<{ name: string }>) => + ); + +const RenameDialogFormFields = (props: WithDialogProps) => <> + + {`Please, enter a new name for ${props.data}`} + + +; -- 2.39.5