[ARVADOS-WORKBENCH2] updated: 1.4.1-427-gffbfe196

Git user git at public.arvados.org
Mon Sep 21 16:10:46 UTC 2020


Summary of changes:
 .../collection-panel-files-reducer.ts              | 23 ++++++++++++++++------
 .../collection-panel-files-state.ts                |  1 -
 .../collections/collection-partial-copy-actions.ts | 12 +++++++++--
 3 files changed, 27 insertions(+), 9 deletions(-)

       via  ffbfe1965a34800f933b20a32374d9cd9eb7ea72 (commit)
      from  0c00f9d96076ad46e2ee499230f3f22a1603675d (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 ffbfe1965a34800f933b20a32374d9cd9eb7ea72
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date:   Mon Sep 21 18:09:35 2020 +0200

    16243: Fixed copy of selected items to new collection
    
    Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>

diff --git a/src/store/collection-panel/collection-panel-files/collection-panel-files-reducer.ts b/src/store/collection-panel/collection-panel-files/collection-panel-files-reducer.ts
index 25323e27..03de8e34 100644
--- a/src/store/collection-panel/collection-panel-files/collection-panel-files-reducer.ts
+++ b/src/store/collection-panel/collection-panel-files/collection-panel-files-reducer.ts
@@ -27,8 +27,8 @@ export const collectionPanelFilesReducer = (state: CollectionPanelFilesState = c
             .map(toggleDescendants(data.id))[0],
 
         ON_SEARCH_CHANGE: (searchValue) => {
-            // node.children = children.filter((id: string) => id.replace(parentId, '').toLowerCase().indexOf(searchValue.toLowerCase()) > -1);
-            const ids: string[] = [];
+            const fileIds: string[] = [];
+            const directoryIds: string[] = [];
             const filteredFiles = Object.keys(fetchedFiles)
                 .filter((key: string) => {
                     const node = fetchedFiles[key];
@@ -40,22 +40,33 @@ export const collectionPanelFilesReducer = (state: CollectionPanelFilesState = c
                     const { id, value: { type, name } } = node;
 
                     if (type === CollectionFileType.DIRECTORY) {
-                        ids.push(id);
+                        directoryIds.push(id);
                         return true;
                     }
 
                     const includeFile = name.toLowerCase().indexOf(searchValue.toLowerCase()) > -1;
 
                     if (includeFile) {
-                        ids.push(id);
+                        fileIds.push(id);
                     }
 
                     return includeFile;
                 })
                 .reduce((prev, next) => {
                     const node = JSON.parse(JSON.stringify(fetchedFiles[next]));
-                    node.children = node.children.filter((key: string) => ids.indexOf(key) > -1);
-                    prev[next] = node;
+                    const { value: { type }, children } = node;
+
+                    node.children = node.children.filter((key: string) => {
+                        const isFile = directoryIds.indexOf(key) === -1;
+                        return isFile ?
+                          fileIds.indexOf(key) > -1 :
+                          !!fileIds.find(id => id.indexOf(key) > -1);
+                    });
+
+                    if (type === CollectionFileType.FILE || children.length > 0) {
+                        prev[next] = node;
+                    }
+
                     return prev;
                 }, {});
 
diff --git a/src/store/collection-panel/collection-panel-files/collection-panel-files-state.ts b/src/store/collection-panel/collection-panel-files/collection-panel-files-state.ts
index 9d5b06ce..aa3bd305 100644
--- a/src/store/collection-panel/collection-panel-files/collection-panel-files-state.ts
+++ b/src/store/collection-panel/collection-panel-files/collection-panel-files-state.ts
@@ -38,7 +38,6 @@ export const mergeCollectionPanelFilesStates = (oldState: CollectionPanelFilesSt
 
 export const filterCollectionFilesBySelection = (tree: CollectionPanelFilesState, selected: boolean) => {
     const allFiles = getNodeDescendants('')(tree).map(node => node.value);
-
     const selectedDirectories = allFiles.filter(file => file.selected === selected && file.type === CollectionFileType.DIRECTORY);
     const selectedFiles = allFiles.filter(file => file.selected === selected && !selectedDirectories.some(dir => dir.id === file.path));
     return [...selectedDirectories, ...selectedFiles];
diff --git a/src/store/collections/collection-partial-copy-actions.ts b/src/store/collections/collection-partial-copy-actions.ts
index 72374e65..621f1957 100644
--- a/src/store/collections/collection-partial-copy-actions.ts
+++ b/src/store/collections/collection-partial-copy-actions.ts
@@ -61,8 +61,16 @@ export const copyCollectionPartial = ({ name, description, projectUuid }: Collec
                     manifestText: collection.manifestText,
                 };
                 const newCollection = await services.collectionService.create(collectionCopy);
-                const paths = filterCollectionFilesBySelection(state.collectionPanelFiles, false).map(file => file.id);
-                await services.collectionService.deleteFiles(newCollection.uuid, paths);
+                const copiedFiles = await services.collectionService.files(newCollection.uuid);
+                const paths = filterCollectionFilesBySelection(state.collectionPanelFiles, true).map(file => file.id);
+                const filesToDelete = copiedFiles.map(({ id }) => id).filter(file => {
+                    return !paths.find(path => path.indexOf(file.replace(newCollection.uuid, '')) > -1);
+                });
+                // console.log(paths.length, filesToDelete.length, copiedFiles.length);
+                await services.collectionService.deleteFiles(
+                    '',
+                    filesToDelete
+                );
                 dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_COPY_FORM_NAME }));
                 dispatch(snackbarActions.OPEN_SNACKBAR({
                     message: 'New collection created.',

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list