mirror of
https://github.com/ansible/awx.git
synced 2026-03-02 17:28:51 -03:30
Refactor breadcrumbs, tabs, routing.
* Cleanup previous params logic from Notificaitons list * Add shared breadcrumbs and tabs components * Structure Organization screens to render only cardBody content * Add styles * Fetch organization when location changes
This commit is contained in:
70
src/components/Breadcrumbs/Breadcrumbs.jsx
Normal file
70
src/components/Breadcrumbs/Breadcrumbs.jsx
Normal file
@@ -0,0 +1,70 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import {
|
||||
PageSection,
|
||||
PageSectionVariants,
|
||||
Breadcrumb,
|
||||
BreadcrumbItem,
|
||||
BreadcrumbHeading
|
||||
} from '@patternfly/react-core';
|
||||
import {
|
||||
Link,
|
||||
Route,
|
||||
withRouter
|
||||
} from 'react-router-dom';
|
||||
import './breadcrumbs.scss';
|
||||
|
||||
const Breadcrumbs = ({ breadcrumbConfig }) => {
|
||||
const { light } = PageSectionVariants;
|
||||
|
||||
return (
|
||||
<PageSection
|
||||
variant={light}
|
||||
className="pf-m-condensed"
|
||||
>
|
||||
<Breadcrumb>
|
||||
<Route
|
||||
render={(props) => <Crumb breadcrumbConfig={breadcrumbConfig} {...props} />}
|
||||
/>
|
||||
</Breadcrumb>
|
||||
</PageSection>
|
||||
);
|
||||
};
|
||||
|
||||
const Crumb = ({ breadcrumbConfig, match }) => {
|
||||
const crumb = breadcrumbConfig[match.url];
|
||||
|
||||
let crumbElement = (
|
||||
<BreadcrumbItem key={match.url}>
|
||||
<Link to={match.url}>
|
||||
{crumb}
|
||||
</Link>
|
||||
</BreadcrumbItem>
|
||||
);
|
||||
|
||||
if (match.isExact) {
|
||||
crumbElement = (
|
||||
<BreadcrumbHeading
|
||||
key="breadcrumb-heading"
|
||||
className="heading"
|
||||
>
|
||||
{crumb}
|
||||
</BreadcrumbHeading>
|
||||
);
|
||||
}
|
||||
|
||||
if (!crumb) {
|
||||
crumbElement = null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
{crumbElement}
|
||||
<Route
|
||||
path={`${match.url}/:path`}
|
||||
render={(props) => <Crumb breadcrumbConfig={breadcrumbConfig} {...props} />}
|
||||
/>
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
export default withRouter(Breadcrumbs);
|
||||
15
src/components/Breadcrumbs/breadcrumbs.scss
Normal file
15
src/components/Breadcrumbs/breadcrumbs.scss
Normal file
@@ -0,0 +1,15 @@
|
||||
.pf-c-breadcrumb__item {
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.pf-c-breadcrumb__item.heading {
|
||||
--pf-c-breadcrumb__heading--FontSize: 20px;
|
||||
line-height: 24px;
|
||||
flex: 100%;
|
||||
}
|
||||
|
||||
.pf-c-breadcrumb__item:nth-last-child(2) {
|
||||
.pf-c-breadcrumb__item-divider {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user