From: Michal Klobukowski Date: Sat, 18 Aug 2018 05:29:08 +0000 (+0200) Subject: Extract collection form components X-Git-Tag: 1.3.0~146^2~5 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/0b94fe12e8705098542008753ce5a5caa12a4218 Extract collection form components Feature #14014 Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski --- diff --git a/src/store/collections/creator/collection-creator-action.ts b/src/store/collections/creator/collection-creator-action.ts index 5243a610..8c35ffa8 100644 --- a/src/store/collections/creator/collection-creator-action.ts +++ b/src/store/collections/creator/collection-creator-action.ts @@ -21,6 +21,8 @@ export const collectionCreateActions = unionize({ 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; @@ -33,4 +35,3 @@ export const createCollection = (collection: Partial, files: return newCollection; }; -export type CollectionCreateAction = UnionOf; diff --git a/src/views-components/collection-partial-copy-dialog/collection-partial-copy-dialog.tsx b/src/views-components/collection-partial-copy-dialog/collection-partial-copy-dialog.tsx new file mode 100644 index 00000000..0105ad2c --- /dev/null +++ b/src/views-components/collection-partial-copy-dialog/collection-partial-copy-dialog.tsx @@ -0,0 +1,30 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import { Dispatch, compose } from "redux"; +import { reduxForm, reset, startSubmit, stopSubmit } from "redux-form"; +import { withDialog } from "~/store/dialog/with-dialog"; +import { dialogActions } from "~/store/dialog/dialog-actions"; +import { loadProjectTreePickerProjects } from "../project-tree-picker/project-tree-picker"; +import { CollectionPartialCopyFormDialog } from "~/views-components/form-dialog/collection-form-dialog"; + +export const COLLECTION_PARTIAL_COPY = 'COLLECTION_PARTIAL_COPY'; + +export const openCollectionPartialCopyDialog = () => + (dispatch: Dispatch) => { + dispatch(reset(COLLECTION_PARTIAL_COPY)); + dispatch(loadProjectTreePickerProjects('')); + dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_PARTIAL_COPY, data: {} })); + }; + + +export const CollectionPartialCopyDialog = compose( + withDialog(COLLECTION_PARTIAL_COPY), + reduxForm({ + form: COLLECTION_PARTIAL_COPY, + onSubmit: (data, dispatch) => { + dispatch(startSubmit(COLLECTION_PARTIAL_COPY)); + setTimeout(() => dispatch(stopSubmit(COLLECTION_PARTIAL_COPY, { name: 'Invalid name' })), 2000); + } + }))(CollectionPartialCopyFormDialog); diff --git a/src/views-components/context-menu/action-sets/collection-files-action-set.ts b/src/views-components/context-menu/action-sets/collection-files-action-set.ts index 653da011..69815efd 100644 --- a/src/views-components/context-menu/action-sets/collection-files-action-set.ts +++ b/src/views-components/context-menu/action-sets/collection-files-action-set.ts @@ -4,7 +4,7 @@ import { ContextMenuActionSet } from "../context-menu-action-set"; import { collectionPanelFilesAction, openMultipleFilesRemoveDialog } from "~/store/collection-panel/collection-panel-files/collection-panel-files-actions"; -import { createCollectionWithSelected } from "~/views-components/create-collection-dialog-with-selected/create-collection-dialog-with-selected"; +import { openCollectionPartialCopyDialog } from "~/views-components/collection-partial-copy-dialog/collection-partial-copy-dialog"; export const collectionFilesActionSet: ContextMenuActionSet = [[{ @@ -30,6 +30,6 @@ export const collectionFilesActionSet: ContextMenuActionSet = [[{ }, { name: "Create a new collection with selected", execute: (dispatch) => { - dispatch(createCollectionWithSelected()); + dispatch(openCollectionPartialCopyDialog()); } }]]; diff --git a/src/views-components/create-collection-dialog-with-selected/create-collection-dialog-with-selected.tsx b/src/views-components/create-collection-dialog-with-selected/create-collection-dialog-with-selected.tsx deleted file mode 100644 index 53464022..00000000 --- a/src/views-components/create-collection-dialog-with-selected/create-collection-dialog-with-selected.tsx +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) The Arvados Authors. All rights reserved. -// -// SPDX-License-Identifier: AGPL-3.0 - -import { Dispatch, compose } from "redux"; -import { reduxForm, reset, startSubmit, stopSubmit } from "redux-form"; -import { withDialog } from "~/store/dialog/with-dialog"; -import { dialogActions } from "~/store/dialog/dialog-actions"; -import { DialogCollectionCreateWithSelected } from "../dialog-create/dialog-collection-create-selected"; -import { loadProjectTreePickerProjects } from "../project-tree-picker/project-tree-picker"; - -export const DIALOG_COLLECTION_CREATE_WITH_SELECTED = 'dialogCollectionCreateWithSelected'; - -export const createCollectionWithSelected = () => - (dispatch: Dispatch) => { - dispatch(reset(DIALOG_COLLECTION_CREATE_WITH_SELECTED)); - dispatch(loadProjectTreePickerProjects('')); - dispatch(dialogActions.OPEN_DIALOG({ id: DIALOG_COLLECTION_CREATE_WITH_SELECTED, data: {} })); - }; - - -export const DialogCollectionCreateWithSelectedFile = compose( - withDialog(DIALOG_COLLECTION_CREATE_WITH_SELECTED), - reduxForm({ - form: DIALOG_COLLECTION_CREATE_WITH_SELECTED, - onSubmit: (data, dispatch) => { - dispatch(startSubmit(DIALOG_COLLECTION_CREATE_WITH_SELECTED)); - setTimeout(() => dispatch(stopSubmit(DIALOG_COLLECTION_CREATE_WITH_SELECTED, { name: 'Invalid name' })), 2000); - } - }))(DialogCollectionCreateWithSelected); diff --git a/src/views-components/dialog-create/dialog-collection-create-selected.tsx b/src/views-components/form-dialog/collection-form-dialog.tsx similarity index 51% rename from src/views-components/dialog-create/dialog-collection-create-selected.tsx rename to src/views-components/form-dialog/collection-form-dialog.tsx index 70837471..937558cc 100644 --- a/src/views-components/dialog-create/dialog-collection-create-selected.tsx +++ b/src/views-components/form-dialog/collection-form-dialog.tsx @@ -10,34 +10,43 @@ import { COLLECTION_NAME_VALIDATION, COLLECTION_DESCRIPTION_VALIDATION, COLLECTI import { ProjectTreePicker } from "../project-tree-picker/project-tree-picker"; import { FormDialog } from '../../components/form-dialog/form-dialog'; -export const DialogCollectionCreateWithSelected = (props: WithDialogProps & InjectedFormProps<{ name: string }>) => +export const CollectionPartialCopyFormDialog = (props: WithDialogProps & InjectedFormProps<{ name: string }>) => ; -const FormFields = () =>
+export const CollectionPartialCopyFields = () =>
- - + +
+ +
; + +export const CollectionNameField = () => + ; + +export const CollectionDescriptionField = () => + ; + +export const CollectionProjectPickerField = () => -
; + component={ProjectPicker} + validate={COLLECTION_PROJECT_VALIDATION} />; -const Picker = (props: WrappedFieldProps) => +const ProjectPicker = (props: WrappedFieldProps) =>
props.input.onChange(projectUuid)} />
; diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx index 01a92ab4..71e5a03b 100644 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@ -47,10 +47,10 @@ 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'; const DRAWER_WITDH = 240; const APP_BAR_HEIGHT = 100; @@ -243,7 +243,7 @@ export const Workbench = withStyles(styles)( - +