[ARVADOS-WORKBENCH2] updated: 1.1.4-637-gc4c906c

Git user git at public.curoverse.com
Fri Aug 17 11:12:29 EDT 2018


Summary of changes:
 src/components/form-dialog/form-dialog.tsx         | 89 ++++++++++++++++++++++
 .../dialog-collection-create-selected.tsx          | 71 +++++++----------
 2 files changed, 115 insertions(+), 45 deletions(-)
 create mode 100644 src/components/form-dialog/form-dialog.tsx

       via  c4c906cb232d8974858e4da2393fb7a83a24fbd0 (commit)
      from  25aa8a7c81609525d300f38bc5b7d2344c4e1cdf (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit c4c906cb232d8974858e4da2393fb7a83a24fbd0
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Fri Aug 17 16:38:28 2018 +0200

    Extract form dialog component
    
    Feature #14014
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/components/form-dialog/form-dialog.tsx b/src/components/form-dialog/form-dialog.tsx
new file mode 100644
index 0000000..29c0b16
--- /dev/null
+++ b/src/components/form-dialog/form-dialog.tsx
@@ -0,0 +1,89 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { InjectedFormProps } from 'redux-form';
+import { Dialog, DialogActions, DialogContent, DialogTitle } from '@material-ui/core/';
+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";
+
+const styles: StyleRulesCallback<CssRules> = theme => ({
+    button: {
+        marginLeft: theme.spacing.unit
+    },
+    lastButton: {
+        marginLeft: theme.spacing.unit,
+        marginRight: "20px",
+    },
+    formContainer: {
+        display: "flex",
+        flexDirection: "column",
+        marginTop: "20px",
+    },
+    dialogTitle: {
+        paddingBottom: "0"
+    },
+    textField: {
+        marginTop: "32px",
+    },
+    dialog: {
+        minWidth: "600px",
+        minHeight: "320px"
+    },
+    progressIndicator: {
+        position: "absolute",
+        minWidth: "20px",
+    },
+    dialogActions: {
+        marginBottom: "24px"
+    }
+});
+
+interface DialogProjectProps {
+    cancelLabel?: string;
+    dialogTitle: string;
+    formFields: React.ComponentType<InjectedFormProps<any>>;
+    submitLabel?: string;
+}
+
+export const FormDialog = withStyles(styles)((props: DialogProjectProps & WithDialogProps<{}> & InjectedFormProps<any> & WithStyles<CssRules>) =>
+    <Dialog
+        open={props.open}
+        onClose={props.closeDialog}
+        disableBackdropClick={props.submitting}
+        disableEscapeKeyDown={props.submitting}>
+        <div className={props.classes.dialog}>
+            <form>
+                <DialogTitle className={props.classes.dialogTitle}>
+                    {props.dialogTitle}
+                </DialogTitle>
+                <DialogContent className={props.classes.formContainer}>
+                    <props.formFields {...props} />
+                </DialogContent>
+                <DialogActions className={props.classes.dialogActions}>
+                    <Button
+                        onClick={props.closeDialog}
+                        className={props.classes.button}
+                        color="primary"
+                        disabled={props.submitting}>
+                        {props.cancelLabel || 'Cancel'}
+                    </Button>
+                    <Button
+                        onClick={props.handleSubmit}
+                        className={props.classes.lastButton}
+                        color="primary"
+                        disabled={props.invalid || props.submitting || props.pristine}
+                        variant="contained">
+                        {props.submitLabel || 'Submit'}
+                        {props.submitting && <CircularProgress size={20} className={props.classes.progressIndicator} />}
+                    </Button>
+                </DialogActions>
+            </form>
+        </div>
+    </Dialog>
+);
+
+
diff --git a/src/views-components/dialog-create/dialog-collection-create-selected.tsx b/src/views-components/dialog-create/dialog-collection-create-selected.tsx
index af2536d..7083747 100644
--- a/src/views-components/dialog-create/dialog-collection-create-selected.tsx
+++ b/src/views-components/dialog-create/dialog-collection-create-selected.tsx
@@ -4,57 +4,38 @@
 
 import * as React from "react";
 import { InjectedFormProps, Field, WrappedFieldProps } from "redux-form";
-import { Dialog, DialogTitle, DialogContent, DialogActions, Button, CircularProgress } from "@material-ui/core";
 import { WithDialogProps } from "~/store/dialog/with-dialog";
 import { TextField } from "~/components/text-field/text-field";
 import { COLLECTION_NAME_VALIDATION, COLLECTION_DESCRIPTION_VALIDATION, COLLECTION_PROJECT_VALIDATION } from "~/validators/validators";
 import { ProjectTreePicker } from "../project-tree-picker/project-tree-picker";
+import { FormDialog } from '../../components/form-dialog/form-dialog';
 
 export const DialogCollectionCreateWithSelected = (props: WithDialogProps<string> & InjectedFormProps<{ name: string }>) =>
-    <form>
-        <Dialog open={props.open}
-            disableBackdropClick={true}
-            disableEscapeKeyDown={true}>
-            <DialogTitle>Create a collection</DialogTitle>
-            <DialogContent style={{ display: 'flex' }}>
-                <div>
-                    <Field
-                        name='name'
-                        component={TextField}
-                        validate={COLLECTION_NAME_VALIDATION}
-                        label="Collection Name" />
-                    <Field
-                        name='description'
-                        component={TextField}
-                        validate={COLLECTION_DESCRIPTION_VALIDATION}
-                        label="Description - optional" />
-                </div>
-                <Field
-                    name="projectUuid"
-                    component={Picker}
-                    validate={COLLECTION_PROJECT_VALIDATION} />
-            </DialogContent>
-            <DialogActions>
-                <Button
-                    variant='flat'
-                    color='primary'
-                    disabled={props.submitting}
-                    onClick={props.closeDialog}>
-                    Cancel
-                    </Button>
-                <Button
-                    variant='contained'
-                    color='primary'
-                    type='submit'
-                    onClick={props.handleSubmit}
-                    disabled={props.pristine || props.invalid || props.submitting}>
-                    {props.submitting
-                        ? <CircularProgress size={20} />
-                        : 'Create a collection'}
-                </Button>
-            </DialogActions>
-        </Dialog>
-    </form>;
+    <FormDialog
+        dialogTitle='Create a collection'
+        formFields={FormFields}
+        submitLabel='Create a collection'
+        {...props}
+    />;
+
+const FormFields = () => <div style={{ display: 'flex' }}>
+    <div>
+        <Field
+            name='name'
+            component={TextField}
+            validate={COLLECTION_NAME_VALIDATION}
+            label="Collection Name" />
+        <Field
+            name='description'
+            component={TextField}
+            validate={COLLECTION_DESCRIPTION_VALIDATION}
+            label="Description - optional" />
+    </div>
+    <Field
+        name="projectUuid"
+        component={Picker}
+        validate={COLLECTION_PROJECT_VALIDATION} />
+</div>;
 
 const Picker = (props: WrappedFieldProps) =>
     <div style={{ width: '400px', height: '144px', display: 'flex', flexDirection: 'column' }}>

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list