1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { connect } from "react-redux";
6 import { Breadcrumb, Breadcrumbs as BreadcrumbsComponent, BreadcrumbsProps } from 'components/breadcrumbs/breadcrumbs';
7 import { RootState } from 'store/store';
8 import { Dispatch } from 'redux';
9 import { getProperty } from '../../store/properties/properties';
10 import { BREADCRUMBS } from '../../store/breadcrumbs/breadcrumbs-actions';
11 import { openSidePanelContextMenu } from 'store/context-menu/context-menu-actions';
13 type BreadcrumbsDataProps = Pick<BreadcrumbsProps, 'items' | 'resources'>;
14 type BreadcrumbsActionProps = Pick<BreadcrumbsProps, 'onClick' | 'onContextMenu'>;
16 const mapStateToProps = () => ({ properties, resources }: RootState): BreadcrumbsDataProps => ({
17 items: (getProperty<Breadcrumb[]>(BREADCRUMBS)(properties) || []),
21 const mapDispatchToProps = (dispatch: Dispatch): BreadcrumbsActionProps => ({
22 onClick: (navFunc, { uuid }: Breadcrumb) => {
23 dispatch<any>(navFunc(uuid));
25 onContextMenu: (event, breadcrumb: Breadcrumb) => {
26 dispatch<any>(openSidePanelContextMenu(event, breadcrumb.uuid));
30 export const Breadcrumbs = connect(mapStateToProps(), mapDispatchToProps)(BreadcrumbsComponent);