15768: collection copy dialog mostly works Arvados-DCO-1.1-Signed-off-by: Lisa Knox...
[arvados-workbench2.git] / src / store / workbench / workbench-actions.ts
index e79df2394747dc7a5578d78015e172316a28f900..71fdc6aa88075146cbbb79683d999232efce55b7 100644 (file)
@@ -432,18 +432,20 @@ export const copyCollection = (data: CopyFormDialogData) => async (dispatch: Dis
     //if no items in checkedlist && no items passed in, default to normal context menu behavior
     if (!uuidsToCopy.length) uuidsToCopy.push(data.uuid);
 
-    const collectionsToCopy: Resource[] = uuidsToCopy
-        .map(uuid => getResource(uuid)(getState().resources) as any)
+    const collectionsToCopy: CollectionCopyResource[] = uuidsToCopy
+        .map(uuid => getResource(uuid)(getState().resources) as CollectionCopyResource)
         .filter(resource => resource.kind === ResourceKind.COLLECTION);
 
     for (const collection of collectionsToCopy) {
-        await copySingleCollection(collection as Resource & { name: string });
+        await copySingleCollection(collection as CollectionCopyResource);
     }
 
-    async function copySingleCollection(copyToProject: Resource & { name: string }) {
+    async function copySingleCollection(copyToProject: CollectionCopyResource) {
         const newName = data.isSingle ? data.name : `Copy of: ${copyToProject.name}`;
         try {
-            const collection = await dispatch<any>(collectionCopyActions.copyCollection({ ...copyToProject, name: newName }));
+            const collection = await dispatch<any>(
+                collectionCopyActions.copyCollection({ ...copyToProject, name: newName, isSingle: data.isSingle })
+            );
             if (copyToProject && collection) {
                 await dispatch<any>(reloadProjectMatchingUuid([copyToProject.uuid]));
                 dispatch(
@@ -828,6 +830,8 @@ const groupContentsHandlers = unionize(groupContentsHandlersRecord);
 
 type GroupContentsHandler = UnionOf<typeof groupContentsHandlers>;
 
+type CollectionCopyResource = Resource & { name: string; isSingle: boolean };
+
 type MoveableResource = Resource & { name: string };
 
 type MoveFunc = (