16672: Adds new prop to MPVContent: max height when not maximized.
authorLucas Di Pentima <lucas.dipentima@curii.com>
Fri, 18 Mar 2022 20:33:05 +0000 (17:33 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Fri, 25 Mar 2022 20:59:23 +0000 (17:59 -0300)
This applies to the Log panel so that it doesn't take the whole vertical
space available when sharing the UI with other panels.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

src/components/multi-panel-view/multi-panel-view.tsx
src/views/process-panel/process-panel-root.tsx

index b242f805a4e6f899cfd058eb06e3136039bfdb44..48241c0b61e03063af90f92b23e0e699707cc43c 100644 (file)
@@ -33,7 +33,6 @@ const styles: StyleRulesCallback<CssRules> = theme => ({
     },
     content: {
         overflow: 'auto',
-        height: '100%',
     },
 });
 
@@ -66,6 +65,7 @@ interface MPVPanelDataProps {
     panelIlluminated?: boolean;
     panelRef?: MutableRefObject<any>;
     forwardProps?: boolean;
+    maxHeight?: string;
 }
 
 interface MPVPanelActionProps {
@@ -79,14 +79,23 @@ export type MPVPanelProps = MPVPanelDataProps & MPVPanelActionProps;
 type MPVPanelContentProps = {children: ReactElement} & MPVPanelProps & GridProps;
 
 // Grid item compatible component for layout and MPV props passing
-export const MPVPanelContent = ({doHidePanel, doMaximizePanel, panelName, panelMaximized, panelIlluminated, panelRef, forwardProps, ...props}: MPVPanelContentProps) => {
+export const MPVPanelContent = ({doHidePanel, doMaximizePanel, panelName,
+    panelMaximized, panelIlluminated, panelRef, forwardProps, maxHeight,
+    ...props}: MPVPanelContentProps) => {
     useEffect(() => {
         if (panelRef && panelRef.current) {
             panelRef.current.scrollIntoView({behavior: 'smooth'});
         }
     }, [panelRef]);
 
-    return <Grid item style={{height: '100%'}} {...props}>
+    // If maxHeight is set, only apply it when not maximized
+    const mh = maxHeight
+        ? panelMaximized
+            ? '100%'
+            : maxHeight
+        : undefined;
+
+    return <Grid item style={{maxHeight: mh}} {...props}>
         <span ref={panelRef} /> {/* Element to scroll to when the panel is selected */}
         <Paper style={{height: '100%'}} elevation={panelIlluminated ? 8 : 0}>
             { forwardProps
index cf32b50f3ef7cd401180e5145652489334630662..78c79f8fec4c5cbe928648724b5c059484d0bbe2 100644 (file)
@@ -70,7 +70,7 @@ export const ProcessPanelRoot = withStyles(styles)(
             <MPVPanelContent forwardProps xs="auto">
                 <ProcessDetailsCard process={process} />
             </MPVPanelContent>
-            <MPVPanelContent forwardProps xs>
+            <MPVPanelContent forwardProps xs maxHeight='50%'>
                 <ProcessLogsCard
                     process={process}
                     lines={getProcessPanelLogs(processLogsPanel)}