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 = 'mainBar' | 'infoTooltip';
20 const styles: StyleRulesCallback<CssRules> = theme => ({
30 interface MainContentBarProps {
31 onRefreshPage: () => void;
32 onDetailsPanelToggle: () => void;
33 buttonVisible: boolean;
36 const isButtonVisible = ({ router }: RootState) => {
37 const pathname = router.location ? router.location.pathname : '';
38 return Routes.matchCollectionsContentAddressRoute(pathname) ||
39 Routes.matchPublicFavoritesRoute(pathname) ||
40 Routes.matchGroupDetailsRoute(pathname) ||
41 Routes.matchGroupsRoute(pathname) ||
42 Routes.matchUsersRoute(pathname) ||
43 Routes.matchSearchResultsRoute(pathname) ||
44 Routes.matchSharedWithMeRoute(pathname) ||
45 Routes.matchProcessRoute(pathname) ||
46 Routes.matchCollectionRoute(pathname) ||
47 Routes.matchProjectRoute(pathname) ||
48 Routes.matchAllProcessesRoute(pathname) ||
49 Routes.matchTrashRoute(pathname) ||
50 Routes.matchFavoritesRoute(pathname);
53 const mapStateToProps = (state: RootState) => ({
54 buttonVisible: isButtonVisible(state),
55 projectUuid: state.detailsPanel.resourceUuid,
58 const mapDispatchToProps = () => (dispatch: Dispatch) => ({
59 onDetailsPanelToggle: () => dispatch<any>(toggleDetailsPanel()),
60 onRefreshButtonClick: (id) => {
61 dispatch<any>(loadSidePanelTreeProjects(id));
65 export const MainContentBar = connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(
66 (props: MainContentBarProps & WithStyles<CssRules> & any) =>
67 <Toolbar><Grid container className={props.classes.mainBar}>
68 <Grid container item xs alignItems="center">
72 <RefreshButton onClick={() => {
73 props.onRefreshButtonClick(props.projectUuid);
77 {props.buttonVisible && <Tooltip title="Additional Info">
78 <IconButton data-cy="additional-info-icon"
80 className={props.classes.infoTooltip}
81 onClick={props.onDetailsPanelToggle}>