1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { Grid, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
7 import { DefaultView } from 'components/default-view/default-view';
8 import { ProcessIcon } from 'components/icon/icon';
9 import { Process } from 'store/processes/process';
10 import { SubprocessPanel } from 'views/subprocess-panel/subprocess-panel';
11 import { SubprocessFilterDataProps } from 'components/subprocess-filter/subprocess-filter';
12 import { MPVContainer, MPVPanelContent, MPVPanelState } from 'components/multi-panel-view/multi-panel-view';
13 import { ArvadosTheme } from 'common/custom-theme';
14 import { ProcessDetailsCard } from './process-details-card';
15 import { ProcessIOCard, ProcessIOCardType, ProcessIOParameter } from './process-io-card';
16 import { ProcessResourceCard } from './process-resource-card';
17 import { getProcessPanelLogs, ProcessLogsPanel } from 'store/process-logs-panel/process-logs-panel';
18 import { ProcessLogsCard } from './process-log-card';
19 import { FilterOption } from 'views/process-panel/process-log-form';
20 import { getInputCollectionMounts } from 'store/processes/processes-actions';
21 import { WorkflowInputsData } from 'models/workflow';
22 import { CommandOutputParameter } from 'cwlts/mappings/v1.0/CommandOutputParameter';
23 import { AuthState } from 'store/auth/auth-reducer';
24 import { ProcessCmdCard } from './process-cmd-card';
25 import { ContainerRequestResource } from 'models/container-request';
26 import { OutputDetails, NodeInstanceType } from 'store/process-panel/process-panel';
28 type CssRules = 'root';
30 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
36 export interface ProcessPanelRootDataProps {
38 subprocesses: Array<Process>;
39 filters: Array<SubprocessFilterDataProps>;
40 processLogsPanel: ProcessLogsPanel;
42 inputRaw: WorkflowInputsData | null;
43 inputParams: ProcessIOParameter[] | null;
44 outputRaw: OutputDetails | null;
45 outputDefinitions: CommandOutputParameter[];
46 outputParams: ProcessIOParameter[] | null;
47 nodeInfo: NodeInstanceType | null;
50 export interface ProcessPanelRootActionProps {
51 onContextMenu: (event: React.MouseEvent<HTMLElement>, process: Process) => void;
52 onToggle: (status: string) => void;
53 cancelProcess: (uuid: string) => void;
54 startProcess: (uuid: string) => void;
55 resumeOnHoldWorkflow: (uuid: string) => void;
56 onLogFilterChange: (filter: FilterOption) => void;
57 navigateToLog: (uuid: string) => void;
58 onCopyToClipboard: (uuid: string) => void;
59 loadInputs: (containerRequest: ContainerRequestResource) => void;
60 loadOutputs: (containerRequest: ContainerRequestResource) => void;
61 loadNodeJson: (containerRequest: ContainerRequestResource) => void;
62 loadOutputDefinitions: (containerRequest: ContainerRequestResource) => void;
63 updateOutputParams: () => void;
66 export type ProcessPanelRootProps = ProcessPanelRootDataProps & ProcessPanelRootActionProps & WithStyles<CssRules>;
68 const panelsData: MPVPanelState[] = [
71 { name: "Logs", visible: true },
74 { name: "Resources" },
75 { name: "Subprocesses" },
78 export const ProcessPanelRoot = withStyles(styles)(
92 loadOutputDefinitions,
95 }: ProcessPanelRootProps) => {
97 const outputUuid = process?.containerRequest.outputUuid;
98 const containerRequest = process?.containerRequest;
99 const inputMounts = getInputCollectionMounts(process?.containerRequest);
101 React.useEffect(() => {
102 if (containerRequest) {
103 // Load inputs from mounts or props
104 loadInputs(containerRequest);
105 // Fetch raw output (loads from props or keep)
106 loadOutputs(containerRequest);
107 // Loads output definitions from mounts into store
108 loadOutputDefinitions(containerRequest);
109 // load the assigned instance type from node.json in
110 // the log collection
111 loadNodeJson(containerRequest);
113 }, [containerRequest, loadInputs, loadOutputs, loadOutputDefinitions, loadNodeJson]);
115 // Trigger processing output params when raw or definitions change
116 React.useEffect(() => {
117 updateOutputParams();
118 }, [outputRaw, outputDefinitions, updateOutputParams]);
121 ? <MPVContainer className={props.classes.root} spacing={8} panelStates={panelsData} justify-content="flex-start" direction="column" wrap="nowrap">
122 <MPVPanelContent forwardProps xs="auto" data-cy="process-details">
125 onContextMenu={event => props.onContextMenu(event, process)}
126 cancelProcess={props.cancelProcess}
127 startProcess={props.startProcess}
128 resumeOnHoldWorkflow={props.resumeOnHoldWorkflow}
131 <MPVPanelContent forwardProps xs="auto" data-cy="process-cmd">
133 onCopy={props.onCopyToClipboard}
136 <MPVPanelContent forwardProps xs minHeight='50%' data-cy="process-logs">
138 onCopy={props.onCopyToClipboard}
140 lines={getProcessPanelLogs(processLogsPanel)}
142 label: processLogsPanel.selectedFilter,
143 value: processLogsPanel.selectedFilter
145 filters={processLogsPanel.filters.map(
146 filter => ({ label: filter, value: filter })
148 onLogFilterChange={props.onLogFilterChange}
149 navigateToLog={props.navigateToLog}
152 <MPVPanelContent forwardProps xs maxHeight='50%' data-cy="process-inputs">
154 label={ProcessIOCardType.INPUT}
161 <MPVPanelContent forwardProps xs maxHeight='50%' data-cy="process-outputs">
163 label={ProcessIOCardType.OUTPUT}
165 params={outputParams}
166 raw={outputRaw?.rawOutputs}
167 outputUuid={outputUuid || ""}
170 <MPVPanelContent forwardProps xs data-cy="process-resources">
176 <MPVPanelContent forwardProps xs maxHeight='50%' data-cy="process-children">
183 style={{ minHeight: '100%' }}>
186 messages={['Process not found']} />