Merge branch '13704-navigation-details-panel'
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Fri, 6 Jul 2018 10:55:36 +0000 (12:55 +0200)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Fri, 6 Jul 2018 10:55:36 +0000 (12:55 +0200)
refs #13704

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

src/common/custom-theme.ts [new file with mode: 0644]
src/components/attribute/attribute.tsx [new file with mode: 0644]
src/components/side-panel/side-panel.tsx
src/index.tsx
src/views-components/details-panel/details-panel.tsx [new file with mode: 0644]
src/views-components/main-app-bar/main-app-bar.test.tsx
src/views-components/main-app-bar/main-app-bar.tsx
src/views/workbench/workbench.tsx

diff --git a/src/common/custom-theme.ts b/src/common/custom-theme.ts
new file mode 100644 (file)
index 0000000..0850f88
--- /dev/null
@@ -0,0 +1,62 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { createMuiTheme } from '@material-ui/core/styles';
+import { ThemeOptions, Theme } from '@material-ui/core/styles/createMuiTheme';
+import purple from '@material-ui/core/colors/purple';
+import blue from '@material-ui/core/colors/blue';
+import grey from '@material-ui/core/colors/grey';
+import green from '@material-ui/core/colors/green';
+
+interface ArvadosThemeOptions extends ThemeOptions {
+    customs: any;
+}
+
+export interface ArvadosTheme extends Theme {
+    customs: any;
+}
+
+const purple900 = purple["900"];
+const grey600 = grey["600"];
+const themeOptions: ArvadosThemeOptions = {
+    customs: {
+        colors: {
+            green700: green["700"]
+        }
+    },
+    overrides: {
+        MuiAppBar: {
+            colorPrimary: {
+                backgroundColor: purple900
+            }
+        },
+        MuiTabs: {
+            root: {
+                color: grey600
+            },
+            indicator: {
+                backgroundColor: purple900
+            }
+        },
+        MuiTab: {
+            selected: {
+                fontWeight: 700,
+                color: purple900
+            }
+        }
+    },
+    mixins: {
+        toolbar: {
+            minHeight: '48px'
+        }
+    },
+    palette: {
+        primary: {
+            main: '#06C',
+            dark: blue.A100
+        }
+    }
+};
+
+export const CustomTheme = createMuiTheme(themeOptions);
\ No newline at end of file
diff --git a/src/components/attribute/attribute.tsx b/src/components/attribute/attribute.tsx
new file mode 100644 (file)
index 0000000..131d629
--- /dev/null
@@ -0,0 +1,46 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import Typography from '@material-ui/core/Typography';
+import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
+import { ArvadosTheme } from 'src/common/custom-theme';
+
+interface AttributeDataProps {
+    label: string;
+}
+
+type AttributeProps = AttributeDataProps & WithStyles<CssRules>;
+
+class Attribute extends React.Component<AttributeProps> {
+
+    render() {
+        const { label, children, classes } = this.props;
+        return <Typography component="div" className={classes.attribute}>
+                <span className={classes.label}>{label}</span>
+                <span className={classes.value}>{children}</span>
+            </Typography>;
+    }
+
+}
+
+type CssRules = 'attribute' | 'label' | 'value';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+    attribute: {
+        display: 'flex',
+        alignItems: 'center',
+        marginBottom: theme.spacing.unit
+    },
+    label: {
+        color: theme.palette.grey["500"],
+        width: '40%'
+    },
+    value: {
+        display: 'flex',
+        alignItems: 'center'
+    }
+});
+
+export default withStyles(styles)(Attribute);
\ No newline at end of file
index ac2073019d6cce5e7950dc6f92580c38fb1310e5..cc191e808df6bd4770f9f60df1888cb0e7ad1671 100644 (file)
@@ -92,7 +92,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
         overflowY: 'auto',
         minWidth: '240px',
         whiteSpace: 'nowrap',
-        marginTop: '38px',
+        marginTop: '52px',
         display: 'flex',
         flexGrow: 1,
     },
index 580487846f05f9074068b20761c3b81579768f5b..21ecdab1ca0c5cf70dc84893501154d7601a3235 100644 (file)
@@ -15,6 +15,8 @@ import ApiToken from "./views-components/api-token/api-token";
 import authActions from "./store/auth/auth-action";
 import { authService } from "./services/services";
 import { getProjectList } from "./store/project/project-action";
+import { MuiThemeProvider } from '@material-ui/core/styles';
+import { CustomTheme } from './common/custom-theme';
 
 const history = createBrowserHistory();
 
@@ -25,14 +27,16 @@ const rootUuid = authService.getRootUuid();
 store.dispatch<any>(getProjectList(rootUuid));
 
 const App = () =>
-    <Provider store={store}>
-        <ConnectedRouter history={history}>
-            <div>
-                <Route path="/" component={Workbench}/>
-                <Route path="/token" component={ApiToken}/>
-            </div>
-        </ConnectedRouter>
-    </Provider>;
+    <MuiThemeProvider theme={CustomTheme}>
+        <Provider store={store}>
+            <ConnectedRouter history={history}>
+                <div>
+                    <Route path="/" component={Workbench}/>
+                    <Route path="/token" component={ApiToken}/>
+                </div>
+            </ConnectedRouter>
+        </Provider>
+    </MuiThemeProvider>;
 
 ReactDOM.render(
     <App/>,
diff --git a/src/views-components/details-panel/details-panel.tsx b/src/views-components/details-panel/details-panel.tsx
new file mode 100644 (file)
index 0000000..be257e8
--- /dev/null
@@ -0,0 +1,119 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import Drawer from '@material-ui/core/Drawer';
+import IconButton from "@material-ui/core/IconButton";
+import CloseIcon from '@material-ui/icons/Close';
+import FolderIcon from '@material-ui/icons/Folder';
+import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
+import { ArvadosTheme } from '../../common/custom-theme';
+import Attribute from '../../components/attribute/attribute';
+import Tabs from '@material-ui/core/Tabs';
+import Tab from '@material-ui/core/Tab';
+import Typography from '@material-ui/core/Typography';
+import Grid from '@material-ui/core/Grid';
+import * as classnames from "classnames";
+
+export interface DetailsPanelProps {
+    onCloseDrawer: () => void;
+    isOpened: boolean;
+}
+
+class DetailsPanel extends React.Component<DetailsPanelProps & WithStyles<CssRules>, {}> {
+       state = {
+               tabsValue: 0,
+       };
+
+       handleChange = (event: any, value: boolean) => {
+               this.setState({ tabsValue: value });
+       }
+    
+    renderTabContainer = (children: React.ReactElement<any>) => 
+        <Typography className={this.props.classes.tabContainer} component="div">
+            {children}
+        </Typography>
+
+       render() {
+        const { classes, onCloseDrawer, isOpened } = this.props;
+               const { tabsValue } = this.state;
+        return (
+            <div className={classnames([classes.container, { [classes.opened]: isOpened }])}>
+                <Drawer variant="permanent" anchor="right" classes={{ paper: classes.drawerPaper }}>
+                                       <Typography component="div" className={classes.headerContainer}>
+                                               <Grid container alignItems='center' justify='space-around'>
+                            <i className="fas fa-cogs fa-lg" />
+                                                       <Typography variant="title">
+                                                               Tutorial pipeline
+                                                       </Typography>
+                            <IconButton color="inherit" onClick={onCloseDrawer}>
+                                                               <CloseIcon />
+                                                       </IconButton>
+                                               </Grid>
+                                       </Typography>
+                                       <Tabs value={tabsValue} onChange={this.handleChange}>
+                                               <Tab disableRipple label="Details" />
+                                               <Tab disableRipple label="Activity" />
+                                       </Tabs>
+                    {tabsValue === 0 && this.renderTabContainer(
+                        <Grid container direction="column">
+                            <Attribute label="Type">Process</Attribute>
+                            <Attribute label="Size">---</Attribute>
+                            <Attribute label="Location">
+                                <FolderIcon />
+                                Projects
+                            </Attribute>
+                            <Attribute label="Owner">me</Attribute>
+                                               </Grid>
+                                       )}
+                    {tabsValue === 1 && this.renderTabContainer(
+                        <Grid container direction="column">
+                            <Attribute label="Type">Process</Attribute>
+                            <Attribute label="Size">---</Attribute>
+                            <Attribute label="Location">
+                                <FolderIcon />
+                                Projects
+                            </Attribute>
+                            <Attribute label="Owner">me</Attribute>
+                        </Grid>
+                                       )}
+                </Drawer>
+            </div>
+        );
+    }
+
+}
+
+type CssRules = 'drawerPaper' | 'container' | 'opened' | 'headerContainer' | 'tabContainer';
+
+const drawerWidth = 320;
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+       container: {
+        width: 0,
+               position: 'relative',
+        height: 'auto',
+        transition: 'width 0.5s ease',
+        '&$opened': {
+            width: drawerWidth
+        }
+    },
+    opened: {},
+    drawerPaper: {
+        position: 'relative',
+        width: drawerWidth
+       },
+       headerContainer: {
+        color: theme.palette.grey["600"],
+        margin: `${theme.spacing.unit}px 0`,
+        '& .fa-cogs': {
+            fontSize: "24px",
+            color: theme.customs.colors.green700
+        }
+       },
+       tabContainer: {
+               padding: theme.spacing.unit * 3
+       }
+});
+
+export default withStyles(styles)(DetailsPanel);
\ No newline at end of file
index 25494b65a07c2e9c76757f84a25a26400a196ead..7bdb63b3f61f36dc3510f583f3a316890100e1cc 100644 (file)
@@ -28,6 +28,7 @@ describe("<MainAppBar />", () => {
         const mainAppBar = mount(
             <MainAppBar
                 user={user}
+                onDetailsPanelToggle={jest.fn()}
                 {...{ searchText: "", breadcrumbs: [], menuItems: { accountMenu: [], helpMenu: [], anonymousMenu: [] }, onSearch: jest.fn(), onBreadcrumbClick: jest.fn(), onMenuItemClick: jest.fn() }}
             />
         );
@@ -41,6 +42,7 @@ describe("<MainAppBar />", () => {
         const mainAppBar = mount(
             <MainAppBar
                 menuItems={menuItems}
+                onDetailsPanelToggle={jest.fn()}
                 {...{ searchText: "", breadcrumbs: [], onSearch: jest.fn(), onBreadcrumbClick: jest.fn(), onMenuItemClick: jest.fn() }}
             />
         );
@@ -57,6 +59,7 @@ describe("<MainAppBar />", () => {
                 searchText="search text"
                 searchDebounce={2000}
                 onSearch={onSearch}
+                onDetailsPanelToggle={jest.fn()}
                 {...{ user, breadcrumbs: [], menuItems: { accountMenu: [], helpMenu: [], anonymousMenu: [] }, onBreadcrumbClick: jest.fn(), onMenuItemClick: jest.fn() }}
             />
         );
@@ -74,6 +77,7 @@ describe("<MainAppBar />", () => {
             <MainAppBar
                 breadcrumbs={items}
                 onBreadcrumbClick={onBreadcrumbClick}
+                onDetailsPanelToggle={jest.fn()}
                 {...{ user, searchText: "", menuItems: { accountMenu: [], helpMenu: [], anonymousMenu: [] }, onSearch: jest.fn(), onMenuItemClick: jest.fn() }}
             />
         );
@@ -90,6 +94,7 @@ describe("<MainAppBar />", () => {
             <MainAppBar
                 menuItems={menuItems}
                 onMenuItemClick={onMenuItemClick}
+                onDetailsPanelToggle={jest.fn()}
                 {...{ user, searchText: "", breadcrumbs: [], onSearch: jest.fn(), onBreadcrumbClick: jest.fn() }}
             />
         );
index c0525a566843e9a10f75b0a38fb84babef482c38..1230e3b7db60abe9901db66fa28a310a6737c804 100644 (file)
@@ -3,10 +3,11 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from "react";
-import { AppBar, Toolbar, Typography, Grid, IconButton, Badge, StyleRulesCallback, withStyles, WithStyles, Button, MenuItem } from "@material-ui/core";
+import { AppBar, Toolbar, Typography, Grid, IconButton, Badge, Button, MenuItem } from "@material-ui/core";
 import NotificationsIcon from "@material-ui/icons/Notifications";
 import PersonIcon from "@material-ui/icons/Person";
 import HelpIcon from "@material-ui/icons/Help";
+import InfoIcon from '@material-ui/icons/Info';
 import SearchBar from "../../components/search-bar/search-bar";
 import Breadcrumbs, { Breadcrumb } from "../../components/breadcrumbs/breadcrumbs";
 import DropdownMenu from "../../components/dropdown-menu/dropdown-menu";
@@ -34,17 +35,15 @@ export interface MainAppBarActionProps {
     onSearch: (searchText: string) => void;
     onBreadcrumbClick: (breadcrumb: Breadcrumb) => void;
     onMenuItemClick: (menuItem: MainAppBarMenuItem) => void;
+    onDetailsPanelToggle: () => void;
 }
 
-type MainAppBarProps = MainAppBarDataProps & MainAppBarActionProps & WithStyles<CssRules>;
+type MainAppBarProps = MainAppBarDataProps & MainAppBarActionProps;
 
 export const MainAppBar: React.SFC<MainAppBarProps> = (props) => {
-    return <AppBar className={props.classes.appBar} position="static">
-        <Toolbar className={props.classes.toolbar}>
-            <Grid
-                container
-                justify="space-between"
-            >
+    return <AppBar position="static">
+        <Toolbar>
+            <Grid container justify="space-between">
                 <Grid item xs={3}>
                     <Typography variant="headline" color="inherit" noWrap>
                         Arvados
@@ -69,11 +68,14 @@ export const MainAppBar: React.SFC<MainAppBarProps> = (props) => {
                 </Grid>
             </Grid>
         </Toolbar>
-        {
-            props.user && <Toolbar className={props.classes.toolbar}>
-                <Breadcrumbs items={props.breadcrumbs} onClick={props.onBreadcrumbClick} />
-            </Toolbar>
-        }
+        <Toolbar >
+            {
+                props.user && <Breadcrumbs items={props.breadcrumbs} onClick={props.onBreadcrumbClick} />
+            }
+            <IconButton color="inherit" onClick={props.onDetailsPanelToggle}>
+                <InfoIcon />
+            </IconButton>
+        </Toolbar>
     </AppBar>;
 };
 
@@ -115,15 +117,4 @@ const renderMenuItems = (menuItems: MainAppBarMenuItem[], onMenuItemClick: (menu
     ));
 };
 
-type CssRules = "appBar" | "toolbar";
-
-const styles: StyleRulesCallback<CssRules> = theme => ({
-    appBar: {
-        backgroundColor: "#692498"
-    },
-    toolbar: {
-        minHeight: '48px'
-    }
-});
-
-export default withStyles(styles)(MainAppBar);
+export default MainAppBar;
index b8baeadc630988f70a8c6234eefb9df2a5ca4cb0..8cc5fc22700571a207395746390d8e778ad4e1f8 100644 (file)
@@ -3,7 +3,7 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { StyleRulesCallback, Theme, WithStyles, withStyles } from '@material-ui/core/styles';
+import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
 import Drawer from '@material-ui/core/Drawer';
 import { connect, DispatchProp } from "react-redux";
 import { Route, Switch, RouteComponentProps, withRouter } from "react-router";
@@ -28,13 +28,15 @@ import { ItemMode, setProjectItem } from "../../store/navigation/navigation-acti
 import projectActions from "../../store/project/project-action";
 import ProjectPanel from "../project-panel/project-panel";
 import { sidePanelData } from '../../store/side-panel/side-panel-reducer';
+import DetailsPanel from '../../views-components/details-panel/details-panel';
+import { ArvadosTheme } from '../../common/custom-theme';
 
 const drawerWidth = 240;
-const appBarHeight = 102;
+const appBarHeight = 100;
 
 type CssRules = 'root' | 'appBar' | 'drawerPaper' | 'content' | 'contentWrapper' | 'toolbar';
 
-const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     root: {
         flexGrow: 1,
         zIndex: 1,
@@ -46,7 +48,6 @@ const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
     },
     appBar: {
         zIndex: theme.zIndex.drawer + 1,
-        backgroundColor: '#692498',
         position: "absolute",
         width: "100%"
     },
@@ -64,7 +65,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
         paddingTop: appBarHeight
     },
     content: {
-        padding: theme.spacing.unit * 3,
+        padding: `${theme.spacing.unit}px ${theme.spacing.unit * 3}px`,
         overflowY: "auto",
         flexGrow: 1
     },
@@ -99,6 +100,7 @@ interface WorkbenchState {
         helpMenu: NavMenuItem[],
         anonymousMenu: NavMenuItem[]
     };
+    isDetailsPanelOpened: boolean;
 }
 
 class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
@@ -129,7 +131,8 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
                     action: () => this.props.dispatch(authActions.LOGIN())
                 }
             ]
-        }
+        },
+        isDetailsPanelOpened: false
     };
 
     mainAppBarActions: MainAppBarActionProps = {
@@ -140,7 +143,10 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
             this.setState({ searchText });
             this.props.dispatch(push(`/search?q=${searchText}`));
         },
-        onMenuItemClick: (menuItem: NavMenuItem) => menuItem.action()
+        onMenuItemClick: (menuItem: NavMenuItem) => menuItem.action(),
+        onDetailsPanelToggle: () => {
+            this.setState(prev => ({ isDetailsPanelOpened: !prev.isDetailsPanelOpened }));
+        }
     };
 
     toggleSidePanelOpen = (itemId: string) => {
@@ -196,6 +202,9 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
                             <Route path="/projects/:id" render={this.renderProjectPanel} />
                         </Switch>
                     </div>
+                    <DetailsPanel 
+                        isOpened={this.state.isDetailsPanelOpened} 
+                        onCloseDrawer={this.mainAppBarActions.onDetailsPanelToggle} />
                 </main>
             </div>
         );