+
+export const cancelRunningWorkflow = (uuid: string) =>
+ async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ try {
+ const process = await services.containerRequestService.update(uuid, { priority: 0 });
+ return process;
+ } catch (e) {
+ throw new Error('Could not cancel the process.');
+ }
+ };
+
+export const reRunProcess = (processUuid: string, workflowUuid: string) =>
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const process = getResource<any>(processUuid)(getState().resources);
+ const workflows = getState().runProcessPanel.searchWorkflows;
+ const workflow = workflows.find(workflow => workflow.uuid === workflowUuid);
+ if (workflow && process) {
+ const newValues = getInputs(process);
+ process.mounts.varLibCwlWorkflowJson.content.graph[1].inputs = newValues;
+ const stringifiedDefinition = JSON.stringify(process.mounts.varLibCwlWorkflowJson.content);
+ const newWorkflow = { ...workflow, definition: stringifiedDefinition };
+
+ const basicInitialData: RunProcessBasicFormData = { name: `Copy of: ${process.name}`, description: process.description };
+ dispatch<any>(initialize(RUN_PROCESS_BASIC_FORM, basicInitialData));
+
+ const advancedInitialData: RunProcessAdvancedFormData = {
+ output: process.outputName,
+ runtime: process.schedulingParameters.maxRunTime,
+ ram: process.runtimeConstraints.ram,
+ vcpus: process.runtimeConstraints.vcpus,
+ keepCacheRam: process.runtimeConstraints.keepCacheRam,
+ api: process.runtimeConstraints.API
+ };
+ dispatch<any>(initialize(RUN_PROCESS_ADVANCED_FORM, advancedInitialData));
+
+ dispatch<any>(navigateToRunProcess);
+ dispatch<any>(goToStep(1));
+ dispatch(runProcessPanelActions.SET_STEP_CHANGED(true));
+ dispatch(runProcessPanelActions.SET_SELECTED_WORKFLOW(newWorkflow));
+ } else {
+ dispatch<any>(snackbarActions.OPEN_SNACKBAR({ message: `You can't re-run this process`, kind: SnackbarKind.ERROR }));
+ }
+ };
+
+const getInputs = (data: any) =>
+ data && data.mounts.varLibCwlWorkflowJson ? data.mounts.varLibCwlWorkflowJson.content.graph[1].inputs.map((it: any) => (
+ { type: it.type, id: it.id, label: it.label, default: getInputValue(it.id, data.mounts.varLibCwlCwlInputJson.content), doc: it.doc }
+ )) : [];
+
+export const openRemoveProcessDialog = (uuid: string) =>
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ dispatch(dialogActions.OPEN_DIALOG({
+ id: REMOVE_PROCESS_DIALOG,
+ data: {
+ title: 'Remove process permanently',
+ text: 'Are you sure you want to remove this process?',
+ confirmButtonLabel: 'Remove',
+ uuid
+ }
+ }));
+ };
+
+export const REMOVE_PROCESS_DIALOG = 'removeProcessDialog';
+
+export const removeProcessPermanently = (uuid: string) =>
+ async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...', kind: SnackbarKind.INFO }));
+ await services.containerRequestService.delete(uuid);
+ dispatch(projectPanelActions.REQUEST_ITEMS());
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removed.', hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
+ };
+
+