1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { dialogActions } from 'store/dialog/dialog-actions';
6 import { RootState } from 'store/store';
7 import { Dispatch } from 'redux';
8 import { getProcess, Process } from 'store/processes/process';
9 import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions';
10 import { getWorkflowInputs } from 'models/workflow';
11 import { JSONMount } from 'models/mount-types';
12 import { MOUNT_PATH_CWL_WORKFLOW } from 'models/process';
14 export const PROCESS_INPUT_DIALOG_NAME = 'processInputDialog';
16 export const openProcessInputDialog = (processUuid: string) =>
17 (dispatch: Dispatch<any>, getState: () => RootState) => {
18 const process = getProcess(processUuid)(getState().resources);
20 const data: any = process;
21 const inputs = getInputsFromWFMount(process);
22 if (inputs && inputs.length > 0) {
23 dispatch(dialogActions.OPEN_DIALOG({ id: PROCESS_INPUT_DIALOG_NAME, data }));
25 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'There are no inputs in this process!', kind: SnackbarKind.ERROR }));
30 const getInputsFromWFMount = (process: Process) => {
31 if (!process || !process.containerRequest.mounts[MOUNT_PATH_CWL_WORKFLOW] ) { return undefined; }
32 const mnt = process.containerRequest.mounts[MOUNT_PATH_CWL_WORKFLOW] as JSONMount;
33 return getWorkflowInputs(mnt.content);