21225: Add styles to wrap mutually exclusive tabs and data explorer in same paper
authorStephen Smith <stephen@curii.com>
Tue, 4 Jun 2024 20:07:31 +0000 (16:07 -0400)
committerStephen Smith <stephen@curii.com>
Fri, 7 Jun 2024 18:08:23 +0000 (14:08 -0400)
Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen@curii.com>

services/workbench2/src/components/data-explorer/data-explorer.tsx
services/workbench2/src/components/multi-panel-view/multi-panel-view.tsx
services/workbench2/src/views-components/data-explorer/data-explorer.tsx
services/workbench2/src/views/project-panel/project-panel-data.tsx
services/workbench2/src/views/project-panel/project-panel-run.tsx
services/workbench2/src/views/project-panel/project-panel.tsx

index 94deff0462bfcf6dbf312f02a56841bf3f381653..40ecfc5b3837fa6d9d7274797ac0aa77638f5e7d 100644 (file)
@@ -126,6 +126,7 @@ interface DataExplorerDataProps<T> {
     checkedList: TCheckedList;
     isNotFound: boolean;
     searchBarValue: string;
+    paperClassName?: string;
 }
 
 interface DataExplorerActionProps<T> {
@@ -218,10 +219,11 @@ export const DataExplorer = withStyles(styles)(
                 setCheckedListOnStore,
                 checkedList,
                 working,
+                paperClassName,
             } = this.props;
             return (
                 <Paper
-                    className={classes.root}
+                    className={classNames(classes.root, paperClassName)}
                     {...paperProps}
                     key={paperKey}
                     data-cy={this.props["data-cy"]}
index 69e2b7015e8061cd71ea373a8294e45ebb865533..10c671f05fd2adcb3ec602a198cb59b5aa743c6a 100644 (file)
@@ -21,12 +21,32 @@ import { InfoIcon } from 'components/icon/icon';
 import { ReactNodeArray } from 'prop-types';
 import classNames from 'classnames';
 
-type CssRules = 'root' | 'button' | 'buttonIcon' | 'content' | 'tabsWrapper' | 'tabsRoot' | 'tabs';
+type CssRules =
+    | 'gridContainerRoot'
+    | 'exclusiveGridContainerRoot'
+    | 'gridItemRoot'
+    | 'paperRoot'
+    | 'button'
+    | 'buttonIcon'
+    | 'content'
+    | 'exclusiveContentPaper'
+    | 'tabs';
 
 const styles: StyleRulesCallback<CssRules> = theme => ({
-    root: {
+    gridContainerRoot: {
         marginTop: '10px',
     },
+    exclusiveGridContainerRoot: {
+        marginTop: 0,
+    },
+    gridItemRoot: {
+        paddingTop: '0 !important',
+    },
+    paperRoot: {
+        height: '100%',
+        display: 'flex',
+        flexDirection: 'column',
+    },
     button: {
         padding: '2px 5px',
         marginRight: '5px',
@@ -40,11 +60,8 @@ const styles: StyleRulesCallback<CssRules> = theme => ({
         overflow: 'auto',
         maxWidth: 'initial',
     },
-    tabsWrapper: {
-        width: '100%',
-    },
-    tabsRoot: {
-        flexGrow: 1,
+    exclusiveContentPaper: {
+        boxShadow: 'none',
     },
     tabs: {
         flexGrow: 1,
@@ -60,6 +77,7 @@ interface MPVHideablePanelDataProps {
     illuminated: boolean;
     children: ReactNode;
     panelRef?: MutableRefObject<any>;
+    paperClassName?: string;
 }
 
 interface MPVHideablePanelActionProps {
@@ -70,10 +88,19 @@ interface MPVHideablePanelActionProps {
 
 type MPVHideablePanelProps = MPVHideablePanelDataProps & MPVHideablePanelActionProps;
 
-const MPVHideablePanel = ({ doHidePanel, doMaximizePanel, doUnMaximizePanel, name, visible, maximized, illuminated, ...props }: MPVHideablePanelProps) =>
+const MPVHideablePanel = ({ doHidePanel, doMaximizePanel, doUnMaximizePanel, name, visible, maximized, illuminated, paperClassName, ...props }: MPVHideablePanelProps) =>
     visible
         ? <>
-            {React.cloneElement((props.children as ReactElement), { doHidePanel, doMaximizePanel, doUnMaximizePanel, panelName: name, panelMaximized: maximized, panelIlluminated: illuminated, panelRef: props.panelRef })}
+            {React.cloneElement((props.children as ReactElement), {
+                doHidePanel,
+                doMaximizePanel,
+                doUnMaximizePanel,
+                panelName: name,
+                panelMaximized: maximized,
+                panelIlluminated: illuminated,
+                panelRef: props.panelRef,
+                paperClassName,
+            })}
         </>
         : null;
 
@@ -85,6 +112,7 @@ interface MPVPanelDataProps {
     forwardProps?: boolean;
     maxHeight?: string;
     minHeight?: string;
+    paperClassName?: string;
 }
 
 interface MPVPanelActionProps {
@@ -100,7 +128,7 @@ type MPVPanelContentProps = { children: ReactElement } & MPVPanelProps & GridPro
 
 // Grid item compatible component for layout and MPV props passing
 export const MPVPanelContent = ({ doHidePanel, doMaximizePanel, doUnMaximizePanel, panelName,
-    panelMaximized, panelIlluminated, panelRef, forwardProps, maxHeight, minHeight,
+    panelMaximized, panelIlluminated, panelRef, forwardProps, maxHeight, minHeight, paperClassName,
     ...props }: MPVPanelContentProps) => {
     useEffect(() => {
         if (panelRef && panelRef.current) {
@@ -116,8 +144,8 @@ export const MPVPanelContent = ({ doHidePanel, doMaximizePanel, doUnMaximizePane
         <span ref={panelRef} /> {/* Element to scroll to when the panel is selected */}
         <Paper style={{ height: '100%' }} elevation={panelIlluminated ? 8 : 0}>
             {forwardProps
-                ? React.cloneElement(props.children, { doHidePanel, doMaximizePanel, doUnMaximizePanel, panelName, panelMaximized })
-                : props.children}
+                ? React.cloneElement(props.children, { doHidePanel, doMaximizePanel, doUnMaximizePanel, panelName, panelMaximized, paperClassName })
+                : React.cloneElement(props.children, { paperClassName })}
         </Paper>
     </Grid>;
 }
@@ -231,7 +259,11 @@ const MPVContainerComponent = ({ children, panelStates, classes, ...props }: MPV
             ];
 
             const aPanel =
-                <MPVHideablePanel key={idx} visible={panelVisibility[idx]} name={panelName}
+                <MPVHideablePanel
+                    key={idx}
+                    visible={panelVisibility[idx]}
+                    name={panelName}
+                    paperClassName={props.mutuallyExclusive ? classes.exclusiveContentPaper : undefined}
                     panelRef={(idx === selectedPanel) ? panelRef : undefined}
                     maximized={panelIsMaximized} illuminated={idx === highlightedPanel}
                     doHidePanel={hideFn(idx)} doMaximizePanel={maximizeFn(idx)} doUnMaximizePanel={panelIsMaximized ? unMaximizeFn(idx) : () => null}>
@@ -241,29 +273,38 @@ const MPVContainerComponent = ({ children, panelStates, classes, ...props }: MPV
         };
 
         buttonBar = props.mutuallyExclusive ?
-            <Paper className={classes.tabsWrapper}>
-                <Tabs className={classes.tabsRoot} value={currentSelectedPanel} onChange={(e, val) => showFn(val)()}>
-                    {tabs.map((tgl, idx) => <Tab className={classes.tabs} key={idx} label={tgl} />)}
-                </Tabs>
-            </Paper> :
-            <>
+            <Tabs value={currentSelectedPanel} onChange={(e, val) => showFn(val)()}>
+                {tabs.map((tgl, idx) => <Tab className={classes.tabs} key={idx} label={tgl} />)}
+            </Tabs> :
+            <Grid container item direction="row">
                 {buttons.map((tgl, idx) => <Grid item key={idx}>{tgl}</Grid>)}
-            </>;
+            </Grid>;
     };
 
-    return <Grid container {...props} className={classNames(classes.root, props.className)}>
-        <Grid container item direction="row">
-            {buttonBar}
-        </Grid>
-        <Grid container item {...props} xs className={classes.content}
-            onScroll={() => setSelectedPanel(-1)}>
-            {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>
+    const content = <Grid container item {...props} xs className={classes.content}
+        onScroll={() => setSelectedPanel(-1)}>
+        {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>;
+
+    if (props.mutuallyExclusive) {
+        return <Grid container {...props} className={classNames(classes.exclusiveGridContainerRoot, props.className)}>
+            <Grid item {...props} className={classes.gridItemRoot}>
+                <Paper className={classes.paperRoot}>
+                    {buttonBar}
+                    {content}
+                </Paper>
+            </Grid>
+        </Grid>;
+    } else {
+        return <Grid container {...props} className={classNames(classes.gridContainerRoot, props.className)}>
+            {buttonBar}
+            {content}
+        </Grid>;
+    }
 };
 
 export const MPVContainer = withStyles(styles)(MPVContainerComponent);
index 0f4fc5635817830e20e175df85bc5eddecddb8ec..bcf8683e89ff724cd0b731b358d6ff80d59fc842 100644 (file)
@@ -86,7 +86,7 @@ const mapDispatchToProps = () => {
         setSelectedUuid: (uuid: string | null) => {
             dispatch<any>(setSelectedResourceUuid(uuid));
         },
-        
+
         onRowClick,
 
         onRowDoubleClick,
index 59c6f2250638b82946e30d4beca69be7ca9a40d8..8526ebf08304b0bdf97ffda473654d8b4a247e6c 100644 (file)
@@ -150,7 +150,11 @@ export const projectPanelDataColumns: DataColumns<string, ProjectResource> = [
 
 const DEFAULT_VIEW_MESSAGES = ['No data found'];
 
-export const ProjectPanelData = class extends React.Component {
+interface ProjectPanelDataProps {
+    paperClassName?: string;
+};
+
+export const ProjectPanelData = class extends React.Component<ProjectPanelDataProps> {
     handleRowClick = () => {};
     handleRowDoubleClick = () => {};
     handleContextMenu = () => {};
@@ -164,6 +168,7 @@ export const ProjectPanelData = class extends React.Component {
             contextMenuColumn={true}
             defaultViewIcon={ProjectIcon}
             defaultViewMessages={DEFAULT_VIEW_MESSAGES}
+            paperClassName={this.props.paperClassName}
         />;
     }
 };
index 0dcda89e8b7bfe4382e84c667697574ae0d3d329..e89e76138912cb94f7ec322cadc00dea5dc7d6a4 100644 (file)
@@ -174,6 +174,7 @@ const DEFAULT_VIEW_MESSAGES = ['No workflow runs found'];
 
 interface ProjectPanelRunProps {
     project?: ProjectResource;
+    paperClassName?: string;
 }
 
 const mapStateToProps = (state: RootState): ProjectPanelRunProps => {
@@ -198,5 +199,6 @@ export const ProjectPanelRun = connect(mapStateToProps)((props: ProjectPanelRunP
         defaultViewIcon={ProjectIcon}
         defaultViewMessages={DEFAULT_VIEW_MESSAGES}
         progressBar={<SubprocessProgressBar parentResource={props.project} dataExplorerId={PROJECT_PANEL_RUN_ID} />}
+        paperClassName={props.paperClassName}
     />;
 });
index fe01a9344f36bcc31e1691e43840722ae2bba84d..f84d8e70904f9f497fe2616d02044ba459023536 100644 (file)
@@ -39,6 +39,11 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     },
     mpvRoot: {
         flexGrow: 1,
+        display: 'flex',
+        flexDirection: 'column',
+        '& > div': {
+            height: '100%',
+        },
     },
     dataExplorer: {
         height: "100%",
@@ -92,14 +97,14 @@ export const ProjectPanel = withStyles(styles)(
                         <MPVPanelContent
                             forwardProps
                             xs="auto"
-                            data-cy="process-details"
+                            data-cy="process-data"
                             className={classes.dataExplorer}>
                             <ProjectPanelData />
                         </MPVPanelContent>
                         <MPVPanelContent
                             forwardProps
                             xs="auto"
-                            data-cy="process-details"
+                            data-cy="process-run"
                             className={classes.dataExplorer}>
                             <ProjectPanelRun />
                         </MPVPanelContent>