21225: Add mutually exclusive tabs to multi panel view, use for project tabs
[arvados.git] / services / workbench2 / src / views / project-panel / project-panel.tsx
index 2cc751bffd6e78526b38ea07e8d0a5ca4d0683f2..3d64f6517abdcd2e64faa389e987bab1e193a643 100644 (file)
@@ -51,17 +51,28 @@ import { GroupClass, GroupResource } from 'models/group';
 import { CollectionResource } from 'models/collection';
 import { resourceIsFrozen } from 'common/frozen-resources';
 import { ProjectResource } from 'models/project';
-import { NotFoundView } from 'views/not-found-panel/not-found-panel';
+import { deselectAllOthers, toggleOne } from 'store/multiselect/multiselect-actions';
+import { DetailsCardRoot } from 'views-components/details-card/details-card-root';
+import { MPVContainer, MPVPanelContent, MPVPanelState } from 'components/multi-panel-view/multi-panel-view';
+import { PROJECT_PANEL_ID } from 'store/project-panel/project-panel-action-bind';
 
-type CssRules = 'root' | 'button';
+type CssRules = 'root' | 'button' | 'mpvRoot' | 'dataExplorer';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     root: {
         width: '100%',
+        display: 'flex',
+        flexDirection: 'column',
     },
     button: {
         marginLeft: theme.spacing.unit,
     },
+    mpvRoot: {
+        flexGrow: 1,
+    },
+    dataExplorer: {
+        height: "100%",
+    },
 });
 
 export enum ProjectPanelColumnNames {
@@ -232,10 +243,12 @@ export const projectPanelColumns: DataColumns<string, ProjectResource> = [
     },
 ];
 
-export const PROJECT_PANEL_ID = 'projectPanel';
-
 const DEFAULT_VIEW_MESSAGES = ['Your project is empty.', 'Please create a project or create a collection and upload a data.'];
 
+const panelsData: MPVPanelState[] = [
+    { name: "Subprojects", visible: true },
+];
+
 interface ProjectPanelDataProps {
     currentItemId: string;
     resources: ResourcesState;
@@ -243,6 +256,7 @@ interface ProjectPanelDataProps {
     isAdmin: boolean;
     userUuid: string;
     dataExplorerItems: any;
+    working: boolean;
 }
 
 type ProjectPanelProps = ProjectPanelDataProps & DispatchProp & WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
@@ -261,26 +275,36 @@ const mapStateToProps = (state: RootState) => {
 export const ProjectPanel = withStyles(styles)(
     connect(mapStateToProps)(
         class extends React.Component<ProjectPanelProps> {
+
             render() {
                 const { classes } = this.props;
-
-                return this.props.project ?
-                    <div data-cy='project-panel' className={classes.root}>
-                        <DataExplorer
-                            id={PROJECT_PANEL_ID}
-                            onRowClick={this.handleRowClick}
-                            onRowDoubleClick={this.handleRowDoubleClick}
-                            onContextMenu={this.handleContextMenu}
-                            contextMenuColumn={true}
-                            defaultViewIcon={ProjectIcon}
-                            defaultViewMessages={DEFAULT_VIEW_MESSAGES}
-                        />
-                    </div>
-                    :
-                    <NotFoundView
-                        icon={ProjectIcon}
-                        messages={["Project not found"]}
-                    />
+                return <div data-cy='project-panel' className={classes.root}>
+                    <DetailsCardRoot />
+                    <MPVContainer
+                        className={classes.mpvRoot}
+                        spacing={8}
+                        panelStates={panelsData}
+                        mutuallyExclusive
+                        justify-content="flex-start"
+                        direction="column"
+                        wrap="nowrap">
+                        <MPVPanelContent
+                            forwardProps
+                            xs="auto"
+                            data-cy="process-details"
+                            className={classes.dataExplorer}>
+                            <DataExplorer
+                                id={PROJECT_PANEL_ID}
+                                onRowClick={this.handleRowClick}
+                                onRowDoubleClick={this.handleRowDoubleClick}
+                                onContextMenu={this.handleContextMenu}
+                                contextMenuColumn={true}
+                                defaultViewIcon={ProjectIcon}
+                                defaultViewMessages={DEFAULT_VIEW_MESSAGES}
+                            />
+                        </MPVPanelContent>
+                    </MPVContainer>
+                </div>
             }
 
             isCurrentItemChild = (resource: Resource) => {
@@ -323,6 +347,8 @@ export const ProjectPanel = withStyles(styles)(
             };
 
             handleRowClick = (uuid: string) => {
+                this.props.dispatch<any>(toggleOne(uuid))
+                this.props.dispatch<any>(deselectAllOthers(uuid))
                 this.props.dispatch<any>(loadDetailsPanel(uuid));
             };
         }