15768: narrowed 422 handling on copyCollection Arvados-DCO-1.1-Signed-off-by: Lisa...
authorLisa Knox <lisaknox83@gmail.com>
Wed, 4 Oct 2023 14:21:56 +0000 (10:21 -0400)
committerLisa Knox <lisaknox83@gmail.com>
Wed, 4 Oct 2023 14:21:56 +0000 (10:21 -0400)
src/index.tsx
src/store/collections/collection-copy-actions.ts

index f2c06666d6f1c7989c14311b74a2f4c1c05af60d..cddfb464315ba3304c42218bb59f16c262611e16 100644 (file)
@@ -152,7 +152,7 @@ fetchConfig().then(({ config, apiHost }) => {
                 } else if (error.status === 401 && error.errors[0].indexOf("Not logged in") > -1) {
                     // Catch auth errors when navigating and redirect to login preserving url location
                     store.dispatch(logout(false, true));
-                } else if (error.status !== 422) {
+                } else {
                     store.dispatch(
                         snackbarActions.OPEN_SNACKBAR({
                             message: `${error.errors ? error.errors[0] : error.message}`,
index d4e647f86219af4f6e03c730f2817660a6b8c75b..1323ebc3e5d0558aefa0b1c03e7b3df0282d35b3 100644 (file)
@@ -46,14 +46,18 @@ export const copyCollection =
             const collManifestText = await services.collectionService.get(resource.uuid, undefined, ["manifestText"]);
             collection.manifestText = collManifestText.manifestText;
             const { href, ...collectionRecord } = collection;
-            const newCollection = await services.collectionService.create({
-                ...collectionRecord,
-                ownerUuid: resource.ownerUuid,
-                name: resource.name,
-            });
+            const newCollection = await services.collectionService.create(
+                {
+                    ...collectionRecord,
+                    ownerUuid: resource.ownerUuid,
+                    name: resource.name,
+                },
+                false
+            );
             dispatch(dialogActions.CLOSE_DIALOG({ id: formName }));
             return newCollection;
         } catch (e) {
+            console.error("Error while copying collection: ", e);
             const error = getCommonResourceServiceError(e);
             if (error === CommonResourceServiceError.UNIQUE_NAME_VIOLATION) {
                 dispatch(
@@ -61,6 +65,7 @@ export const copyCollection =
                         ownerUuid: "A collection with the same name already exists in the target project.",
                     } as FormErrors)
                 );
+                throw new Error("Could not copy the collection.");
             } else {
                 dispatch(dialogActions.CLOSE_DIALOG({ id: formName }));
                 throw new Error("Could not copy the collection.");