18123: Add active toggle to group member list.
[arvados-workbench2.git] / src / store / resources / resources-actions.ts
index 0034e7aa5faf8cdea6f22236f971ec14db657e18..6c05da32f6cbdcee6b558683385d9cce87dcabe5 100644 (file)
@@ -2,12 +2,12 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { unionize, ofType, UnionOf } from '~/common/unionize';
-import { Resource, extractUuidKind } from '~/models/resource';
+import { unionize, ofType, UnionOf } from 'common/unionize';
+import { extractUuidKind, Resource } from 'models/resource';
 import { Dispatch } from 'redux';
-import { RootState } from '~/store/store';
-import { ServiceRepository } from '~/services/services';
-import { getResourceService } from '~/services/services';
+import { RootState } from 'store/store';
+import { ServiceRepository } from 'services/services';
+import { getResourceService } from 'services/services';
 
 export const resourcesActions = unionize({
     SET_RESOURCES: ofType<Resource[]>(),
@@ -18,14 +18,18 @@ export type ResourcesAction = UnionOf<typeof resourcesActions>;
 
 export const updateResources = (resources: Resource[]) => resourcesActions.SET_RESOURCES(resources);
 
-export const loadResource = (uuid: string) =>
+export const deleteResources = (resources: string[]) => resourcesActions.DELETE_RESOURCES(resources);
+
+export const loadResource = (uuid: string, showErrors?: boolean) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        const kind = extractUuidKind(uuid);
-        const service = getResourceService(kind)(services);
-        if (service) {
-            const resource = await service.get(uuid);
-            dispatch<any>(updateResources([resource]));
-            return resource;
-        }
+        try {
+            const kind = extractUuidKind(uuid);
+            const service = getResourceService(kind)(services);
+            if (service) {
+                const resource = await service.get(uuid, showErrors);
+                dispatch<any>(updateResources([resource]));
+                return resource;
+            }
+        } catch {}
         return undefined;
-    };
\ No newline at end of file
+    };