1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from "react";
7 import { Toolbar, StyleRulesCallback, IconButton, Tooltip, Grid, WithStyles, withStyles } from "@material-ui/core";
8 import { DetailsIcon } from "components/icon/icon";
9 import { Breadcrumbs } from "views-components/breadcrumbs/breadcrumbs";
10 import { connect } from 'react-redux';
11 import { RootState } from 'store/store';
12 import * as Routes from 'routes/routes';
13 import { toggleDetailsPanel } from 'store/details-panel/details-panel-action';
14 import RefreshButton from "components/refresh-button/refresh-button";
15 import { loadSidePanelTreeProjects } from "store/side-panel-tree/side-panel-tree-actions";
16 import { Dispatch } from "redux";
18 type CssRules = "infoTooltip";
20 const styles: StyleRulesCallback<CssRules> = theme => ({
27 interface MainContentBarProps {
28 onRefreshPage: () => void;
29 onDetailsPanelToggle: () => void;
30 buttonVisible: boolean;
33 const isButtonVisible = ({ router }: RootState) => {
34 const pathname = router.location ? router.location.pathname : '';
35 return Routes.matchCollectionsContentAddressRoute(pathname) ||
36 Routes.matchPublicFavoritesRoute(pathname) ||
37 Routes.matchGroupDetailsRoute(pathname) ||
38 Routes.matchGroupsRoute(pathname) ||
39 Routes.matchUsersRoute(pathname) ||
40 Routes.matchSearchResultsRoute(pathname) ||
41 Routes.matchSharedWithMeRoute(pathname) ||
42 Routes.matchProcessRoute(pathname) ||
43 Routes.matchCollectionRoute(pathname) ||
44 Routes.matchProjectRoute(pathname) ||
45 Routes.matchAllProcessesRoute(pathname) ||
46 Routes.matchTrashRoute(pathname) ||
47 Routes.matchFavoritesRoute(pathname);
50 const mapStateToProps = (state: RootState) => ({
51 buttonVisible: isButtonVisible(state),
52 projectUuid: state.detailsPanel.resourceUuid,
55 const mapDispatchToProps = () => (dispatch: Dispatch) => ({
56 onDetailsPanelToggle: () => dispatch<any>(toggleDetailsPanel()),
57 onRefreshButtonClick: (id) => {
58 dispatch<any>(loadSidePanelTreeProjects(id));
62 export const MainContentBar = connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(
63 (props: MainContentBarProps & WithStyles<CssRules> & any) =>
64 <Toolbar><Grid container>
65 <Grid container item xs alignItems="center">
69 <RefreshButton onClick={() => {
70 props.onRefreshButtonClick(props.projectUuid);
74 {props.buttonVisible && <Tooltip title="Additional Info">
75 <IconButton data-cy="additional-info-icon"
77 className={props.classes.infoTooltip}
78 onClick={props.onDetailsPanelToggle}>