[ARVADOS-WORKBENCH2] updated: 1.3.1-422-g4d2f28ce
Git user
git at public.curoverse.com
Fri Mar 22 09:55:58 UTC 2019
Summary of changes:
src/models/collection.ts | 1 +
.../collections/collection-partial-copy-actions.ts | 62 ++++++++++++++++++++++
.../action-sets/collection-files-action-set.ts | 9 +++-
...y.tsx => dialog-partial-copy-to-collection.tsx} | 16 +++---
.../partial-copy-to-collection-dialog.ts | 21 ++++++++
.../form-fields/collection-form-fields.tsx | 9 +++-
.../project-tree-picker/project-tree-picker.tsx | 12 +++++
src/views/workbench/workbench.tsx | 2 +
8 files changed, 120 insertions(+), 12 deletions(-)
copy src/views-components/dialog-copy/{dialog-collection-partial-copy.tsx => dialog-partial-copy-to-collection.tsx} (52%)
create mode 100644 src/views-components/dialog-forms/partial-copy-to-collection-dialog.ts
via 4d2f28ce28f9a6ff5018a4a0c5200ee4bfb277e2 (commit)
from 2c1eea0961138a2903cf83b8e756b78bc52bc9df (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 4d2f28ce28f9a6ff5018a4a0c5200ee4bfb277e2
Author: Pawel Kowalczyk <pawel.kowalczyk at contractors.roche.com>
Date: Fri Mar 22 10:55:46 2019 +0100
refs #14876 Copy-selected-into-the-colletion
Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk <pawel.kowalczyk at contractors.roche.com>
diff --git a/src/models/collection.ts b/src/models/collection.ts
index 72075fdb..ca2b4b36 100644
--- a/src/models/collection.ts
+++ b/src/models/collection.ts
@@ -20,6 +20,7 @@ export interface CollectionResource extends TrashableResource {
currentVersionUuid: string;
version: number;
preserveVersion: boolean;
+ unsignedManifestText?: string;
}
export const getCollectionUrl = (uuid: string) => {
diff --git a/src/store/collections/collection-partial-copy-actions.ts b/src/store/collections/collection-partial-copy-actions.ts
index 9d0515ab..65561aa4 100644
--- a/src/store/collections/collection-partial-copy-actions.ts
+++ b/src/store/collections/collection-partial-copy-actions.ts
@@ -3,6 +3,7 @@
// SPDX-License-Identifier: AGPL-3.0
import { Dispatch } from 'redux';
+import * as _ from "lodash";
import { RootState } from '~/store/store';
import { FormErrors, initialize, startSubmit, stopSubmit } from 'redux-form';
import { resetPickerProjectTree } from '~/store/project-tree-picker/project-tree-picker-actions';
@@ -15,6 +16,7 @@ import { progressIndicatorActions } from "~/store/progress-indicator/progress-in
import { initProjectsTreePicker } from '~/store/tree-picker/tree-picker-actions';
export const COLLECTION_PARTIAL_COPY_FORM_NAME = 'COLLECTION_PARTIAL_COPY_DIALOG';
+export const COLLECTION_PARTIAL_COPY_TO_SELECTED_COLLECTION = 'COLLECTION_PARTIAL_COPY_TO_SELECTED_DIALOG';
export interface CollectionPartialCopyFormData {
name: string;
@@ -22,6 +24,10 @@ export interface CollectionPartialCopyFormData {
projectUuid: string;
}
+export interface CollectionPartialCopyToSelectedCollectionFormData {
+ collectionUuid: string;
+}
+
export const openCollectionPartialCopyDialog = () =>
(dispatch: Dispatch, getState: () => RootState) => {
const currentCollection = getState().collectionPanel.item;
@@ -79,3 +85,59 @@ export const copyCollectionPartial = ({ name, description, projectUuid }: Collec
}
}
};
+
+export const openCollectionPartialCopyToSelectedCollectionDialog = () =>
+ (dispatch: Dispatch, getState: () => RootState) => {
+ const currentCollection = getState().collectionPanel.item;
+ if (currentCollection) {
+ const initialData = {
+ collectionUuid: ''
+ };
+ dispatch(initialize(COLLECTION_PARTIAL_COPY_TO_SELECTED_COLLECTION, initialData));
+ dispatch<any>(resetPickerProjectTree());
+ dispatch<any>(initProjectsTreePicker(COLLECTION_PARTIAL_COPY_TO_SELECTED_COLLECTION));
+ dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_PARTIAL_COPY_TO_SELECTED_COLLECTION, data: {} }));
+ }
+ };
+
+export const copyCollectionPartialToSelectedCollection = ({ collectionUuid }: CollectionPartialCopyToSelectedCollectionFormData) =>
+ async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ dispatch(startSubmit(COLLECTION_PARTIAL_COPY_TO_SELECTED_COLLECTION));
+ const state = getState();
+ const currentCollection = state.collectionPanel.item;
+ if (currentCollection) {
+ try {
+ dispatch(progressIndicatorActions.START_WORKING(COLLECTION_PARTIAL_COPY_TO_SELECTED_COLLECTION));
+ const selectedCollection = await services.collectionService.get(collectionUuid);
+ const paths = filterCollectionFilesBySelection(state.collectionPanelFiles, false).map(file => file.id);
+ const pathsToRemove = paths.filter(path => {
+ const a = path.split('/');
+ const fileExistsInSelectedCollection = selectedCollection.manifestText.includes(a[1]);
+ if (fileExistsInSelectedCollection) {
+ return path;
+ } else {
+ return;
+ }
+ });
+ const diffPathToRemove = _.difference(paths, pathsToRemove);
+ await services.collectionService.deleteFiles(selectedCollection.uuid, pathsToRemove);
+ const collectionWithDeletedFiles = await services.collectionService.get(collectionUuid);
+ await services.collectionService.update(collectionUuid, { manifestText: `${collectionWithDeletedFiles.manifestText}${currentCollection.manifestText ? currentCollection.manifestText : currentCollection.unsignedManifestText}` });
+ await services.collectionService.deleteFiles(collectionWithDeletedFiles.uuid, diffPathToRemove);
+ dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_COPY_TO_SELECTED_COLLECTION }));
+ dispatch(snackbarActions.OPEN_SNACKBAR({
+ message: 'Files has been copied to selected collection.',
+ hideDuration: 2000,
+ kind: SnackbarKind.SUCCESS
+ }));
+ dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_PARTIAL_COPY_TO_SELECTED_COLLECTION));
+ } catch (e) {
+ const error = getCommonResourceServiceError(e);
+ if (error === CommonResourceServiceError.UNKNOWN) {
+ dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_COPY_TO_SELECTED_COLLECTION }));
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not copy this files to selected collection', hideDuration: 2000, kind: SnackbarKind.ERROR }));
+ }
+ dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_PARTIAL_COPY_TO_SELECTED_COLLECTION));
+ }
+ }
+ };
\ No newline at end of file
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 5b683bf8..885f222c 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 "~/views-components/context-menu/context-menu-action-set";
import { collectionPanelFilesAction, openMultipleFilesRemoveDialog } from "~/store/collection-panel/collection-panel-files/collection-panel-files-actions";
-import { openCollectionPartialCopyDialog } from '~/store/collections/collection-partial-copy-actions';
+import { openCollectionPartialCopyDialog, openCollectionPartialCopyToSelectedCollectionDialog } from '~/store/collections/collection-partial-copy-actions';
import { DownloadCollectionFileAction } from "~/views-components/context-menu/actions/download-collection-file-action";
export const collectionFilesActionSet: ContextMenuActionSet = [[{
@@ -27,7 +27,12 @@ export const collectionFilesActionSet: ContextMenuActionSet = [[{
execute: () => { return; }
}, {
name: "Create a new collection with selected",
- execute: dispatch => {
+ execute: dispatch => {
dispatch<any>(openCollectionPartialCopyDialog());
}
+}, {
+ name: "Copy selected into the collection",
+ execute: dispatch => {
+ dispatch<any>(openCollectionPartialCopyToSelectedCollectionDialog());
+ }
}]];
diff --git a/src/views-components/dialog-copy/dialog-partial-copy-to-collection.tsx b/src/views-components/dialog-copy/dialog-partial-copy-to-collection.tsx
new file mode 100644
index 00000000..1c987264
--- /dev/null
+++ b/src/views-components/dialog-copy/dialog-partial-copy-to-collection.tsx
@@ -0,0 +1,29 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { memoize } from "lodash/fp";
+import { FormDialog } from '~/components/form-dialog/form-dialog';
+import { WithDialogProps } from '~/store/dialog/with-dialog';
+import { InjectedFormProps } from 'redux-form';
+import { CollectionPartialCopyToSelectedCollectionFormData } from '~/store/collections/collection-partial-copy-actions';
+import { PickerIdProp } from "~/store/tree-picker/picker-id";
+import { CollectionPickerField } from '~/views-components/form-fields/collection-form-fields';
+
+type DialogCollectionPartialCopyProps = WithDialogProps<string> & InjectedFormProps<CollectionPartialCopyToSelectedCollectionFormData>;
+
+export const DialogCollectionPartialCopyToSelectedCollection = (props: DialogCollectionPartialCopyProps & PickerIdProp) =>
+ <FormDialog
+ dialogTitle='Choose collection'
+ formFields={CollectionPartialCopyFields(props.pickerId)}
+ submitLabel='Copy files'
+ {...props}
+ />;
+
+export const CollectionPartialCopyFields = memoize(
+ (pickerId: string) =>
+ () =>
+ <div>
+ <CollectionPickerField {...{ pickerId }}/>
+ </div>);
diff --git a/src/views-components/dialog-forms/partial-copy-to-collection-dialog.ts b/src/views-components/dialog-forms/partial-copy-to-collection-dialog.ts
new file mode 100644
index 00000000..8f062ac4
--- /dev/null
+++ b/src/views-components/dialog-forms/partial-copy-to-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 { CollectionPartialCopyToSelectedCollectionFormData, copyCollectionPartialToSelectedCollection, COLLECTION_PARTIAL_COPY_TO_SELECTED_COLLECTION } from '~/store/collections/collection-partial-copy-actions';
+import { DialogCollectionPartialCopyToSelectedCollection } from "~/views-components/dialog-copy/dialog-partial-copy-to-collection";
+import { pickerId } from "~/store/tree-picker/picker-id";
+
+export const PartialCopyToCollectionDialog = compose(
+ withDialog(COLLECTION_PARTIAL_COPY_TO_SELECTED_COLLECTION),
+ reduxForm<CollectionPartialCopyToSelectedCollectionFormData>({
+ form: COLLECTION_PARTIAL_COPY_TO_SELECTED_COLLECTION,
+ onSubmit: (data, dispatch) => {
+ dispatch(copyCollectionPartialToSelectedCollection(data));
+ }
+ }),
+ pickerId(COLLECTION_PARTIAL_COPY_TO_SELECTED_COLLECTION),
+)(DialogCollectionPartialCopyToSelectedCollection);
\ 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 c02996d8..2ebcf08e 100644
--- a/src/views-components/form-fields/collection-form-fields.tsx
+++ b/src/views-components/form-fields/collection-form-fields.tsx
@@ -6,7 +6,7 @@ import * as React from "react";
import { Field } from "redux-form";
import { TextField } from "~/components/text-field/text-field";
import { COLLECTION_NAME_VALIDATION, COLLECTION_DESCRIPTION_VALIDATION, COLLECTION_PROJECT_VALIDATION } from "~/validators/validators";
-import { ProjectTreePickerField } from "~/views-components/project-tree-picker/project-tree-picker";
+import { ProjectTreePickerField, CollectionTreePickerField } from "~/views-components/project-tree-picker/project-tree-picker";
import { PickerIdProp } from '~/store/tree-picker/picker-id';
export const CollectionNameField = () =>
@@ -30,3 +30,10 @@ export const CollectionProjectPickerField = (props: PickerIdProp) =>
pickerId={props.pickerId}
component={ProjectTreePickerField}
validate={COLLECTION_PROJECT_VALIDATION} />;
+
+export const CollectionPickerField = (props: PickerIdProp) =>
+ <Field
+ name="collectionUuid"
+ pickerId={props.pickerId}
+ component={CollectionTreePickerField}
+ validate={COLLECTION_PROJECT_VALIDATION} />;
diff --git a/src/views-components/project-tree-picker/project-tree-picker.tsx b/src/views-components/project-tree-picker/project-tree-picker.tsx
index bae5d59f..2ff9b3c4 100644
--- a/src/views-components/project-tree-picker/project-tree-picker.tsx
+++ b/src/views-components/project-tree-picker/project-tree-picker.tsx
@@ -104,3 +104,15 @@ export const ProjectTreePickerField = (props: WrappedFieldProps & PickerIdProp)
const handleChange = (props: WrappedFieldProps) =>
(_: any, { id }: TreeItem<ProjectsTreePickerItem>) =>
props.input.onChange(id);
+
+export const CollectionTreePickerField = (props: WrappedFieldProps & PickerIdProp) =>
+ <div style={{ height: '200px', display: 'flex', flexDirection: 'column' }}>
+ <ProjectsTreePicker
+ pickerId={props.pickerId}
+ toggleItemActive={handleChange(props)}
+ includeCollections />
+ {props.meta.dirty && props.meta.error &&
+ <Typography variant='caption' color='error'>
+ {props.meta.error}
+ </Typography>}
+ </div>;
\ No newline at end of file
diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx
index e6ac5130..a009d614 100644
--- a/src/views/workbench/workbench.tsx
+++ b/src/views/workbench/workbench.tsx
@@ -90,6 +90,7 @@ import { GroupDetailsPanel } from '~/views/group-details-panel/group-details-pan
import { RemoveGroupMemberDialog } from '~/views-components/groups-dialog/member-remove-dialog';
import { GroupMemberAttributesDialog } from '~/views-components/groups-dialog/member-attributes-dialog';
import { AddGroupMembersDialog } from '~/views-components/dialog-forms/add-group-member-dialog';
+import { PartialCopyToCollectionDialog } from '~/views-components/dialog-forms/partial-copy-to-collection-dialog';
type CssRules = 'root' | 'container' | 'splitter' | 'asidePanel' | 'contentWrapper' | 'content';
@@ -210,6 +211,7 @@ export const WorkbenchPanel =
<MultipleFilesRemoveDialog />
<PublicKeyDialog />
<PartialCopyCollectionDialog />
+ <PartialCopyToCollectionDialog />
<ProcessCommandDialog />
<ProcessInputDialog />
<ProjectPropertiesDialog />
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list