+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 mainWf = getWorkflow(process.mounts[MOUNT_PATH_CWL_WORKFLOW]);
+ if (mainWf) { mainWf.inputs = getInputs(process); }
+ const stringifiedDefinition = JSON.stringify(process.mounts[MOUNT_PATH_CWL_WORKFLOW].content);
+ const newWorkflow = { ...workflow, definition: stringifiedDefinition };
+
+ const owner = getResource<ProjectResource | UserResource>(workflow.ownerUuid)(getState().resources);
+ const basicInitialData: RunProcessBasicFormData = { name: `Copy of: ${process.name}`, description: process.description, owner };
+ dispatch<any>(initialize(RUN_PROCESS_BASIC_FORM, basicInitialData));
+
+ const advancedInitialData: RunProcessAdvancedFormData = {
+ output: process.outputName,
+ runtime: process.schedulingParameters.max_run_time,
+ ram: process.runtimeConstraints.ram,
+ vcpus: process.runtimeConstraints.vcpus,
+ keep_cache_ram: process.runtimeConstraints.keep_cache_ram,
+ acr_container_image: process.containerImage
+ };
+ 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) => {
+ if (!data || !data.mounts || !data.mounts[MOUNT_PATH_CWL_WORKFLOW]) { return []; }
+ const inputs = getWorkflowInputs(data.mounts[MOUNT_PATH_CWL_WORKFLOW].content);
+ return inputs ? inputs.map(
+ (it: any) => (
+ {
+ type: it.type,
+ id: it.id,
+ label: it.label,
+ default: data.mounts[MOUNT_PATH_CWL_INPUT].content[it.id],
+ 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) =>