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 onLogFilterChange: (filter: FilterOption) => void;
56 navigateToLog: (uuid: string) => void;
57 onCopyToClipboard: (uuid: string) => void;
58 loadInputs: (containerRequest: ContainerRequestResource) => void;
59 loadOutputs: (containerRequest: ContainerRequestResource) => void;
60 loadNodeJson: (containerRequest: ContainerRequestResource) => void;
61 loadOutputDefinitions: (containerRequest: ContainerRequestResource) => void;
62 updateOutputParams: () => void;
65 export type ProcessPanelRootProps = ProcessPanelRootDataProps & ProcessPanelRootActionProps & WithStyles<CssRules>;
67 const panelsData: MPVPanelState[] = [
70 { name: "Logs", visible: true },
73 { name: "Resources" },
74 { name: "Subprocesses" },
77 export const ProcessPanelRoot = withStyles(styles)(
91 loadOutputDefinitions,
94 }: ProcessPanelRootProps) => {
96 const outputUuid = process?.containerRequest.outputUuid;
97 const containerRequest = process?.containerRequest;
98 const inputMounts = getInputCollectionMounts(process?.containerRequest);
100 React.useEffect(() => {
101 if (containerRequest) {
102 // Load inputs from mounts or props
103 loadInputs(containerRequest);
104 // Fetch raw output (loads from props or keep)
105 loadOutputs(containerRequest);
106 // Loads output definitions from mounts into store
107 loadOutputDefinitions(containerRequest);
108 // load the assigned instance type from node.json in
109 // the log collection
110 loadNodeJson(containerRequest);
112 }, [containerRequest, loadInputs, loadOutputs, loadOutputDefinitions, loadNodeJson]);
114 // Trigger processing output params when raw or definitions change
115 React.useEffect(() => {
116 updateOutputParams();
117 }, [outputRaw, outputDefinitions, updateOutputParams]);
120 ? <MPVContainer className={props.classes.root} spacing={8} panelStates={panelsData} justify-content="flex-start" direction="column" wrap="nowrap">
121 <MPVPanelContent forwardProps xs="auto" data-cy="process-details">
124 onContextMenu={event => props.onContextMenu(event, process)}
125 cancelProcess={props.cancelProcess}
126 startProcess={props.startProcess}
129 <MPVPanelContent forwardProps xs="auto" data-cy="process-cmd">
131 onCopy={props.onCopyToClipboard}
134 <MPVPanelContent forwardProps xs minHeight='50%' data-cy="process-logs">
136 onCopy={props.onCopyToClipboard}
138 lines={getProcessPanelLogs(processLogsPanel)}
140 label: processLogsPanel.selectedFilter,
141 value: processLogsPanel.selectedFilter
143 filters={processLogsPanel.filters.map(
144 filter => ({ label: filter, value: filter })
146 onLogFilterChange={props.onLogFilterChange}
147 navigateToLog={props.navigateToLog}
150 <MPVPanelContent forwardProps xs maxHeight='50%' data-cy="process-inputs">
152 label={ProcessIOCardType.INPUT}
159 <MPVPanelContent forwardProps xs maxHeight='50%' data-cy="process-outputs">
161 label={ProcessIOCardType.OUTPUT}
163 params={outputParams}
164 raw={outputRaw?.rawOutputs}
165 outputUuid={outputUuid || ""}
168 <MPVPanelContent forwardProps xs data-cy="process-resources">
174 <MPVPanelContent forwardProps xs maxHeight='50%' data-cy="process-children">
181 style={{ minHeight: '100%' }}>
184 messages={['Process not found']} />