18128: Adds unit tests.
[arvados-workbench2.git] / src / components / multi-panel-view / multi-panel-view.tsx
index e0698750610ad58b51236836c062fbbdeb4c83a4..35daa13cba586cc3e84c1d0195aac85ccd4bff7f 100644 (file)
@@ -11,7 +11,7 @@ import { InfoIcon, InvisibleIcon, VisibleIcon } from 'components/icon/icon';
 import { ReactNodeArray } from 'prop-types';
 import classNames from 'classnames';
 
-type CssRules = 'button' | 'buttonIcon';
+type CssRules = 'button' | 'buttonIcon' | 'content';
 
 const styles: StyleRulesCallback<CssRules> = theme => ({
     button: {
@@ -23,6 +23,9 @@ const styles: StyleRulesCallback<CssRules> = theme => ({
         padding: '2px 0px 2px 5px',
         fontSize: '1rem'
     },
+    content: {
+        overflow: 'auto',
+    },
 });
 
 interface MPVHideablePanelDataProps {
@@ -116,8 +119,8 @@ const MPVContainerComponent = ({children, panelStates, classes, ...props}: MPVCo
                 ? `Panel ${idx+1}`
                 : (panelStates[idx] && panelStates[idx].name) || `Panel ${idx+1}`;
             const toggleVariant = panelVisibility[idx]
-                ? "raised"
-                : "flat";
+                ? "contained"
+                : "text";
             const toggleTooltip = panelVisibility[idx]
                 ? `Hide ${panelName} panel`
                 : `Show ${panelName} panel`;
@@ -137,7 +140,7 @@ const MPVContainerComponent = ({children, panelStates, classes, ...props}: MPVCo
             ];
 
             const aPanel =
-                <MPVHideablePanel visible={panelVisibility[idx]} name={panelName}
+                <MPVHideablePanel key={idx} visible={panelVisibility[idx]} name={panelName}
                     maximized={panelIsMaximized}
                     doHidePanel={toggleFn(idx)} doMaximizePanel={maximizeFn(idx)}>
                     {children[idx]}
@@ -148,13 +151,15 @@ const MPVContainerComponent = ({children, panelStates, classes, ...props}: MPVCo
 
     return <Grid container {...props}>
         <Grid container item direction="row">
-            { toggles.map(tgl => <Grid item>{tgl}</Grid>) }
+            { toggles.map((tgl, idx) => <Grid item key={idx}>{tgl}</Grid>) }
+        </Grid>
+        <Grid container item {...props} xs className={classes.content}>
+            { panelVisibility.includes(true)
+                ? panels
+                : <Grid container item alignItems='center' justify='center'>
+                    <DefaultView messages={["All panels are hidden.", "Click on the buttons above to show them."]} icon={InfoIcon} />
+                </Grid> }
         </Grid>
-        { panelVisibility.includes(true)
-            ? panels
-            : <Grid container item alignItems='center' justify='center'>
-                <DefaultView messages={["All panels are hidden.", "Click on the buttons above to show them."]} icon={InfoIcon} />
-            </Grid> }
     </Grid>;
 };