From dbde3a8cc8098e423fb7d7f7147ea8a664744957 Mon Sep 17 00:00:00 2001 From: Janicki Artur Date: Tue, 28 Aug 2018 14:10:20 +0200 Subject: [PATCH] rename and change path for collection partial copy Feature #13860 Arvados-DCO-1.1-Signed-off-by: Janicki Artur --- .../collection-panel-files-actions.ts | 19 +++++++------- .../collection-partial-copy-dialog.tsx | 26 ------------------- .../dialog-collection-partial-copy.tsx | 20 ++++++++++++++ .../copy-collection-partial-dialog.ts | 19 ++++++++++++++ src/views/workbench/workbench.tsx | 6 ++--- 5 files changed, 52 insertions(+), 38 deletions(-) delete mode 100644 src/views-components/collection-partial-copy-dialog/collection-partial-copy-dialog.tsx create mode 100644 src/views-components/dialog-copy/dialog-collection-partial-copy.tsx create mode 100644 src/views-components/dialog-forms/copy-collection-partial-dialog.ts diff --git a/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts b/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts index 01b4fe4fac..96ff17c8cd 100644 --- a/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts +++ b/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts @@ -86,7 +86,7 @@ export const openMultipleFilesRemoveDialog = () => } }); -export const COLLECTION_PARTIAL_COPY = 'COLLECTION_PARTIAL_COPY'; +export const COLLECTION_PARTIAL_COPY_FORM_NAME = 'collectionPartialCopyFormName'; export interface CollectionPartialCopyFormData { name: string; @@ -103,15 +103,16 @@ export const openCollectionPartialCopyDialog = () => description: currentCollection.description, projectUuid: '' }; - dispatch(initialize(COLLECTION_PARTIAL_COPY, initialData)); + dispatch(initialize(COLLECTION_PARTIAL_COPY_FORM_NAME, initialData)); dispatch(resetPickerProjectTree()); - dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_PARTIAL_COPY, data: {} })); + dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_PARTIAL_COPY_FORM_NAME, data: {} })); } }; -export const doCollectionPartialCopy = ({ name, description, projectUuid }: CollectionPartialCopyFormData) => + +export const copyCollectionPartial = ({ name, description, projectUuid }: CollectionPartialCopyFormData) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - dispatch(startSubmit(COLLECTION_PARTIAL_COPY)); + dispatch(startSubmit(COLLECTION_PARTIAL_COPY_FORM_NAME)); const state = getState(); const currentCollection = state.collectionPanel.item; if (currentCollection) { @@ -127,17 +128,17 @@ export const doCollectionPartialCopy = ({ name, description, projectUuid }: Coll const newCollection = await services.collectionService.create(collectionCopy); const paths = filterCollectionFilesBySelection(state.collectionPanelFiles, false).map(file => file.id); await services.collectionService.deleteFiles(newCollection.uuid, paths); - dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_COPY })); + dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_COPY_FORM_NAME })); dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'New collection created.', hideDuration: 2000 })); } catch (e) { const error = getCommonResourceServiceError(e); if (error === CommonResourceServiceError.UNIQUE_VIOLATION) { - dispatch(stopSubmit(COLLECTION_PARTIAL_COPY, { name: 'Collection with this name already exists.' })); + dispatch(stopSubmit(COLLECTION_PARTIAL_COPY_FORM_NAME, { name: 'Collection with this name already exists.' })); } else if (error === CommonResourceServiceError.UNKNOWN) { - dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_COPY })); + dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_COPY_FORM_NAME })); dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not create a copy of collection', hideDuration: 2000 })); } else { - dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_COPY })); + dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_COPY_FORM_NAME })); dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been copied but may contain incorrect files.', hideDuration: 2000 })); } } 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 deleted file mode 100644 index 86fc360ef8..0000000000 --- a/src/views-components/collection-partial-copy-dialog/collection-partial-copy-dialog.tsx +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) The Arvados Authors. All rights reserved. -// -// SPDX-License-Identifier: AGPL-3.0 - -import * as React from "react"; -import { compose } from "redux"; -import { reduxForm, InjectedFormProps } from 'redux-form'; -import { withDialog, WithDialogProps } from '~/store/dialog/with-dialog'; -import { COLLECTION_PARTIAL_COPY, doCollectionPartialCopy, CollectionPartialCopyFormData } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions'; -import { CollectionPartialCopyFields } from '~/views-components/form-fields/collection-form-fields'; -import { FormDialog } from '~/components/form-dialog/form-dialog'; - -export const CollectionPartialCopyDialog = compose( - withDialog(COLLECTION_PARTIAL_COPY), - reduxForm({ - form: COLLECTION_PARTIAL_COPY, - onSubmit: (data: CollectionPartialCopyFormData, dispatch) => { - dispatch(doCollectionPartialCopy(data)); - } - }))((props: WithDialogProps & InjectedFormProps) => - ); diff --git a/src/views-components/dialog-copy/dialog-collection-partial-copy.tsx b/src/views-components/dialog-copy/dialog-collection-partial-copy.tsx new file mode 100644 index 0000000000..1975ea7e59 --- /dev/null +++ b/src/views-components/dialog-copy/dialog-collection-partial-copy.tsx @@ -0,0 +1,20 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import * as React from "react"; +import { InjectedFormProps, Field } from 'redux-form'; +import { WithDialogProps } from '~/store/dialog/with-dialog'; +import { CollectionPartialCopyFormData } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions'; +import { FormDialog } from '~/components/form-dialog/form-dialog'; +import { CollectionPartialCopyFields } from '~/views-components/form-fields/collection-form-fields'; + +type CopyFormDialogProps = WithDialogProps & InjectedFormProps; + +export const DialogCollectionPartialCopy = (props: CopyFormDialogProps) => + ; \ No newline at end of file diff --git a/src/views-components/dialog-forms/copy-collection-partial-dialog.ts b/src/views-components/dialog-forms/copy-collection-partial-dialog.ts new file mode 100644 index 0000000000..9b9298a624 --- /dev/null +++ b/src/views-components/dialog-forms/copy-collection-partial-dialog.ts @@ -0,0 +1,19 @@ +// 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 { COLLECTION_PARTIAL_COPY_FORM_NAME, copyCollectionPartial, CollectionPartialCopyFormData } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions'; +import { DialogCollectionPartialCopy } from '~/views-components/dialog-copy/dialog-collection-partial-copy'; + +export const CopyCollectionPartialDialog = compose( + withDialog(COLLECTION_PARTIAL_COPY_FORM_NAME), + reduxForm({ + form: COLLECTION_PARTIAL_COPY_FORM_NAME, + onSubmit: (data, dispatch) => { + dispatch(copyCollectionPartial(data)); + } + }) +)(DialogCollectionPartialCopy); diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx index 27470fa430..a3c4d2faa2 100644 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@ -25,7 +25,7 @@ import { RenameFileDialog } from '~/views-components/rename-file-dialog/rename-f import { FileRemoveDialog } from '~/views-components/file-remove-dialog/file-remove-dialog'; import { MultipleFilesRemoveDialog } from '~/views-components/file-remove-dialog/multiple-files-remove-dialog'; 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'; +import { CopyCollectionPartialDialog } from '~/views-components/dialog-forms/copy-collection-partial-dialog'; import { SidePanel } from '~/views-components/side-panel/side-panel'; import { Routes } from '~/routes/routes'; import { Breadcrumbs } from '~/views-components/breadcrumbs/breadcrumbs'; @@ -175,9 +175,9 @@ export const Workbench = withStyles(styles)( - - + + -- 2.39.5