From d842372e4f45ee06315e511529e65ae1d3f319a0 Mon Sep 17 00:00:00 2001 From: Janicki Artur Date: Fri, 24 Aug 2018 11:44:43 +0200 Subject: [PATCH] update collections create and update (forms and dialogs) Feature #14103 Arvados-DCO-1.1-Signed-off-by: Janicki Artur --- src/store/collections/collection-create-actions.ts | 5 ++--- src/store/collections/collection-update-actions.ts | 4 ++-- .../action-sets/collection-action-set.ts | 4 ++-- .../action-sets/collection-resource-action-set.ts | 4 ++-- .../action-sets/root-project-action-set.ts | 4 ++-- .../dialog-create/dialog-collection-create.tsx | 13 ++++++++++++- .../dialog-forms/create-collection-dialog.ts | 5 +++-- src/views/workbench/workbench.tsx | 5 +++-- 8 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/store/collections/collection-create-actions.ts b/src/store/collections/collection-create-actions.ts index 66f5ab8c..2c339f28 100644 --- a/src/store/collections/collection-create-actions.ts +++ b/src/store/collections/collection-create-actions.ts @@ -19,9 +19,9 @@ export interface CollectionCreateFormDialogData { files: File[]; } -export const COLLECTION_CREATE_FORM_NAME = "collectionCreateDialog"; +export const COLLECTION_CREATE_FORM_NAME = "collectionCreateFormName"; -export const openCreateModal = () => +export const openCollectionCreateDialog = () => (dispatch: Dispatch) => { dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_CREATE_FORM_NAME, data: {} })); }; @@ -44,7 +44,6 @@ export const createCollection = (collection: Partial) => 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) { diff --git a/src/store/collections/collection-update-actions.ts b/src/store/collections/collection-update-actions.ts index 4c4ad3bf..27c3bfce 100644 --- a/src/store/collections/collection-update-actions.ts +++ b/src/store/collections/collection-update-actions.ts @@ -22,9 +22,9 @@ export interface CollectionUpdateFormDialogData { description: string; } -export const COLLECTION_UPDATE_FORM_NAME = 'collectionUpdateDialog'; +export const COLLECTION_UPDATE_FORM_NAME = 'collectionUpdateFormName'; -export const openUpdateModal = (resource: ContextMenuResource) => +export const openCollectionUpdateDialog = (resource: ContextMenuResource) => (dispatch: Dispatch) => { dispatch(initialize(COLLECTION_UPDATE_FORM_NAME, resource)); dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_UPDATE_FORM_NAME, data: {} })); 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 65bb84b1..fab4a805 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 { openUpdateModal } from "~/store/collections/collection-update-actions"; +import { openCollectionUpdateDialog } 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(openUpdateModal(resource)); + dispatch(openCollectionUpdateDialog(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 ad99bb85..66838a96 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 { openUpdateModal } from "~/store/collections/collection-update-actions"; +import { openCollectionUpdateDialog } 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(openUpdateModal(resource)); + dispatch(openCollectionUpdateDialog(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 1adac00f..a5e2065a 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 @@ -7,7 +7,7 @@ import { reset } from "redux-form"; import { ContextMenuActionSet } from "../context-menu-action-set"; import { projectActions } from "~/store/project/project-action"; import { PROJECT_CREATE_DIALOG } from "../../dialog-create/dialog-project-create"; -import { COLLECTION_CREATE_FORM_NAME, openCreateModal } from '~/store/collections/collection-create-actions'; +import { COLLECTION_CREATE_FORM_NAME, openCollectionCreateDialog } from '~/store/collections/collection-create-actions'; import { NewProjectIcon, CollectionIcon } from "~/components/icon/icon"; export const rootProjectActionSet: ContextMenuActionSet = [[ @@ -24,7 +24,7 @@ export const rootProjectActionSet: ContextMenuActionSet = [[ name: "New Collection", execute: (dispatch, resource) => { dispatch(reset(COLLECTION_CREATE_FORM_NAME)); - dispatch(openCreateModal()); + dispatch(openCollectionCreateDialog()); } } ]]; diff --git a/src/views-components/dialog-create/dialog-collection-create.tsx b/src/views-components/dialog-create/dialog-collection-create.tsx index 607835b0..5d3bfd85 100644 --- a/src/views-components/dialog-create/dialog-collection-create.tsx +++ b/src/views-components/dialog-create/dialog-collection-create.tsx @@ -6,8 +6,19 @@ import * as React from 'react'; import { InjectedFormProps } from 'redux-form'; import { WithDialogProps } from '~/store/dialog/with-dialog'; import { CollectionCreateFormDialogData } from '~/store/collections/collection-create-actions'; +import { collectionUploaderActions, UploadFile } from "~/store/collections/uploader/collection-uploader-actions"; import { FormDialog } from '~/components/form-dialog/form-dialog'; import { CollectionNameField, CollectionDescriptionField } from '~/views-components/collection-form-fields/collection-form-fields'; +import { FileUpload } from '~/components/file-upload/file-upload'; + +// interface DialogCollectionDataProps { +// open: boolean; +// handleSubmit: any; +// submitting: boolean; +// invalid: boolean; +// pristine: boolean; +// files: UploadFile[]; +// } type DialogCollectionProps = WithDialogProps<{}> & InjectedFormProps; @@ -23,7 +34,7 @@ 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 index 30c999ca..d2699d83 100644 --- a/src/views-components/dialog-forms/create-collection-dialog.ts +++ b/src/views-components/dialog-forms/create-collection-dialog.ts @@ -14,8 +14,9 @@ export const CreateCollectionDialog = compose( reduxForm({ form: COLLECTION_CREATE_FORM_NAME, onSubmit: (data, dispatch) => { - console.log('onSubmit: ', data); dispatch(addCollection(data)); } }) -)(DialogCollectionCreate); \ No newline at end of file +)(DialogCollectionCreate); + +// onSubmit: (data: { name: string, description: string }, files: UploadFile[]) => void; \ No newline at end of file diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx index 38de88b3..85c9b66e 100644 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@ -37,10 +37,11 @@ import { favoritePanelActions } from '~/store/favorite-panel/favorite-panel-acti import { CollectionPanel } from '../collection-panel/collection-panel'; import { loadCollection, loadCollectionTags } from '~/store/collection-panel/collection-panel-action'; import { getCollectionUrl } from '~/models/collection'; -import { COLLECTION_CREATE_FORM_NAME, openCreateModal } from '~/store/collections/collection-create-actions'; +import { COLLECTION_CREATE_FORM_NAME, openCollectionCreateDialog } 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 { ProjectPanel } from "~/views/project-panel/project-panel"; 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'; @@ -385,7 +386,7 @@ export const Workbench = withStyles(styles)( handleCollectionCreationDialogOpen = (itemUuid: string) => { this.props.dispatch(reset(COLLECTION_CREATE_FORM_NAME)); - this.props.dispatch(openCreateModal()); + this.props.dispatch(openCollectionCreateDialog()); } openContextMenu = (event: React.MouseEvent, resource: { name: string; uuid: string; description?: string; kind: ContextMenuKind; }) => { -- 2.39.5