From f4ed762732e8f5d2f7c4c08d5efbe92d4bce7f16 Mon Sep 17 00:00:00 2001 From: Janicki Artur Date: Thu, 23 Aug 2018 16:11:54 +0200 Subject: [PATCH] store - remove collection creator, modify modla for adding collection Feature #14103 Arvados-DCO-1.1-Signed-off-by: Janicki Artur --- .../collections/collection-create-actions.ts | 54 +++++++ .../collections/collection-update-actions.ts | 22 +-- src/store/collections/collections-reducer.ts | 3 - .../creator/collection-creator-action.ts | 37 ----- .../collection-creator-reducer.test.ts | 33 ----- .../creator/collection-creator-reducer.ts | 30 ---- .../action-sets/collection-action-set.ts | 4 +- .../collection-resource-action-set.ts | 4 +- .../action-sets/root-project-action-set.ts | 7 +- .../create-collection-dialog.tsx | 44 ------ .../dialog-collection-create.tsx | 134 ++++-------------- .../dialog-forms/create-collection-dialog.ts | 21 +++ .../update-collection-dialog.ts | 8 +- src/views/workbench/workbench.tsx | 12 +- 14 files changed, 126 insertions(+), 287 deletions(-) create mode 100644 src/store/collections/collection-create-actions.ts delete mode 100644 src/store/collections/creator/collection-creator-action.ts delete mode 100644 src/store/collections/creator/collection-creator-reducer.test.ts delete mode 100644 src/store/collections/creator/collection-creator-reducer.ts delete mode 100644 src/views-components/create-collection-dialog/create-collection-dialog.tsx create mode 100644 src/views-components/dialog-forms/create-collection-dialog.ts rename src/views-components/{update-collection-dialog => dialog-forms}/update-collection-dialog.ts (54%) diff --git a/src/store/collections/collection-create-actions.ts b/src/store/collections/collection-create-actions.ts new file mode 100644 index 00000000..66f5ab8c --- /dev/null +++ b/src/store/collections/collection-create-actions.ts @@ -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(createCollection(data)); + dispatch(snackbarActions.OPEN_SNACKBAR({ + message: "Collection has been successfully created.", + hideDuration: 2000 + })); + }; + +export const createCollection = (collection: Partial) => + async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + dispatch(startSubmit(COLLECTION_CREATE_FORM_NAME)); + try { + const newCollection = await services.collectionService.create(collection); + await dispatch(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 diff --git a/src/store/collections/collection-update-actions.ts b/src/store/collections/collection-update-actions.ts index 13df864d..4c4ad3bf 100644 --- a/src/store/collections/collection-update-actions.ts +++ b/src/store/collections/collection-update-actions.ts @@ -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) => 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(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 diff --git a/src/store/collections/collections-reducer.ts b/src/store/collections/collections-reducer.ts index 892a1ffc..c7601505 100644 --- a/src/store/collections/collections-reducer.ts +++ b/src/store/collections/collections-reducer.ts @@ -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 index 8c35ffa8..00000000 --- a/src/store/collections/creator/collection-creator-action.ts +++ /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; - -export const createCollection = (collection: Partial, 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(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 index 5aa9dcfe..00000000 --- a/src/store/collections/creator/collection-creator-reducer.test.ts +++ /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 index 72c999d0..00000000 --- a/src/store/collections/creator/collection-creator-reducer.ts +++ /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) => ({ - ...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 - }); -}; diff --git a/src/views-components/context-menu/action-sets/collection-action-set.ts b/src/views-components/context-menu/action-sets/collection-action-set.ts index 1b949000..65bb84b1 100644 --- a/src/views-components/context-menu/action-sets/collection-action-set.ts +++ b/src/views-components/context-menu/action-sets/collection-action-set.ts @@ -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(openUpdater(resource)); + dispatch(openUpdateModal(resource)); } }, { diff --git a/src/views-components/context-menu/action-sets/collection-resource-action-set.ts b/src/views-components/context-menu/action-sets/collection-resource-action-set.ts index 989c8f1f..ad99bb85 100644 --- a/src/views-components/context-menu/action-sets/collection-resource-action-set.ts +++ b/src/views-components/context-menu/action-sets/collection-resource-action-set.ts @@ -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(openUpdater(resource)); + dispatch(openUpdateModal(resource)); } }, { diff --git a/src/views-components/context-menu/action-sets/root-project-action-set.ts b/src/views-components/context-menu/action-sets/root-project-action-set.ts index de3b954f..1adac00f 100644 --- a/src/views-components/context-menu/action-sets/root-project-action-set.ts +++ b/src/views-components/context-menu/action-sets/root-project-action-set.ts @@ -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(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 index 94eb82f9..00000000 --- a/src/views-components/create-collection-dialog/create-collection-dialog.tsx +++ /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(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(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); - diff --git a/src/views-components/dialog-create/dialog-collection-create.tsx b/src/views-components/dialog-create/dialog-collection-create.tsx index af0e33f1..607835b0 100644 --- a/src/views-components/dialog-create/dialog-collection-create.tsx +++ b/src/views-components/dialog-create/dialog-collection-create.tsx @@ -3,113 +3,27 @@ // 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 = 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; - -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 { - 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 ( - -
onSubmit(data, files))}> - Create a collection - - - - this.props.dispatch(collectionUploaderActions.SET_UPLOAD_FILES(files))} /> - - - - - {busy && } - -
-
- ); - } - } - ); +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; + +export const DialogCollectionCreate = (props: DialogCollectionProps) => + ; + +const CollectionAddFields = () => + + + {/* this.props.dispatch(collectionUploaderActions.SET_UPLOAD_FILES(files))} /> */} +; \ 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 index 00000000..30c999ca --- /dev/null +++ b/src/views-components/dialog-forms/create-collection-dialog.ts @@ -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({ + form: COLLECTION_CREATE_FORM_NAME, + onSubmit: (data, dispatch) => { + console.log('onSubmit: ', data); + dispatch(addCollection(data)); + } + }) +)(DialogCollectionCreate); \ No newline at end of file diff --git a/src/views-components/update-collection-dialog/update-collection-dialog.ts b/src/views-components/dialog-forms/update-collection-dialog.ts 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 7db45fae..2c4296d8 100644 --- a/src/views-components/update-collection-dialog/update-collection-dialog.ts +++ b/src/views-components/dialog-forms/update-collection-dialog.ts @@ -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({ - form: COLLECTION_FORM_NAME, + form: COLLECTION_UPDATE_FORM_NAME, onSubmit: (data, dispatch) => { dispatch(editCollection(data)); } diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx index 47e93861..38de88b3 100644 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@ -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(openCreateModal()); } openContextMenu = (event: React.MouseEvent, resource: { name: string; uuid: string; description?: string; kind: ContextMenuKind; }) => { -- 2.30.2