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" | "chevron" | "label" | "buttonLabel" | "icon" | "frozenIcon";
24 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
29 color: theme.customs.colors.grey700,
31 color: `${theme.palette.primary.main}`,
38 textTransform: "none",
45 justifyContent: 'flex-start',
59 export interface BreadcrumbsProps {
61 resources: ResourcesState;
62 onClick: (breadcrumb: Breadcrumb) => void;
63 onContextMenu: (event: React.MouseEvent<HTMLElement>, breadcrumb: Breadcrumb) => void;
66 export const Breadcrumbs = withStyles(styles)(
67 ({ classes, onClick, onContextMenu, items, resources }: BreadcrumbsProps & WithStyles<CssRules>) =>
68 <Grid container data-cy='breadcrumbs' alignItems="center" wrap="nowrap">
70 items.map((item, index) => {
71 const isLastItem = index === items.length - 1;
72 const isFirstItem = index === 0;
73 const Icon = item.icon || (() => (null));
75 <React.Fragment key={index}>
76 {isFirstItem ? null : <IllegalNamingWarning name={item.label} />}
77 <Tooltip title={item.label}>
85 className={classNames(
86 isLastItem ? null : 'parentItem',
90 label: classes.buttonLabel
93 onClick={() => onClick(item)}
94 onContextMenu={event => onContextMenu(event, item)}>
95 <Icon className={classes.icon} />
99 className={classes.label}>
103 (resources[item.uuid] as any)?.frozenByUuid ? <FreezeIcon className={classes.frozenIcon} /> : null
107 {!isLastItem && <ChevronRightIcon color="inherit" className={classNames('parentItem', classes.chevron)} />}