20251: Increase/set containers list request to match count of requested container...
[arvados-workbench2.git] / src / store / processes / processes-actions.ts
index 815d6aec5e37eb443f3f636a58c63d990481684d..b26c2017f7552fa54c4d6e44f57ad398ff1b45ce 100644 (file)
@@ -23,6 +23,7 @@ import { UserResource } from "models/user";
 import { CommandOutputParameter } from "cwlts/mappings/v1.0/CommandOutputParameter";
 import { ContainerResource } from "models/container";
 import { ContainerRequestResource, ContainerRequestState } from "models/container-request";
+import { FilterBuilder } from "services/api/filter-builder";
 
 export const loadProcess = (containerRequestUuid: string) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<Process | undefined> => {
@@ -60,9 +61,12 @@ export const loadProcess = (containerRequestUuid: string) =>
         return { containerRequest };
     };
 
-export const loadContainers = (filters: string, loadMounts: boolean = true) =>
+export const loadContainers = (containerUuids: string[], loadMounts: boolean = true) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        let args: any = { filters };
+        let args: any = {
+            filters: new FilterBuilder().addIn('uuid', containerUuids).getFilters(),
+            limit: containerUuids.length,
+         };
         if (!loadMounts) {
             args.select = containerFieldsNoMounts;
         }
@@ -114,12 +118,32 @@ export const cancelRunningWorkflow = (uuid: string) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         try {
             const process = await services.containerRequestService.update(uuid, { priority: 0 });
+            dispatch<any>(updateResources([process]));
+            if (process.containerUuid) {
+                const container = await services.containerService.get(process.containerUuid, false);
+                dispatch<any>(updateResources([container]));
+            }
             return process;
         } catch (e) {
             throw new Error('Could not cancel the process.');
         }
     };
 
+export const resumeOnHoldWorkflow = (uuid: string) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        try {
+            const process = await services.containerRequestService.update(uuid, { priority: 500 });
+            dispatch<any>(updateResources([process]));
+            if (process.containerUuid) {
+                const container = await services.containerService.get(process.containerUuid, false);
+                dispatch<any>(updateResources([container]));
+            }
+            return process;
+        } catch (e) {
+            throw new Error('Could not resume the process.');
+        }
+    };
+
 export const startWorkflow = (uuid: string) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         try {