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) => ({
27 backgroundColor: theme.customs.colors.grey300,
29 backgroundColor: `${theme.customs.colors.grey300}99`,
32 backgroundColor: theme.customs.colors.grey400,
34 '&.parentItem:hover': {
35 backgroundColor: `${theme.customs.colors.grey400}99`,
39 textTransform: "none",
55 export interface BreadcrumbsProps {
57 resources: ResourcesState;
58 onClick: (breadcrumb: Breadcrumb) => void;
59 onContextMenu: (event: React.MouseEvent<HTMLElement>, breadcrumb: Breadcrumb) => void;
62 export const Breadcrumbs = withStyles(styles)(
63 ({ classes, onClick, onContextMenu, items, resources }: BreadcrumbsProps & WithStyles<CssRules>) =>
64 <Grid container data-cy='breadcrumbs' alignItems="center" wrap="nowrap">
66 items.map((item, index) => {
67 const isLastItem = index === items.length - 1;
68 const isFirstItem = index === 0;
69 const Icon = item.icon || (() => (null));
71 <React.Fragment key={index}>
72 {isFirstItem ? null : <IllegalNamingWarning name={item.label} />}
73 <Tooltip title={item.label}>
81 className={classNames(
82 isLastItem ? null : 'parentItem',
85 onClick={() => onClick(item)}
86 onContextMenu={event => onContextMenu(event, item)}>
87 <Icon className={classes.icon} />
91 className={classes.label}>
95 (resources[item.uuid] as any)?.frozenByUuid ? <FreezeIcon className={classes.frozenIcon} /> : null
99 {!isLastItem && <ChevronRightIcon color="inherit" className={'parentItem'} />}