20031: Remove console log
[arvados.git] / src / views-components / process-input-dialog / process-input-dialog.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import React from "react";
6 import { Dialog, DialogActions, Button, CardHeader, DialogContent } from '@material-ui/core';
7 import { WithDialogProps } from 'store/dialog/with-dialog';
8 import { withDialog } from "store/dialog/with-dialog";
9 import { PROCESS_INPUT_DIALOG_NAME } from 'store/processes/process-input-actions';
10 import { RunProcessInputsForm } from "views/run-process-panel/run-process-inputs-form";
11 import { MOUNT_PATH_CWL_WORKFLOW, MOUNT_PATH_CWL_INPUT } from "models/process";
12 import { getWorkflowInputs } from "models/workflow";
13
14 export const ProcessInputDialog = withDialog(PROCESS_INPUT_DIALOG_NAME)(
15     (props: WithDialogProps<any>) =>
16         <Dialog
17             open={props.open}
18             maxWidth={false}
19             onClose={props.closeDialog}>
20             <CardHeader
21                 title="Inputs - Pipeline template that generates a config file from a template" />
22             <DialogContent>
23                 <RunProcessInputsForm inputs={getInputs(props.data.containerRequest)} />
24             </DialogContent>
25             <DialogActions>
26                 <Button
27                     variant='text'
28                     color='primary'
29                     onClick={props.closeDialog}>
30                     Close
31                 </Button>
32             </DialogActions>
33         </Dialog>
34 );
35
36 const getInputs = (data: any) => {
37     if (!data || !data.mounts || !data.mounts[MOUNT_PATH_CWL_WORKFLOW]) { return []; }
38     const inputs = getWorkflowInputs(data.mounts[MOUNT_PATH_CWL_WORKFLOW].content);
39     return inputs
40         ? inputs.map( (it: any) => (
41             {
42                 type: it.type,
43                 id: it.id,
44                 label: it.label,
45                 value: data.mounts[MOUNT_PATH_CWL_INPUT].content[it.id.split('/').pop()] || [],
46                 disabled: true
47             }))
48         : [];
49 };