Extend details panel with files
[arvados.git] / 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 * as React from "react";
6 import { Toolbar, IconButton, Tooltip, Grid } from "@material-ui/core";
7 import { DetailsIcon } from "~/components/icon/icon";
8 import { Breadcrumbs } from "~/views-components/breadcrumbs/breadcrumbs";
9 import { connect } from 'react-redux';
10 import { RootState } from '~/store/store';
11 import * as Routes from '~/routes/routes';
12 import { toggleDetailsPanel } from '~/store/details-panel/details-panel-action';
13
14 interface MainContentBarProps {
15     onDetailsPanelToggle: () => void;
16     buttonVisible: boolean;
17 }
18
19 const isButtonVisible = ({ router }: RootState) => {
20     const pathname = router.location ? router.location.pathname : '';
21     return !Routes.matchWorkflowRoute(pathname) && !Routes.matchUserVirtualMachineRoute(pathname) &&
22         !Routes.matchAdminVirtualMachineRoute(pathname) && !Routes.matchRepositoriesRoute(pathname) &&
23         !Routes.matchSshKeysAdminRoute(pathname) && !Routes.matchSshKeysUserRoute(pathname) &&
24         !Routes.matchSiteManagerRoute(pathname) &&
25         !Routes.matchKeepServicesRoute(pathname) && !Routes.matchComputeNodesRoute(pathname) &&
26         !Routes.matchApiClientAuthorizationsRoute(pathname) && !Routes.matchUsersRoute(pathname) &&
27         !Routes.matchMyAccountRoute(pathname) && !Routes.matchLinksRoute(pathname);
28 };
29
30 export const MainContentBar = connect((state: RootState) => ({
31     buttonVisible: isButtonVisible(state)
32 }), {
33         onDetailsPanelToggle: toggleDetailsPanel
34     })((props: MainContentBarProps) =>
35         <Toolbar>
36             <Grid container>
37                 <Grid container item xs alignItems="center">
38                     <Breadcrumbs />
39                 </Grid>
40                 <Grid item>
41                     {props.buttonVisible && <Tooltip title="Additional Info">
42                         <IconButton color="inherit" onClick={props.onDetailsPanelToggle}>
43                             <DetailsIcon />
44                         </IconButton>
45                     </Tooltip>}
46                 </Grid>
47             </Grid>
48         </Toolbar>);