[ARVADOS-WORKBENCH2] updated: 1.2.0-179-g3d8c3da
Git user
git at public.curoverse.com
Tue Aug 28 07:56:09 EDT 2018
Summary of changes:
.../collection-panel-files-actions.ts | 56 -----------------
.../collections/collection-partial-copy-actions.ts | 71 ++++++++++++++++++++++
.../collection-partial-copy-dialog.tsx | 26 --------
.../action-sets/collection-files-action-set.ts | 2 +-
.../dialog-copy/collection-partial-copy-dialog.tsx | 28 +++++++++
.../dialog-forms/collection-partial-copy-dialog.ts | 19 ++++++
.../form-fields/collection-form-fields.tsx | 8 ---
src/views/workbench/workbench.tsx | 2 +-
8 files changed, 120 insertions(+), 92 deletions(-)
create mode 100644 src/store/collections/collection-partial-copy-actions.ts
delete mode 100644 src/views-components/collection-partial-copy-dialog/collection-partial-copy-dialog.tsx
create mode 100644 src/views-components/dialog-copy/collection-partial-copy-dialog.tsx
create mode 100644 src/views-components/dialog-forms/collection-partial-copy-dialog.ts
via 3d8c3da5fdc9488ac37d09211af8312e77ebebcb (commit)
from 6a024c9a0ad6543bf95359b10bcd22aeec3e7dca (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 3d8c3da5fdc9488ac37d09211af8312e77ebebcb
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Tue Aug 28 13:55:55 2018 +0200
Extract collection partial copy dialog
Feature #14119
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
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 01b4fe4..d509218 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,63 +86,7 @@ export const openMultipleFilesRemoveDialog = () =>
}
});
-export const COLLECTION_PARTIAL_COPY = 'COLLECTION_PARTIAL_COPY';
-export interface CollectionPartialCopyFormData {
- name: string;
- description: string;
- projectUuid: string;
-}
-
-export const openCollectionPartialCopyDialog = () =>
- (dispatch: Dispatch, getState: () => RootState) => {
- const currentCollection = getState().collectionPanel.item;
- if (currentCollection) {
- const initialData = {
- name: currentCollection.name,
- description: currentCollection.description,
- projectUuid: ''
- };
- dispatch(initialize(COLLECTION_PARTIAL_COPY, initialData));
- dispatch<any>(resetPickerProjectTree());
- dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_PARTIAL_COPY, data: {} }));
- }
- };
-
-export const doCollectionPartialCopy = ({ name, description, projectUuid }: CollectionPartialCopyFormData) =>
- async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- dispatch(startSubmit(COLLECTION_PARTIAL_COPY));
- const state = getState();
- const currentCollection = state.collectionPanel.item;
- if (currentCollection) {
- try {
- const collection = await services.collectionService.get(currentCollection.uuid);
- const collectionCopy = {
- ...collection,
- name,
- description,
- ownerUuid: projectUuid,
- uuid: undefined
- };
- 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(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.' }));
- } else if (error === CommonResourceServiceError.UNKNOWN) {
- dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_COPY }));
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not create a copy of collection', hideDuration: 2000 }));
- } else {
- dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_COPY }));
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been copied but may contain incorrect files.', hideDuration: 2000 }));
- }
- }
- }
- };
export const RENAME_FILE_DIALOG = 'renameFileDialog';
export interface RenameFileDialogData {
diff --git a/src/store/collections/collection-partial-copy-actions.ts b/src/store/collections/collection-partial-copy-actions.ts
new file mode 100644
index 0000000..cba23ab
--- /dev/null
+++ b/src/store/collections/collection-partial-copy-actions.ts
@@ -0,0 +1,71 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch } from 'redux';
+import { RootState } from '~/store/store';
+import { initialize, startSubmit, stopSubmit } from 'redux-form';
+import { resetPickerProjectTree } from '~/store/project-tree-picker/project-tree-picker-actions';
+import { dialogActions } from '~/store/dialog/dialog-actions';
+import { ServiceRepository } from '~/services/services';
+import { filterCollectionFilesBySelection } from '../collection-panel/collection-panel-files/collection-panel-files-state';
+import { snackbarActions } from '~/store/snackbar/snackbar-actions';
+import { getCommonResourceServiceError, CommonResourceServiceError } from '~/common/api/common-resource-service';
+
+export const COLLECTION_PARTIAL_COPY_DIALOG = 'COLLECTION_PARTIAL_COPY_DIALOG';
+
+export interface CollectionPartialCopyFormData {
+ name: string;
+ description: string;
+ projectUuid: string;
+}
+
+export const openCollectionPartialCopyDialog = () =>
+ (dispatch: Dispatch, getState: () => RootState) => {
+ const currentCollection = getState().collectionPanel.item;
+ if (currentCollection) {
+ const initialData = {
+ name: currentCollection.name,
+ description: currentCollection.description,
+ projectUuid: ''
+ };
+ dispatch(initialize(COLLECTION_PARTIAL_COPY_DIALOG, initialData));
+ dispatch<any>(resetPickerProjectTree());
+ dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_PARTIAL_COPY_DIALOG, data: {} }));
+ }
+ };
+
+export const doCollectionPartialCopy = ({ name, description, projectUuid }: CollectionPartialCopyFormData) =>
+ async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ dispatch(startSubmit(COLLECTION_PARTIAL_COPY_DIALOG));
+ const state = getState();
+ const currentCollection = state.collectionPanel.item;
+ if (currentCollection) {
+ try {
+ const collection = await services.collectionService.get(currentCollection.uuid);
+ const collectionCopy = {
+ ...collection,
+ name,
+ description,
+ ownerUuid: projectUuid,
+ uuid: undefined
+ };
+ 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_DIALOG }));
+ 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_DIALOG, { name: 'Collection with this name already exists.' }));
+ } else if (error === CommonResourceServiceError.UNKNOWN) {
+ dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_COPY_DIALOG }));
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not create a copy of collection', hideDuration: 2000 }));
+ } else {
+ dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_COPY_DIALOG }));
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been copied but may contain incorrect files.', hideDuration: 2000 }));
+ }
+ }
+ }
+ };
\ No newline at end of file
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 86fc360..0000000
--- 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<string> & InjectedFormProps<CollectionPartialCopyFormData>) =>
- <FormDialog
- dialogTitle='Create a collection'
- formFields={CollectionPartialCopyFields}
- submitLabel='Create a collection'
- {...props}
- />);
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 965109c..5c4dab3 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 { openCollectionPartialCopyDialog } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions';
+import { openCollectionPartialCopyDialog } from '~/store/collections/collection-partial-copy-actions';
export const collectionFilesActionSet: ContextMenuActionSet = [[{
name: "Select all",
diff --git a/src/views-components/dialog-copy/collection-partial-copy-dialog.tsx b/src/views-components/dialog-copy/collection-partial-copy-dialog.tsx
new file mode 100644
index 0000000..ce2a991
--- /dev/null
+++ b/src/views-components/dialog-copy/collection-partial-copy-dialog.tsx
@@ -0,0 +1,28 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { FormDialog } from '~/components/form-dialog/form-dialog';
+import { CollectionNameField, CollectionDescriptionField, CollectionProjectPickerField } from '../form-fields/collection-form-fields';
+import { WithDialogProps } from '~/store/dialog/with-dialog';
+import { InjectedFormProps } from 'redux-form';
+import { CollectionPartialCopyFormData } from '../../store/collections/collection-partial-copy-actions';
+
+type PartialCopyFormDialogProps = WithDialogProps<string> & InjectedFormProps<CollectionPartialCopyFormData>;
+
+export const CollectionPartialCopyDialog = (props: PartialCopyFormDialogProps) =>
+ <FormDialog
+ dialogTitle='Create a collection'
+ formFields={CollectionPartialCopyFields}
+ submitLabel='Create a collection'
+ {...props}
+ />;
+
+export const CollectionPartialCopyFields = () => <div style={{ display: 'flex' }}>
+ <div>
+ <CollectionNameField />
+ <CollectionDescriptionField />
+ </div>
+ <CollectionProjectPickerField />
+</div>;
diff --git a/src/views-components/dialog-forms/collection-partial-copy-dialog.ts b/src/views-components/dialog-forms/collection-partial-copy-dialog.ts
new file mode 100644
index 0000000..33f6c25
--- /dev/null
+++ b/src/views-components/dialog-forms/collection-partial-copy-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 { CollectionPartialCopyFormData, doCollectionPartialCopy, COLLECTION_PARTIAL_COPY_DIALOG } from '~/store/collections/collection-partial-copy-actions';
+import { CollectionPartialCopyDialog as Dialog } from "~/views-components/dialog-copy/collection-partial-copy-dialog";
+
+
+export const CollectionPartialCopyDialog = compose(
+ withDialog(COLLECTION_PARTIAL_COPY_DIALOG),
+ reduxForm({
+ form: COLLECTION_PARTIAL_COPY_DIALOG,
+ onSubmit: (data: CollectionPartialCopyFormData, dispatch) => {
+ dispatch(doCollectionPartialCopy(data));
+ }
+ }))(Dialog);
\ No newline at end of file
diff --git a/src/views-components/form-fields/collection-form-fields.tsx b/src/views-components/form-fields/collection-form-fields.tsx
index 10c807b..af240fc 100644
--- a/src/views-components/form-fields/collection-form-fields.tsx
+++ b/src/views-components/form-fields/collection-form-fields.tsx
@@ -8,14 +8,6 @@ import { TextField } from "~/components/text-field/text-field";
import { COLLECTION_NAME_VALIDATION, COLLECTION_DESCRIPTION_VALIDATION, COLLECTION_PROJECT_VALIDATION } from "~/validators/validators";
import { ProjectTreePicker } from "~/views-components/project-tree-picker/project-tree-picker";
-export const CollectionPartialCopyFields = () => <div style={{ display: 'flex' }}>
- <div>
- <CollectionNameField />
- <CollectionDescriptionField />
- </div>
- <CollectionProjectPickerField />
-</div>;
-
export const CollectionNameField = () =>
<Field
name='name'
diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx
index 3468ed4..6a99877 100644
--- a/src/views/workbench/workbench.tsx
+++ b/src/views/workbench/workbench.tsx
@@ -24,7 +24,6 @@ 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 { CollectionPartialCopyDialog } from '~/views-components/collection-partial-copy-dialog/collection-partial-copy-dialog';
import { SidePanel } from '~/views-components/side-panel/side-panel';
import { Routes } from '~/routes/routes';
import { Breadcrumbs } from '~/views-components/breadcrumbs/breadcrumbs';
@@ -36,6 +35,7 @@ import { UpdateProjectDialog } from '~/views-components/dialog-forms/update-proj
import { MoveProjectDialog } from '~/views-components/dialog-forms/move-project-dialog';
import { MoveCollectionDialog } from '~/views-components/dialog-forms/move-collection-dialog';
import { CollectionFilesUploadDialog } from '~/views-components/dialog-forms/collection-files-upload-dialog';
+import { CollectionPartialCopyDialog } from '~/views-components/dialog-forms/collection-partial-copy-dialog';
const APP_BAR_HEIGHT = 100;
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list