1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from "react";
6 import { CustomStyleRulesCallback } from 'common/custom-theme';
7 import { WithStyles } from '@mui/styles';
8 import withStyles from '@mui/styles/withStyles';
9 import { ProcessIcon } from "components/icon/icon";
10 import { Process } from "store/processes/process";
11 import { SubprocessPanel } from "views/subprocess-panel/subprocess-panel";
12 import { SubprocessFilterDataProps } from "components/subprocess-filter/subprocess-filter";
13 import { MPVContainer, MPVPanelContent, MPVPanelState } from "components/multi-panel-view/multi-panel-view";
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";
27 import { NotFoundView } from 'views/not-found-panel/not-found-panel';
28 import { ArvadosTheme } from 'common/custom-theme';
30 type CssRules = "root";
32 const styles: CustomStyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
38 export interface ProcessPanelRootDataProps {
40 subprocesses: Array<Process>;
41 filters: Array<SubprocessFilterDataProps>;
42 processLogsPanel: ProcessLogsPanel;
44 inputRaw: WorkflowInputsData | null;
45 inputParams: ProcessIOParameter[] | null;
46 outputData: OutputDetails | null;
47 outputDefinitions: CommandOutputParameter[];
48 outputParams: ProcessIOParameter[] | null;
49 nodeInfo: NodeInstanceType | null;
50 usageReport: string | null;
53 export interface ProcessPanelRootActionProps {
54 onContextMenu: (event: React.MouseEvent<HTMLElement>, process: Process) => void;
55 onToggle: (status: string) => void;
56 cancelProcess: (uuid: string) => void;
57 startProcess: (uuid: string) => void;
58 resumeOnHoldWorkflow: (uuid: string) => void;
59 onLogFilterChange: (filter: FilterOption) => void;
60 navigateToLog: (uuid: string) => void;
61 onCopyToClipboard: (uuid: string) => void;
62 loadInputs: (containerRequest: ContainerRequestResource) => void;
63 loadOutputs: (containerRequest: ContainerRequestResource) => void;
64 loadNodeJson: (containerRequest: ContainerRequestResource) => void;
65 loadOutputDefinitions: (containerRequest: ContainerRequestResource) => void;
66 updateOutputParams: () => void;
67 pollProcessLogs: (processUuid: string) => Promise<void>;
70 export type ProcessPanelRootProps = ProcessPanelRootDataProps & ProcessPanelRootActionProps & WithStyles<CssRules>;
72 const panelsData: MPVPanelState[] = [
74 { name: "Logs", visible: true },
75 { name: "Subprocesses" },
79 { name: "Resources" },
82 export const ProcessPanelRoot = withStyles(styles)(({
96 loadOutputDefinitions,
99 }: ProcessPanelRootProps) => {
100 const outputUuid = process?.containerRequest.outputUuid;
101 const containerRequest = process?.containerRequest;
102 const inputMounts = getInputCollectionMounts(process?.containerRequest);
104 React.useEffect(() => {
105 if (containerRequest) {
106 // Load inputs from mounts or props
107 loadInputs(containerRequest);
108 // Fetch raw output (loads from props or keep)
109 loadOutputs(containerRequest);
110 // Loads output definitions from mounts into store
111 loadOutputDefinitions(containerRequest);
112 // load the assigned instance type from node.json in
113 // the log collection
114 loadNodeJson(containerRequest);
116 }, [containerRequest, loadInputs, loadOutputs, loadOutputDefinitions, loadNodeJson]);
118 const maxHeight = "100%";
120 // Trigger processing output params when raw or definitions change
121 React.useEffect(() => {
122 updateOutputParams();
123 }, [outputData, outputDefinitions, updateOutputParams]);
127 className={props.classes.root}
129 panelStates={panelsData}
130 justifyContent="flex-start"
136 data-cy="process-details">
139 onContextMenu={event => props.onContextMenu(event, process)}
140 cancelProcess={props.cancelProcess}
141 startProcess={props.startProcess}
142 resumeOnHoldWorkflow={props.resumeOnHoldWorkflow}
148 minHeight={maxHeight}
149 maxHeight={maxHeight}
150 data-cy="process-logs">
152 onCopy={props.onCopyToClipboard}
154 lines={getProcessPanelLogs(processLogsPanel)}
156 label: processLogsPanel.selectedFilter,
157 value: processLogsPanel.selectedFilter,
159 filters={processLogsPanel.filters.map(filter => ({ label: filter, value: filter }))}
160 onLogFilterChange={props.onLogFilterChange}
161 navigateToLog={props.navigateToLog}
162 pollProcessLogs={props.pollProcessLogs}
168 maxHeight={maxHeight}
169 data-cy="process-children">
170 <SubprocessPanel process={process} />
175 maxHeight={maxHeight}
176 data-cy="process-outputs">
178 label={ProcessIOCardType.OUTPUT}
180 params={outputParams}
181 raw={outputData?.raw}
182 outputUuid={outputUuid || ""}
188 maxHeight={maxHeight}
189 data-cy="process-inputs">
191 label={ProcessIOCardType.INPUT}
202 data-cy="process-cmd">
204 onCopy={props.onCopyToClipboard}
211 data-cy="process-resources">
215 usageReport={usageReport}
222 messages={["Process not found"]}