21224: fixed first select-selectall bug Arvados-DCO-1.1-Signed-off-by: Lisa Knox...
[arvados.git] / services / workbench2 / src / views-components / main-content-bar / main-content-bar.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import React from "react";
6
7 import { Toolbar, StyleRulesCallback, Grid, WithStyles, withStyles } from "@material-ui/core";
8 import { Breadcrumbs } from "views-components/breadcrumbs/breadcrumbs";
9 import { connect } from 'react-redux';
10 import { RootState } from 'store/store';
11 import { toggleDetailsPanel } from 'store/details-panel/details-panel-action';
12 import RefreshButton from "components/refresh-button/refresh-button";
13 import { loadSidePanelTreeProjects } from "store/side-panel-tree/side-panel-tree-actions";
14 import { Dispatch } from "redux";
15
16 type CssRules = 'mainBar' | 'breadcrumbContainer' | 'infoTooltip';
17
18 const styles: StyleRulesCallback<CssRules> = theme => ({
19     mainBar: {
20         flexWrap: 'nowrap',
21     },
22     breadcrumbContainer: {
23         overflow: 'hidden',
24     },
25     infoTooltip: {
26         marginTop: '-10px',
27         marginLeft: '10px',
28     }
29 });
30
31 interface MainContentBarProps {
32     onRefreshPage: () => void;
33     onDetailsPanelToggle: () => void;
34 }
35
36 const mapStateToProps = (state: RootState) => ({
37     projectUuid: state.detailsPanel.resourceUuid,
38 });
39
40 const mapDispatchToProps = () => (dispatch: Dispatch) => ({
41     onDetailsPanelToggle: () => dispatch<any>(toggleDetailsPanel()),
42     onRefreshButtonClick: (id) => {
43         dispatch<any>(loadSidePanelTreeProjects(id));
44     }
45 });
46
47 export const MainContentBar = connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(
48     (props: MainContentBarProps & WithStyles<CssRules> & any) =>
49         <Toolbar><Grid container className={props.classes.mainBar}>
50             <Grid container item xs alignItems="center" className={props.classes.breadcrumbContainer}>
51                 <Breadcrumbs />
52             </Grid>
53             <Grid item>
54                 <RefreshButton onClick={() => {
55                     props.onRefreshButtonClick(props.projectUuid);
56                 }} />
57             </Grid>
58         </Grid></Toolbar>
59 ));