X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/1072269cec78f75ec8995afab82d0faaa485f5da..b334ada5137efaaaa24ed93ce97a03b7838c924a:/src/views/process-panel/process-panel-root.tsx

diff --git a/src/views/process-panel/process-panel-root.tsx b/src/views/process-panel/process-panel-root.tsx
index 248c5215..c2267ec0 100644
--- a/src/views/process-panel/process-panel-root.tsx
+++ b/src/views/process-panel/process-panel-root.tsx
@@ -70,6 +70,7 @@ export const ProcessPanelRoot = withStyles(styles)(
     ({ process, auth, processLogsPanel, fetchOutputs, ...props }: ProcessPanelRootProps) => {
 
     const [outputDetails, setOutputs] = useState<OutputDetails | undefined>(undefined);
+    const [outputDefinitions, setOutputDefinitions] = useState<CommandOutputParameter[]>([]);
     const [rawInputs, setInputs] = useState<CommandInputParameter[] | undefined>(undefined);
 
     const [processedOutputs, setProcessedOutputs] = useState<ProcessIOParameter[] | undefined>(undefined);
@@ -85,6 +86,7 @@ export const ProcessPanelRoot = withStyles(styles)(
     // Resets state when changing processes
     React.useEffect(() => {
         setOutputs(undefined);
+        setOutputDefinitions([]);
         setInputs(undefined);
         setProcessedOutputs(undefined);
         setProcessedInputs(undefined);
@@ -97,25 +99,40 @@ export const ProcessPanelRoot = withStyles(styles)(
         }
     }, [containerRequest, fetchOutputs]);
 
+    // Fetch outputDefinitons from mounts whenever containerRequest is updated
+    React.useEffect(() => {
+        if (containerRequest && containerRequest.mounts) {
+            const newOutputDefinitions = getOutputParameters(containerRequest);
+            // Avoid setting output definitions to [] when mounts briefly go missing
+            if (newOutputDefinitions.length) {
+                setOutputDefinitions(newOutputDefinitions);
+            }
+        }
+    }, [containerRequest]);
+
     // Format raw output into ProcessIOParameter[] when it changes
     React.useEffect(() => {
-        if (outputDetails !== undefined && outputDetails.rawOutputs && containerRequest) {
-            const outputDefinitions = getOutputParameters(containerRequest);
+        if (outputDetails !== undefined && outputDetails.rawOutputs) {
+            // Update processed outputs as long as outputDetails is loaded (or failed to load with {} rawOutputs)
             setProcessedOutputs(formatOutputData(outputDefinitions, outputDetails.rawOutputs, outputDetails.pdh, auth));
         }
-    }, [outputDetails, auth, containerRequest]);
+    }, [outputDetails, auth, outputDefinitions]);
 
     // Fetch raw inputs and format into ProcessIOParameter[]
     //   Can be sync because inputs are either already in containerRequest mounts or props
     React.useEffect(() => {
         if (containerRequest) {
-            const rawInputs = getRawInputs(containerRequest);
-            setInputs(rawInputs);
-
-            const inputs = getInputs(containerRequest);
-            setProcessedInputs(formatInputData(inputs, auth));
+            // Since mounts can disappear and reappear, only set inputs if raw / processed inputs is undefined or new inputs has content
+            const newRawInputs = getRawInputs(containerRequest);
+            if (rawInputs === undefined || (newRawInputs && newRawInputs.length)) {
+                setInputs(newRawInputs);
+            }
+            const newInputs = getInputs(containerRequest);
+            if (processedInputs === undefined || (newInputs && newInputs.length)) {
+                setProcessedInputs(formatInputData(newInputs, auth));
+            }
         }
-    }, [requestUuid, auth, containerRequest]);
+    }, [requestUuid, auth, containerRequest, processedInputs, rawInputs]);
 
     return process
         ? <MPVContainer className={props.classes.root} spacing={8} panelStates={panelsData}  justify-content="flex-start" direction="column" wrap="nowrap">
