[arvados-workbench2] updated: 2.6.0-123-g59a77c79

git repository hosting git at public.arvados.org
Wed Oct 4 16:19:48 UTC 2023


Summary of changes:
 src/index.tsx                                      |  2 +-
 .../common-service/trashable-resource-service.ts   | 20 +++----
 src/store/collections/collection-copy-actions.ts   | 15 ++++--
 src/store/trash/trash-actions.ts                   | 63 ++++++++++++++--------
 4 files changed, 61 insertions(+), 39 deletions(-)

       via  59a77c79b4d5a2286eeed3f33af78d0b30caea48 (commit)
       via  11ba28b72d1bb268066756381c645710a80bd211 (commit)
      from  72a8bf2138429b61dfc9710cc41932396b6f5b4f (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 59a77c79b4d5a2286eeed3f33af78d0b30caea48
Author: Lisa Knox <lisaknox83 at gmail.com>
Date:   Wed Oct 4 12:19:43 2023 -0400

    15768: fixed 422 handling on untrash Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox at curii.com>

diff --git a/src/services/common-service/trashable-resource-service.ts b/src/services/common-service/trashable-resource-service.ts
index 4d6b130b..5e4704b6 100644
--- a/src/services/common-service/trashable-resource-service.ts
+++ b/src/services/common-service/trashable-resource-service.ts
@@ -9,29 +9,25 @@ import { CommonResourceService } from "services/common-service/common-resource-s
 import { ApiActions } from "services/api/api-actions";
 
 export class TrashableResourceService<T extends TrashableResource> extends CommonResourceService<T> {
-
     constructor(serverApi: AxiosInstance, resourceType: string, actions: ApiActions, readOnlyFields: string[] = []) {
         super(serverApi, resourceType, actions, readOnlyFields);
     }
 
     trash(uuid: string): Promise<T> {
-        return CommonResourceService.defaultResponse(
-            this.serverApi
-                .post(this.resourceType + `/${uuid}/trash`),
-            this.actions
-        );
+        return CommonResourceService.defaultResponse(this.serverApi.post(this.resourceType + `/${uuid}/trash`), this.actions);
     }
 
     untrash(uuid: string): Promise<T> {
         const params = {
-            ensure_unique_name: true
+            ensure_unique_name: true,
         };
         return CommonResourceService.defaultResponse(
-            this.serverApi
-                .post(this.resourceType + `/${uuid}/untrash`, {
-                    params: CommonResourceService.mapKeys(snakeCase)(params)
-                }),
-            this.actions
+            this.serverApi.post(this.resourceType + `/${uuid}/untrash`, {
+                params: CommonResourceService.mapKeys(snakeCase)(params),
+            }),
+            this.actions,
+            undefined,
+            false
         );
     }
 }
diff --git a/src/store/trash/trash-actions.ts b/src/store/trash/trash-actions.ts
index ffdad04a..3f8f8346 100644
--- a/src/store/trash/trash-actions.ts
+++ b/src/store/trash/trash-actions.ts
@@ -18,12 +18,13 @@ export const toggleProjectTrashed =
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<any> => {
         let errorMessage = "";
         let successMessage = "";
+        let untrashedResource;
         try {
             if (isTrashed) {
                 errorMessage = "Could not restore project from trash";
                 successMessage = "Restored project from trash";
-                await services.groupsService.untrash(uuid);
-                dispatch<any>(isMulti ? navigateToTrash : navigateTo(uuid));
+                untrashedResource = await services.groupsService.untrash(uuid);
+                dispatch<any>(isMulti || !untrashedResource ? navigateToTrash : navigateTo(uuid));
                 dispatch<any>(activateSidePanelTreeItem(uuid));
             } else {
                 errorMessage = "Could not move project to trash";
@@ -32,20 +33,31 @@ export const toggleProjectTrashed =
                 dispatch<any>(loadSidePanelTreeProjects(ownerUuid));
                 dispatch<any>(navigateTo(ownerUuid));
             }
-            dispatch(
-                snackbarActions.OPEN_SNACKBAR({
-                    message: successMessage,
-                    hideDuration: 2000,
-                    kind: SnackbarKind.SUCCESS,
-                })
-            );
+            if (untrashedResource) {
+                dispatch(
+                    snackbarActions.OPEN_SNACKBAR({
+                        message: successMessage,
+                        hideDuration: 2000,
+                        kind: SnackbarKind.SUCCESS,
+                    })
+                );
+            }
         } catch (e) {
-            dispatch(
-                snackbarActions.OPEN_SNACKBAR({
-                    message: errorMessage,
-                    kind: SnackbarKind.ERROR,
-                })
-            );
+            if (e.status === 422) {
+                dispatch(
+                    snackbarActions.OPEN_SNACKBAR({
+                        message: "Could not restore project from trash: Duplicate name at destination",
+                        kind: SnackbarKind.ERROR,
+                    })
+                );
+            } else {
+                dispatch(
+                    snackbarActions.OPEN_SNACKBAR({
+                        message: errorMessage,
+                        kind: SnackbarKind.ERROR,
+                    })
+                );
+            }
         }
     };
 
@@ -78,12 +90,21 @@ export const toggleCollectionTrashed =
                 })
             );
         } catch (e) {
-            dispatch(
-                snackbarActions.OPEN_SNACKBAR({
-                    message: errorMessage,
-                    kind: SnackbarKind.ERROR,
-                })
-            );
+            if (e.status === 422) {
+                dispatch(
+                    snackbarActions.OPEN_SNACKBAR({
+                        message: "Could not restore collection from trash: Duplicate name at destination",
+                        kind: SnackbarKind.ERROR,
+                    })
+                );
+            } else {
+                dispatch(
+                    snackbarActions.OPEN_SNACKBAR({
+                        message: errorMessage,
+                        kind: SnackbarKind.ERROR,
+                    })
+                );
+            }
         }
     };
 

commit 11ba28b72d1bb268066756381c645710a80bd211
Author: Lisa Knox <lisaknox83 at gmail.com>
Date:   Wed Oct 4 10:21:56 2023 -0400

    15768: narrowed 422 handling on copyCollection Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox at curii.com>

diff --git a/src/index.tsx b/src/index.tsx
index f2c06666..cddfb464 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -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}`,
diff --git a/src/store/collections/collection-copy-actions.ts b/src/store/collections/collection-copy-actions.ts
index d4e647f8..1323ebc3 100644
--- a/src/store/collections/collection-copy-actions.ts
+++ b/src/store/collections/collection-copy-actions.ts
@@ -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.");

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list