1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as 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';
11 export interface Breadcrumb {
15 type CssRules = "item" | "currentItem" | "label";
17 const styles: StyleRulesCallback<CssRules> = theme => ({
29 export interface BreadcrumbsProps {
31 onClick: (breadcrumb: Breadcrumb) => void;
32 onContextMenu: (event: React.MouseEvent<HTMLElement>, breadcrumb: Breadcrumb) => void;
35 export const Breadcrumbs = withStyles(styles)(
36 ({ classes, onClick, onContextMenu, items }: BreadcrumbsProps & WithStyles<CssRules>) =>
37 <Grid container data-cy='breadcrumbs' alignItems="center" wrap="nowrap">
39 items.map((item, index) => {
40 const isLastItem = index === items.length - 1;
41 const isFirstItem = index === 0;
43 <React.Fragment key={index}>
44 {isFirstItem ? null : <IllegalNamingWarning name={item.label} />}
45 <Tooltip title={item.label}>
54 className={isLastItem ? classes.currentItem : classes.item}
55 onClick={() => onClick(item)}
56 onContextMenu={event => onContextMenu(event, item)}>
60 className={classes.label}>
65 {!isLastItem && <ChevronRightIcon color="inherit" className={classes.item} />}