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 color: theme.customs.colors.grey700,
30 color: `${theme.palette.primary.main}`,
34 textTransform: "none",
51 export interface BreadcrumbsProps {
53 resources: ResourcesState;
54 onClick: (breadcrumb: Breadcrumb) => void;
55 onContextMenu: (event: React.MouseEvent<HTMLElement>, breadcrumb: Breadcrumb) => void;
58 export const Breadcrumbs = withStyles(styles)(
59 ({ classes, onClick, onContextMenu, items, resources }: BreadcrumbsProps & WithStyles<CssRules>) =>
60 <Grid container data-cy='breadcrumbs' alignItems="center">
62 items.map((item, index) => {
63 const isLastItem = index === items.length - 1;
64 const isFirstItem = index === 0;
65 const Icon = item.icon || (() => (null));
67 <React.Fragment key={index}>
68 {isFirstItem ? null : <IllegalNamingWarning name={item.label} />}
69 <Tooltip title={item.label}>
77 className={classNames(
78 isLastItem ? null : 'parentItem',
82 onClick={() => onClick(item)}
83 onContextMenu={event => onContextMenu(event, item)}>
84 <Icon className={classes.icon} />
88 className={classes.label}>
92 (resources[item.uuid] as any)?.frozenByUuid ? <FreezeIcon className={classes.frozenIcon} /> : null
96 {!isLastItem && <ChevronRightIcon color="inherit" className={'parentItem'} />}