X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/488c558be1f9b4a9aa48a06d43b97db0d8ff9101..36c33008be2896228d3040c756d80e8878907655:/src/components/breadcrumbs/breadcrumbs.tsx diff --git a/src/components/breadcrumbs/breadcrumbs.tsx b/src/components/breadcrumbs/breadcrumbs.tsx index 7fa85ca0c7..3d668856ec 100644 --- a/src/components/breadcrumbs/breadcrumbs.tsx +++ b/src/components/breadcrumbs/breadcrumbs.tsx @@ -2,73 +2,79 @@ // // SPDX-License-Identifier: AGPL-3.0 -import * as React from 'react'; -import { Button, Grid, StyleRulesCallback, WithStyles } from '@material-ui/core'; +import React from 'react'; +import { Button, Grid, StyleRulesCallback, WithStyles, Typography, Tooltip } from '@material-ui/core'; import ChevronRightIcon from '@material-ui/icons/ChevronRight'; import { withStyles } from '@material-ui/core'; +import { IllegalNamingWarning } from '../warning/warning'; +import { IconType } from 'components/icon/icon'; +import grey from '@material-ui/core/colors/grey'; export interface Breadcrumb { label: string; + icon?: IconType; } -interface BreadcrumbsProps { +type CssRules = "item" | "currentItem" | "label" | "icon"; + +const styles: StyleRulesCallback = theme => ({ + item: { + opacity: 0.6 + }, + currentItem: { + opacity: 1 + }, + label: { + textTransform: "none" + }, + icon: { + fontSize: 20, + color: grey["600"] + }, +}); + +export interface BreadcrumbsProps { items: Breadcrumb[]; - onClick: (breadcrumb: Breadcrumb) => any; + onClick: (breadcrumb: Breadcrumb) => void; + onContextMenu: (event: React.MouseEvent, breadcrumb: Breadcrumb) => void; } -class Breadcrumbs extends React.Component> { - - render() { - const { classes, onClick } = this.props; - return - { - this.getInactiveItems().map((item, index) => ( - +export const Breadcrumbs = withStyles(styles)( + ({ classes, onClick, onContextMenu, items }: BreadcrumbsProps & WithStyles) => + + { + items.map((item, index) => { + const isLastItem = index === items.length - 1; + const isFirstItem = index === 0; + const Icon = item.icon || (() => (null)); + return ( + + {isFirstItem ? null : } + - - - )) - } - { - this.getActiveItem().map((item, index) => ( - - )) - } - ; - } - - getInactiveItems = () => { - return this.props.items.slice(0, -1); - } - - getActiveItem = () => { - return this.props.items.slice(-1); + + {!isLastItem && } + + ); + }) } - -} - -type CssRules = 'inactiveItem'; - -const styles: StyleRulesCallback = theme => { - const { unit } = theme.spacing; - return { - inactiveItem: { - opacity: 0.6 - } - }; -}; - -export default withStyles(styles)(Breadcrumbs); - + +);