store - remove collection creator, modify modla for adding collection
authorJanicki Artur <artur.janicki@contractors.roche.com>
Thu, 23 Aug 2018 14:11:54 +0000 (16:11 +0200)
committerJanicki Artur <artur.janicki@contractors.roche.com>
Thu, 23 Aug 2018 14:11:54 +0000 (16:11 +0200)
Feature #14103

Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki@contractors.roche.com>

14 files changed:
src/store/collections/collection-create-actions.ts [new file with mode: 0644]
src/store/collections/collection-update-actions.ts
src/store/collections/collections-reducer.ts
src/store/collections/creator/collection-creator-action.ts [deleted file]
src/store/collections/creator/collection-creator-reducer.test.ts [deleted file]
src/store/collections/creator/collection-creator-reducer.ts [deleted file]
src/views-components/context-menu/action-sets/collection-action-set.ts
src/views-components/context-menu/action-sets/collection-resource-action-set.ts
src/views-components/context-menu/action-sets/root-project-action-set.ts
src/views-components/create-collection-dialog/create-collection-dialog.tsx [deleted file]
src/views-components/dialog-create/dialog-collection-create.tsx
src/views-components/dialog-forms/create-collection-dialog.ts [new file with mode: 0644]
src/views-components/dialog-forms/update-collection-dialog.ts [moved from src/views-components/update-collection-dialog/update-collection-dialog.ts with 54% similarity]
src/views/workbench/workbench.tsx

diff --git a/src/store/collections/collection-create-actions.ts b/src/store/collections/collection-create-actions.ts
new file mode 100644 (file)
index 0000000..66f5ab8
--- /dev/null
@@ -0,0 +1,54 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch } from "redux";
+import { reset, startSubmit, stopSubmit } from "redux-form";
+import { RootState } from '~/store/store';
+import { uploadCollectionFiles } from '~/store/collections/uploader/collection-uploader-actions';
+import { projectPanelActions } from "~/store/project-panel/project-panel-action";
+import { snackbarActions } from "~/store/snackbar/snackbar-actions";
+import { dialogActions } from "~/store/dialog/dialog-actions";
+import { CollectionResource } from '~/models/collection';
+import { ServiceRepository } from '~/services/services';
+import { getCommonResourceServiceError, CommonResourceServiceError } from "~/common/api/common-resource-service";
+
+export interface CollectionCreateFormDialogData {
+    name: string;
+    description: string;
+    files: File[];
+}
+
+export const COLLECTION_CREATE_FORM_NAME = "collectionCreateDialog";
+
+export const openCreateModal = () =>
+    (dispatch: Dispatch) => {
+        dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_CREATE_FORM_NAME, data: {} }));
+    };
+
+export const addCollection = (data: CollectionCreateFormDialogData) =>
+    async (dispatch: Dispatch) => {
+        await dispatch<any>(createCollection(data));
+        dispatch(snackbarActions.OPEN_SNACKBAR({
+            message: "Collection has been successfully created.",
+            hideDuration: 2000
+        }));
+    };
+
+export const createCollection = (collection: Partial<CollectionResource>) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        dispatch(startSubmit(COLLECTION_CREATE_FORM_NAME));
+        try {
+            const newCollection = await services.collectionService.create(collection);
+            await dispatch<any>(uploadCollectionFiles(newCollection.uuid));
+            dispatch(projectPanelActions.REQUEST_ITEMS());
+            dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_CREATE_FORM_NAME }));
+            dispatch(reset(COLLECTION_CREATE_FORM_NAME));
+            // return newCollection;
+        } catch (e) {
+            const error = getCommonResourceServiceError(e);
+            if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
+                dispatch(stopSubmit(COLLECTION_CREATE_FORM_NAME, { name: 'Collection with the same name already exists.' }));
+            }
+        }
+    };
\ No newline at end of file
index 13df864df2dd0c5b06bd5d49f71b523ad5f10db0..4c4ad3bf711f290571e41f66546a3a55f23551a5 100644 (file)
@@ -3,11 +3,8 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { Dispatch } from "redux";
-import { getCommonResourceServiceError, CommonResourceServiceError } from "~/common/api/common-resource-service";
-import { ServiceRepository } from "~/services/services";
-import { CollectionResource } from '~/models/collection';
-import { RootState } from "~/store/store";
 import { initialize, startSubmit, stopSubmit } from 'redux-form';
+import { RootState } from "~/store/store";
 import { collectionPanelActions } from "~/store/collection-panel/collection-panel-action";
 import { updateDetails } from "~/store/details-panel/details-panel-action";
 import { dialogActions } from "~/store/dialog/dialog-actions";
@@ -15,6 +12,9 @@ import { dataExplorerActions } from "~/store/data-explorer/data-explorer-action"
 import { snackbarActions } from "~/store/snackbar/snackbar-actions";
 import { ContextMenuResource } from '~/store/context-menu/context-menu-reducer';
 import { PROJECT_PANEL_ID } from "~/views/project-panel/project-panel";
+import { getCommonResourceServiceError, CommonResourceServiceError } from "~/common/api/common-resource-service";
+import { ServiceRepository } from "~/services/services";
+import { CollectionResource } from '~/models/collection';
 
 export interface CollectionUpdateFormDialogData {
     uuid: string;
@@ -22,12 +22,12 @@ export interface CollectionUpdateFormDialogData {
     description: string;
 }
 
-export const COLLECTION_FORM_NAME = 'collectionEditDialog';
+export const COLLECTION_UPDATE_FORM_NAME = 'collectionUpdateDialog';
 
-export const openUpdater = (resource: ContextMenuResource) =>
+export const openUpdateModal = (resource: ContextMenuResource) =>
     (dispatch: Dispatch) => {
-        dispatch(initialize(COLLECTION_FORM_NAME, resource));
-        dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_FORM_NAME, data: {} }));
+        dispatch(initialize(COLLECTION_UPDATE_FORM_NAME, resource));
+        dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_UPDATE_FORM_NAME, data: {} }));
     };
 
 export const editCollection = (data: CollectionUpdateFormDialogData) =>
@@ -42,17 +42,17 @@ export const editCollection = (data: CollectionUpdateFormDialogData) =>
 export const updateCollection = (collection: Partial<CollectionResource>) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         const uuid = collection.uuid || '';
-        dispatch(startSubmit(COLLECTION_FORM_NAME));
+        dispatch(startSubmit(COLLECTION_UPDATE_FORM_NAME));
         try {
             const updatedCollection = await services.collectionService.update(uuid, collection);
             dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: updatedCollection as CollectionResource }));
             dispatch<any>(updateDetails(updatedCollection));
             dispatch(dataExplorerActions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID }));
-            dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_FORM_NAME }));
+            dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_UPDATE_FORM_NAME }));
         } catch(e) {
             const error = getCommonResourceServiceError(e);
             if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
-                dispatch(stopSubmit(COLLECTION_FORM_NAME, { name: 'Collection with the same name already exists.' }));
+                dispatch(stopSubmit(COLLECTION_UPDATE_FORM_NAME, { name: 'Collection with the same name already exists.' }));
             }
         }
     };
\ No newline at end of file
index 892a1ffceebc2e65a5f5095a6de62bcff9a01589..c7601505cbd270c587a1ae9ec3f0e04ad354980a 100644 (file)
@@ -3,15 +3,12 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { combineReducers } from 'redux';
-import { collectionCreatorReducer, CollectionCreatorState } from "./creator/collection-creator-reducer";
 import { collectionUploaderReducer, CollectionUploaderState } from "./uploader/collection-uploader-reducer";
 
 export type CollectionsState = {
-    creator: CollectionCreatorState;
     uploader: CollectionUploaderState
 };
 
 export const collectionsReducer = combineReducers({
-    creator: collectionCreatorReducer,
     uploader: collectionUploaderReducer
 });
diff --git a/src/store/collections/creator/collection-creator-action.ts b/src/store/collections/creator/collection-creator-action.ts
deleted file mode 100644 (file)
index 8c35ffa..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-import { default as unionize, ofType, UnionOf } from "unionize";
-import { Dispatch } from "redux";
-
-import { RootState } from "../../store";
-import { CollectionResource } from '~/models/collection';
-import { ServiceRepository } from "~/services/services";
-import { uploadCollectionFiles } from '../uploader/collection-uploader-actions';
-import { reset } from "redux-form";
-
-export const collectionCreateActions = unionize({
-    OPEN_COLLECTION_CREATOR: ofType<{ ownerUuid: string }>(),
-    CLOSE_COLLECTION_CREATOR: ofType<{}>(),
-    CREATE_COLLECTION: ofType<{}>(),
-    CREATE_COLLECTION_SUCCESS: ofType<{}>(),
-}, {
-        tag: 'type',
-        value: 'payload'
-    });
-
-export type CollectionCreateAction = UnionOf<typeof collectionCreateActions>;
-
-export const createCollection = (collection: Partial<CollectionResource>, files: File[]) =>
-    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        const { ownerUuid } = getState().collections.creator;
-        const collectiontData = { ownerUuid, ...collection };
-        dispatch(collectionCreateActions.CREATE_COLLECTION(collectiontData));
-        const newCollection = await services.collectionService.create(collectiontData);
-        await dispatch<any>(uploadCollectionFiles(newCollection.uuid));
-        dispatch(collectionCreateActions.CREATE_COLLECTION_SUCCESS(collection));
-        dispatch(reset('collectionCreateDialog'));
-        return newCollection;
-    };
-
diff --git a/src/store/collections/creator/collection-creator-reducer.test.ts b/src/store/collections/creator/collection-creator-reducer.test.ts
deleted file mode 100644 (file)
index 5aa9dcf..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-import { collectionCreatorReducer } from "./collection-creator-reducer";
-import { collectionCreateActions } from "./collection-creator-action";
-
-describe('collection-reducer', () => {
-
-    it('should open collection creator dialog', () => {
-        const initialState = { opened: false, ownerUuid: "" };
-        const collection = { opened: true, ownerUuid: "" };
-
-        const state = collectionCreatorReducer(initialState, collectionCreateActions.OPEN_COLLECTION_CREATOR(initialState));
-        expect(state).toEqual(collection);
-    });
-
-    it('should close collection creator dialog', () => {
-        const initialState = { opened: true, ownerUuid: "" };
-        const collection = { opened: false, ownerUuid: "" };
-
-        const state = collectionCreatorReducer(initialState, collectionCreateActions.CLOSE_COLLECTION_CREATOR());
-        expect(state).toEqual(collection);
-    });
-
-    it('should reset collection creator dialog props', () => {
-        const initialState = { opened: true, ownerUuid: "test" };
-        const collection = { opened: false, ownerUuid: "" };
-
-        const state = collectionCreatorReducer(initialState, collectionCreateActions.CREATE_COLLECTION_SUCCESS());
-        expect(state).toEqual(collection);
-    });
-});
diff --git a/src/store/collections/creator/collection-creator-reducer.ts b/src/store/collections/creator/collection-creator-reducer.ts
deleted file mode 100644 (file)
index 72c999d..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-import { collectionCreateActions, CollectionCreateAction } from './collection-creator-action';
-
-export interface CollectionCreatorState {
-    opened: boolean;
-    ownerUuid: string;
-}
-
-const updateCreator = (state: CollectionCreatorState, creator?: Partial<CollectionCreatorState>) => ({
-    ...state,
-    ...creator
-});
-
-const initialState: CollectionCreatorState = {
-    opened: false,
-    ownerUuid: ''
-};
-
-export const collectionCreatorReducer = (state: CollectionCreatorState = initialState, action: CollectionCreateAction) => {
-    return collectionCreateActions.match(action, {
-        OPEN_COLLECTION_CREATOR: ({ ownerUuid }) => updateCreator(state, { ownerUuid, opened: true }),
-        CLOSE_COLLECTION_CREATOR: () => updateCreator(state, { opened: false }),
-        CREATE_COLLECTION: () => updateCreator(state),
-        CREATE_COLLECTION_SUCCESS: () => updateCreator(state, { opened: false, ownerUuid: "" }),
-        default: () => state
-    });
-};
index 1b9490005de2cb4afac44e7113e7287f607434ab..65bb84b1d6ac0db89e7a3f3d8ce5dca0df409ad2 100644 (file)
@@ -6,7 +6,7 @@ import { ContextMenuActionSet } from "../context-menu-action-set";
 import { ToggleFavoriteAction } from "../actions/favorite-action";
 import { toggleFavorite } from "~/store/favorites/favorites-actions";
 import { RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon, ProvenanceGraphIcon, AdvancedIcon, RemoveIcon } from "~/components/icon/icon";
-import { openUpdater } from "~/store/collections/collection-update-actions";
+import { openUpdateModal } from "~/store/collections/collection-update-actions";
 import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action";
 import { openMoveCollectionDialog } from '~/store/move-collection-dialog/move-collection-dialog';
 import { openProjectCopyDialog } from "~/store/project-copy-project-dialog/project-copy-project-dialog";
@@ -16,7 +16,7 @@ export const collectionActionSet: ContextMenuActionSet = [[
         icon: RenameIcon,
         name: "Edit collection",
         execute: (dispatch, resource) => {
-            dispatch<any>(openUpdater(resource));
+            dispatch<any>(openUpdateModal(resource));
         }
     },
     {
index 989c8f1fdd28fcff11c371a980ba9f139cec0025..ad99bb85de73164d2997a83d6b8d3a206e6b6a65 100644 (file)
@@ -6,7 +6,7 @@ import { ContextMenuActionSet } from "../context-menu-action-set";
 import { ToggleFavoriteAction } from "../actions/favorite-action";
 import { toggleFavorite } from "~/store/favorites/favorites-actions";
 import { RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon, RemoveIcon } from "~/components/icon/icon";
-import { openUpdater } from "~/store/collections/collection-update-actions";
+import { openUpdateModal } from "~/store/collections/collection-update-actions";
 import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action";
 import { openMoveCollectionDialog } from '~/store/move-collection-dialog/move-collection-dialog';
 import { openProjectCopyDialog } from '~/store/project-copy-project-dialog/project-copy-project-dialog';
@@ -16,7 +16,7 @@ export const collectionResourceActionSet: ContextMenuActionSet = [[
         icon: RenameIcon,
         name: "Edit collection",
         execute: (dispatch, resource) => {
-            dispatch<any>(openUpdater(resource));
+            dispatch<any>(openUpdateModal(resource));
         }
     },
     {
index de3b954f4c1c819c5d9aab4a136cd0e03a377a6a..1adac00ffa5fea597752460d76f2b2a8d567fd8c 100644 (file)
@@ -6,9 +6,8 @@ import { reset } from "redux-form";
 
 import { ContextMenuActionSet } from "../context-menu-action-set";
 import { projectActions } from "~/store/project/project-action";
-import { collectionCreateActions } from "~/store/collections/creator/collection-creator-action";
 import { PROJECT_CREATE_DIALOG } from "../../dialog-create/dialog-project-create";
-import { COLLECTION_CREATE_DIALOG } from "../../dialog-create/dialog-collection-create";
+import { COLLECTION_CREATE_FORM_NAME, openCreateModal } from '~/store/collections/collection-create-actions';
 import { NewProjectIcon, CollectionIcon } from "~/components/icon/icon";
 
 export const rootProjectActionSet: ContextMenuActionSet =  [[
@@ -24,8 +23,8 @@ export const rootProjectActionSet: ContextMenuActionSet =  [[
         icon: CollectionIcon,
         name: "New Collection",
         execute: (dispatch, resource) => {
-            dispatch(reset(COLLECTION_CREATE_DIALOG));
-            dispatch(collectionCreateActions.OPEN_COLLECTION_CREATOR({ ownerUuid: resource.uuid }));
+            dispatch(reset(COLLECTION_CREATE_FORM_NAME));
+            dispatch<any>(openCreateModal());
         }
     }
 ]];
diff --git a/src/views-components/create-collection-dialog/create-collection-dialog.tsx b/src/views-components/create-collection-dialog/create-collection-dialog.tsx
deleted file mode 100644 (file)
index 94eb82f..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-import { connect } from "react-redux";
-import { Dispatch } from "redux";
-import { SubmissionError } from "redux-form";
-
-import { RootState } from "~/store/store";
-import { DialogCollectionCreate } from "../dialog-create/dialog-collection-create";
-import { collectionCreateActions, createCollection } from "~/store/collections/creator/collection-creator-action";
-import { snackbarActions } from "~/store/snackbar/snackbar-actions";
-import { UploadFile } from "~/store/collections/uploader/collection-uploader-actions";
-import { projectPanelActions } from "~/store/project-panel/project-panel-action";
-
-const mapStateToProps = (state: RootState) => ({
-    open: state.collections.creator.opened
-});
-
-const mapDispatchToProps = (dispatch: Dispatch) => ({
-    handleClose: () => {
-        dispatch(collectionCreateActions.CLOSE_COLLECTION_CREATOR());
-    },
-    onSubmit: (data: { name: string, description: string }, files: UploadFile[]) => {
-        return dispatch<any>(addCollection(data, files.map(f => f.file)))
-            .catch((e: any) => {
-                throw new SubmissionError({ name: e.errors.join("").includes("UniqueViolation") ? "Collection with this name already exists." : "" });
-            });
-    }
-});
-
-const addCollection = (data: { name: string, description: string }, files: File[]) =>
-    (dispatch: Dispatch) => {
-        return dispatch<any>(createCollection(data, files)).then(() => {
-            dispatch(snackbarActions.OPEN_SNACKBAR({
-                message: "Collection has been successfully created.",
-                hideDuration: 2000
-            }));
-            dispatch(projectPanelActions.REQUEST_ITEMS());
-        });
-    };
-
-export const CreateCollectionDialog = connect(mapStateToProps, mapDispatchToProps)(DialogCollectionCreate);
-
index af0e33f1b4260fab01a15bef29fef1985701ecdd..607835b0715ef1da1dffae6b31fec241e4247de7 100644 (file)
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { reduxForm, Field } from 'redux-form';
-import { compose } from 'redux';
-import { TextField } from '~/components/text-field/text-field';
-import { Dialog, DialogActions, DialogContent, DialogTitle } from '@material-ui/core/';
-import { Button, StyleRulesCallback, WithStyles, withStyles, CircularProgress } from '@material-ui/core';
-
-import { COLLECTION_NAME_VALIDATION, COLLECTION_DESCRIPTION_VALIDATION } from '~/validators/validators';
-import { FileUpload } from "~/components/file-upload/file-upload";
-import { connect, DispatchProp } from "react-redux";
-import { RootState } from "~/store/store";
-import { collectionUploaderActions, UploadFile } from "~/store/collections/uploader/collection-uploader-actions";
-
-type CssRules = "button" | "lastButton" | "formContainer" | "createProgress" | "dialogActions";
-
-const styles: StyleRulesCallback<CssRules> = theme => ({
-    button: {
-        marginLeft: theme.spacing.unit
-    },
-    lastButton: {
-        marginLeft: theme.spacing.unit,
-        marginRight: "20px",
-    },
-    formContainer: {
-        display: "flex",
-        flexDirection: "column",
-    },
-    createProgress: {
-        position: "absolute",
-        minWidth: "20px",
-        right: "110px"
-    },
-    dialogActions: {
-        marginBottom: theme.spacing.unit * 3
-    }
-});
-
-interface DialogCollectionDataProps {
-    open: boolean;
-    handleSubmit: any;
-    submitting: boolean;
-    invalid: boolean;
-    pristine: boolean;
-    files: UploadFile[];
-}
-
-interface DialogCollectionActionProps {
-    handleClose: () => void;
-    onSubmit: (data: { name: string, description: string }, files: UploadFile[]) => void;
-}
-
-type DialogCollectionProps = DialogCollectionDataProps & DialogCollectionActionProps & DispatchProp & WithStyles<CssRules>;
-
-export const COLLECTION_CREATE_DIALOG = "collectionCreateDialog";
-
-export const DialogCollectionCreate = compose(
-    connect((state: RootState) => ({
-        files: state.collections.uploader
-    })),
-    reduxForm({ form: COLLECTION_CREATE_DIALOG }),
-    withStyles(styles))(
-    class DialogCollectionCreate extends React.Component<DialogCollectionProps> {
-            render() {
-                const { classes, open, handleClose, handleSubmit, onSubmit, submitting, invalid, pristine, files } = this.props;
-                const busy = submitting || files.reduce(
-                    (prev, curr) => prev + (curr.loaded > 0 && curr.loaded < curr.total ? 1 : 0), 0
-                ) > 0;
-                return (
-                    <Dialog
-                        open={open}
-                        onClose={handleClose}
-                        fullWidth={true}
-                        maxWidth='sm'
-                        disableBackdropClick={true}
-                        disableEscapeKeyDown={true}>
-                        <form onSubmit={handleSubmit((data: any) => onSubmit(data, files))}>
-                            <DialogTitle id="form-dialog-title">Create a collection</DialogTitle>
-                            <DialogContent className={classes.formContainer}>
-                                <Field name="name"
-                                    disabled={submitting}
-                                    component={TextField}
-                                    validate={COLLECTION_NAME_VALIDATION}
-                                    label="Collection Name" />
-                                <Field name="description"
-                                    disabled={submitting}
-                                    component={TextField}
-                                    validate={COLLECTION_DESCRIPTION_VALIDATION}
-                                    label="Description - optional" />
-                                <FileUpload
-                                    files={files}
-                                    disabled={busy}
-                                    onDrop={files => this.props.dispatch(collectionUploaderActions.SET_UPLOAD_FILES(files))} />
-                            </DialogContent>
-                            <DialogActions className={classes.dialogActions}>
-                                <Button onClick={handleClose} className={classes.button} color="primary"
-                                    disabled={busy}>CANCEL</Button>
-                                <Button type="submit"
-                                    className={classes.lastButton}
-                                    color="primary"
-                                    disabled={invalid || busy || pristine}
-                                    variant="contained">
-                                    CREATE A COLLECTION
-                            </Button>
-                                {busy && <CircularProgress size={20} className={classes.createProgress} />}
-                            </DialogActions>
-                        </form>
-                    </Dialog>
-                );
-            }
-        }
-    );
+import { InjectedFormProps } from 'redux-form';
+import { WithDialogProps } from '~/store/dialog/with-dialog';
+import { CollectionCreateFormDialogData } from '~/store/collections/collection-create-actions';
+import { FormDialog } from '~/components/form-dialog/form-dialog';
+import { CollectionNameField, CollectionDescriptionField } from '~/views-components/collection-form-fields/collection-form-fields';
+
+type DialogCollectionProps = WithDialogProps<{}> & InjectedFormProps<CollectionCreateFormDialogData>;
+
+export const DialogCollectionCreate = (props: DialogCollectionProps) =>
+    <FormDialog
+        dialogTitle='Create a collection'
+        formFields={CollectionAddFields}
+        submitLabel='Create a Collection'
+        {...props}
+    />;
+
+const CollectionAddFields = () => <span>
+    <CollectionNameField />
+    <CollectionDescriptionField />
+    {/* <FileUpload
+        files={files}
+        disabled={busy}
+        onDrop={files => this.props.dispatch(collectionUploaderActions.SET_UPLOAD_FILES(files))} /> */}
+</span>;
\ No newline at end of file
diff --git a/src/views-components/dialog-forms/create-collection-dialog.ts b/src/views-components/dialog-forms/create-collection-dialog.ts
new file mode 100644 (file)
index 0000000..30c999c
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { compose } from "redux";
+import { reduxForm } from 'redux-form';
+import { withDialog } from "~/store/dialog/with-dialog";
+import { addCollection, COLLECTION_CREATE_FORM_NAME, CollectionCreateFormDialogData } from '~/store/collections/collection-create-actions';
+import { UploadFile } from "~/store/collections/uploader/collection-uploader-actions";
+import { DialogCollectionCreate } from "~/views-components/dialog-create/dialog-collection-create";
+
+export const CreateCollectionDialog = compose(
+    withDialog(COLLECTION_CREATE_FORM_NAME),
+    reduxForm<CollectionCreateFormDialogData>({
+        form: COLLECTION_CREATE_FORM_NAME,
+        onSubmit: (data, dispatch) => {
+            console.log('onSubmit: ', data);
+            dispatch(addCollection(data));
+        }
+    })
+)(DialogCollectionCreate);
\ No newline at end of file
similarity index 54%
rename from src/views-components/update-collection-dialog/update-collection-dialog.ts
rename to src/views-components/dialog-forms/update-collection-dialog.ts
index 7db45fae0713ba14d204fc9d9212132b24ff1a35..2c4296d816b6f2ff3de84a5a4b6372224eb44c06 100644 (file)
@@ -5,13 +5,13 @@
 import { compose } from "redux";
 import { reduxForm } from 'redux-form';
 import { withDialog } from "~/store/dialog/with-dialog";
-import { DialogCollectionUpdate } from '../dialog-update/dialog-collection-update';
-import { editCollection, COLLECTION_FORM_NAME, CollectionUpdateFormDialogData } from '~/store/collections/collection-update-actions';
+import { DialogCollectionUpdate } from '~/views-components/dialog-update/dialog-collection-update';
+import { editCollection, COLLECTION_UPDATE_FORM_NAME, CollectionUpdateFormDialogData } from '~/store/collections/collection-update-actions';
 
 export const UpdateCollectionDialog = compose(
-    withDialog(COLLECTION_FORM_NAME),
+    withDialog(COLLECTION_UPDATE_FORM_NAME),
     reduxForm<CollectionUpdateFormDialogData>({
-        form: COLLECTION_FORM_NAME,
+        form: COLLECTION_UPDATE_FORM_NAME,
         onSubmit: (data, dispatch) => {
             dispatch(editCollection(data));
         }
index 47e93861bcdb252bc4bdd2d1ed4b267481f8cdb7..38de88b33470550d078ee82e0f966673ba46f29d 100644 (file)
@@ -21,8 +21,6 @@ import { sidePanelActions } from '~/store/side-panel/side-panel-action';
 import { SidePanel, SidePanelItem } from '~/components/side-panel/side-panel';
 import { ItemMode, setProjectItem } from "~/store/navigation/navigation-action";
 import { projectActions } from "~/store/project/project-action";
-import { collectionCreateActions } from '~/store/collections/creator/collection-creator-action';
-import { ProjectPanel } from "~/views/project-panel/project-panel";
 import { DetailsPanel } from '~/views-components/details-panel/details-panel';
 import { ArvadosTheme } from '~/common/custom-theme';
 import { CreateProjectDialog } from "~/views-components/create-project-dialog/create-project-dialog";
@@ -36,18 +34,18 @@ import { FavoritePanel } from "../favorite-panel/favorite-panel";
 import { CurrentTokenDialog } from '~/views-components/current-token-dialog/current-token-dialog';
 import { Snackbar } from '~/views-components/snackbar/snackbar';
 import { favoritePanelActions } from '~/store/favorite-panel/favorite-panel-action';
-import { CreateCollectionDialog } from '~/views-components/create-collection-dialog/create-collection-dialog';
 import { CollectionPanel } from '../collection-panel/collection-panel';
 import { loadCollection, loadCollectionTags } from '~/store/collection-panel/collection-panel-action';
 import { getCollectionUrl } from '~/models/collection';
-import { UpdateCollectionDialog } from '~/views-components/update-collection-dialog/update-collection-dialog';
+import { COLLECTION_CREATE_FORM_NAME, openCreateModal } from '~/store/collections/collection-create-actions';
+import { CreateCollectionDialog } from '~/views-components/dialog-forms/create-collection-dialog';
+import { UpdateCollectionDialog } from '~/views-components/dialog-forms/update-collection-dialog';
 import { UpdateProjectDialog } from '~/views-components/update-project-dialog/update-project-dialog';
 import { AuthService } from "~/services/auth-service/auth-service";
 import { RenameFileDialog } from '~/views-components/rename-file-dialog/rename-file-dialog';
 import { FileRemoveDialog } from '~/views-components/file-remove-dialog/file-remove-dialog';
 import { MultipleFilesRemoveDialog } from '~/views-components/file-remove-dialog/multiple-files-remove-dialog';
 import { DialogCollectionCreateWithSelectedFile } from '~/views-components/create-collection-dialog-with-selected/create-collection-dialog-with-selected';
-import { COLLECTION_CREATE_DIALOG } from '~/views-components/dialog-create/dialog-collection-create';
 import { PROJECT_CREATE_DIALOG } from '~/views-components/dialog-create/dialog-project-create';
 import { UploadCollectionFilesDialog } from '~/views-components/upload-collection-files-dialog/upload-collection-files-dialog';
 import { CollectionPartialCopyDialog } from '../../views-components/collection-partial-copy-dialog/collection-partial-copy-dialog';
@@ -386,8 +384,8 @@ export const Workbench = withStyles(styles)(
             }
 
             handleCollectionCreationDialogOpen = (itemUuid: string) => {
-                this.props.dispatch(reset(COLLECTION_CREATE_DIALOG));
-                this.props.dispatch(collectionCreateActions.OPEN_COLLECTION_CREATOR({ ownerUuid: itemUuid }));
+                this.props.dispatch(reset(COLLECTION_CREATE_FORM_NAME));
+                this.props.dispatch<any>(openCreateModal());
             }
 
             openContextMenu = (event: React.MouseEvent<HTMLElement>, resource: { name: string; uuid: string; description?: string; kind: ContextMenuKind; }) => {