mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 02:50:02 -03:30
Updates routes in breadcrumbs so they no longer use the render prop
This commit is contained in:
parent
193ec21149
commit
7feac5ecd6
@ -7,7 +7,8 @@ import {
|
||||
BreadcrumbItem,
|
||||
BreadcrumbHeading,
|
||||
} from '@patternfly/react-core';
|
||||
import { Link, Route, withRouter } from 'react-router-dom';
|
||||
import { Link, Route, withRouter, useRouteMatch } from 'react-router-dom';
|
||||
|
||||
import styled from 'styled-components';
|
||||
|
||||
const PageSection = styled(PFPageSection)`
|
||||
@ -15,18 +16,15 @@ const PageSection = styled(PFPageSection)`
|
||||
padding-bottom: 10px;
|
||||
`;
|
||||
|
||||
const Breadcrumbs = ({ breadcrumbConfig }) => {
|
||||
const Breadcrumbs = ({ breadcrumbConfig, match }) => {
|
||||
const { light } = PageSectionVariants;
|
||||
|
||||
return (
|
||||
<PageSection variant={light}>
|
||||
<Breadcrumb>
|
||||
<Route
|
||||
path="/:path"
|
||||
render={props => (
|
||||
<Crumb breadcrumbConfig={breadcrumbConfig} {...props} />
|
||||
)}
|
||||
/>
|
||||
<Route path="/:path">
|
||||
<Crumb breadcrumbConfig={breadcrumbConfig} match={match} />
|
||||
</Route>
|
||||
</Breadcrumb>
|
||||
</PageSection>
|
||||
);
|
||||
@ -51,15 +49,17 @@ const Crumb = ({ breadcrumbConfig, match }) => {
|
||||
crumbElement = null;
|
||||
}
|
||||
|
||||
function NextCrumb() {
|
||||
const routeMatch = useRouteMatch();
|
||||
return <Crumb breadcrumbConfig={breadcrumbConfig} match={routeMatch} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
{crumbElement}
|
||||
<Route
|
||||
path={`${match.url}/:path`}
|
||||
render={props => (
|
||||
<Crumb breadcrumbConfig={breadcrumbConfig} {...props} />
|
||||
)}
|
||||
/>
|
||||
<Route path={`${match.url}/:path`}>
|
||||
<NextCrumb />
|
||||
</Route>
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user