1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { CustomStyleRulesCallback } from 'common/custom-theme';
7 import { Button, Grid, Typography, Tooltip } from '@mui/material';
8 import { WithStyles } from '@mui/styles';
9 import ChevronRightIcon from '@mui/icons-material/ChevronRight';
10 import withStyles from '@mui/styles/withStyles';
11 import { IllegalNamingWarning } from '../warning/warning';
12 import { IconType, FreezeIcon } from 'components/icon/icon';
13 import { getResource, ResourcesState } from 'store/resources/resources';
14 import classNames from 'classnames';
15 import { ArvadosTheme } from 'common/custom-theme';
16 import { GroupClass } from "models/group";
17 import { navigateTo, navigateToGroupDetails } from 'store/navigation/navigation-action';
18 import { grey } from '@mui/material/colors';
19 export interface Breadcrumb {
25 type CssRules = "item" | "chevron" | "label" | "buttonLabel" | "icon" | "frozenIcon";
27 const styles: CustomStyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
32 color: theme.customs.colors.grey700,
34 color: `${theme.palette.primary.main}`,
41 textTransform: "none",
48 justifyContent: 'flex-start',
50 alignItems: 'inherit',
64 export interface BreadcrumbsProps {
66 resources: ResourcesState;
67 onClick: (navFunc: (uuid: string) => void, breadcrumb: Breadcrumb) => void;
68 onContextMenu: (event: React.MouseEvent<HTMLElement>, breadcrumb: Breadcrumb) => void;
71 export const Breadcrumbs = withStyles(styles)(
72 ({ classes, onClick, onContextMenu, items, resources }: BreadcrumbsProps & WithStyles<CssRules>) =>
73 <Grid container data-cy='breadcrumbs' alignItems="center" wrap="nowrap">
75 items.map((item, index) => {
76 const isLastItem = index === items.length - 1;
77 const isFirstItem = index === 0;
78 const Icon = item.icon || (() => (null));
79 const resource = getResource(item.uuid)(resources) as any;
80 const navFunc = resource && 'groupClass' in resource && resource.groupClass === GroupClass.ROLE ? navigateToGroupDetails : navigateTo;
83 <React.Fragment key={index}>
84 {isFirstItem ? null : <IllegalNamingWarning name={item.label} />}
85 <Tooltip title={item.label} disableFocusListener>
93 className={classNames(
94 isLastItem ? null : 'parentItem',
98 onClick={() => onClick(navFunc, item)}
99 onContextMenu={event => onContextMenu(event, item)}>
100 <span className={classes.buttonLabel}>
101 <Icon className={classes.icon} />
105 className={classes.label}>
109 (resources[item.uuid] as any)?.frozenByUuid ? <FreezeIcon className={classes.frozenIcon} /> : null
114 {!isLastItem && <ChevronRightIcon color="inherit" className={classNames('parentItem', classes.chevron)} />}