1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { Button, Grid, StyleRulesCallback, WithStyles, Typography, Tooltip } from '@material-ui/core';
7 import ChevronRightIcon from '@material-ui/icons/ChevronRight';
8 import { withStyles } from '@material-ui/core';
9 import { IllegalNamingWarning } from '../warning/warning';
10 import { IconType, FreezeIcon } from 'components/icon/icon';
11 import grey from '@material-ui/core/colors/grey';
12 import { ResourcesState } from 'store/resources/resources';
13 import classNames from 'classnames';
14 import { ArvadosTheme } from 'common/custom-theme';
16 export interface Breadcrumb {
22 type CssRules = "item" | "label" | "icon" | "frozenIcon";
24 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
28 backgroundColor: theme.customs.colors.grey300,
30 backgroundColor: `${theme.customs.colors.grey300}99`,
33 backgroundColor: theme.customs.colors.grey400,
35 '&.parentItem:hover': {
36 backgroundColor: `${theme.customs.colors.grey400}99`,
40 textTransform: "none",
57 export interface BreadcrumbsProps {
59 resources: ResourcesState;
60 onClick: (breadcrumb: Breadcrumb) => void;
61 onContextMenu: (event: React.MouseEvent<HTMLElement>, breadcrumb: Breadcrumb) => void;
64 export const Breadcrumbs = withStyles(styles)(
65 ({ classes, onClick, onContextMenu, items, resources }: BreadcrumbsProps & WithStyles<CssRules>) =>
66 <Grid container data-cy='breadcrumbs' alignItems="center" wrap="nowrap">
68 items.map((item, index) => {
69 const isLastItem = index === items.length - 1;
70 const isFirstItem = index === 0;
71 const Icon = item.icon || (() => (null));
73 <React.Fragment key={index}>
74 {isFirstItem ? null : <IllegalNamingWarning name={item.label} />}
75 <Tooltip title={item.label}>
83 className={classNames(
84 isLastItem ? null : 'parentItem',
87 onClick={() => onClick(item)}
88 onContextMenu={event => onContextMenu(event, item)}>
89 <Icon className={classes.icon} />
93 className={classes.label}>
97 (resources[item.uuid] as any)?.frozenByUuid ? <FreezeIcon className={classes.frozenIcon} /> : null
101 {!isLastItem && <ChevronRightIcon color="inherit" className={'parentItem'} />}