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