15803: toggleIsActive will use unsetup to deactivate user
authorPeter Amstutz <pamstutz@veritasgenetics.com>
Wed, 6 Nov 2019 22:43:46 +0000 (17:43 -0500)
committerPeter Amstutz <pamstutz@veritasgenetics.com>
Wed, 6 Nov 2019 22:43:46 +0000 (17:43 -0500)
Also re-enables generic error reporting for API errors.

src/index.tsx
src/services/user-service/user-service.ts
src/store/users/users-actions.ts

index 5a941638e5c5227fd4014ff63bb10701fb2b17d8..d4203a87d85ad9982601e44e1faf45d0d0abcd3f 100644 (file)
@@ -61,6 +61,7 @@ import { loadFileViewersConfig } from '~/store/file-viewers/file-viewers-actions
 import { collectionAdminActionSet } from '~/views-components/context-menu/action-sets/collection-admin-action-set';
 import { processResourceAdminActionSet } from '~/views-components/context-menu/action-sets/process-resource-admin-action-set';
 import { projectAdminActionSet } from '~/views-components/context-menu/action-sets/project-admin-action-set';
+import { snackbarActions, SnackbarKind } from "~/store/snackbar/snackbar-actions";
 
 console.log(`Starting arvados [${getBuildInfo()}]`);
 
@@ -99,8 +100,12 @@ fetchConfig()
                 store.dispatch(progressIndicatorActions.TOGGLE_WORKING({ id, working }));
             },
             errorFn: (id, error) => {
-                // console.error("Backend error:", error);
-                // store.dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Backend error", kind: SnackbarKind.ERROR }));
+                console.error("Backend error:", error);
+                store.dispatch(snackbarActions.OPEN_SNACKBAR({
+                    message: `${error.errors[0]}`,
+                    kind: SnackbarKind.ERROR,
+                    hideDuration: 8000
+                }));
             }
         });
         const store = configureStore(history, services);
index a69203dc5bece0c4c3e1f29aceba92c3de998849..bcf81d554967a298b3e7f89d2716e15689780a3d 100644 (file)
@@ -11,4 +11,12 @@ export class UserService extends CommonResourceService<UserResource> {
     constructor(serverApi: AxiosInstance, actions: ApiActions) {
         super(serverApi, "users", actions);
     }
+
+    unsetup(uuid: string) {
+        return CommonResourceService.defaultResponse(
+            this.serverApi
+                .post(this.resourceType + uuid + '/unsetup'),
+            this.actions
+        );
+    }
 }
index 44b2bad68d92cf1ac0a77d0f55ad90a3575e61a5..9e9f09543fd1e253d14a6e623932de0756d496bd 100644 (file)
@@ -109,7 +109,12 @@ export const toggleIsActive = (uuid: string) =>
         const { resources } = getState();
         const data = getResource<UserResource>(uuid)(resources);
         const isActive = data!.isActive;
-        const newActivity = await services.userService.update(uuid, { isActive: !isActive });
+        let newActivity;
+        if (isActive) {
+            newActivity = await services.userService.unsetup(uuid);
+        } else {
+            newActivity = await services.userService.update(uuid, { isActive: true });
+        }
         dispatch<any>(loadUsersPanel());
         return newActivity;
     };