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