mirror of
https://github.com/ansible/awx.git
synced 2026-02-12 15:14:45 -03:30
Merge pull request #162 from AlexSCorey/128-UsePFTabs
Add PF's Tabs to Orgs Details page
This commit is contained in:
@@ -283,6 +283,14 @@
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.OrgsTab-closeButton {
|
||||
color: black;
|
||||
float: right;
|
||||
position: relative;
|
||||
top: -25px;
|
||||
margin: 0 10px;
|
||||
right: 10px;
|
||||
}
|
||||
.awx-c-form-action-group {
|
||||
float: right;
|
||||
display: block;
|
||||
|
||||
56
src/components/Tabs/RoutedTabs.jsx
Normal file
56
src/components/Tabs/RoutedTabs.jsx
Normal file
@@ -0,0 +1,56 @@
|
||||
import React from 'react';
|
||||
import { shape, string, number, arrayOf } from 'prop-types';
|
||||
import { Tab, Tabs } from '@patternfly/react-core';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
|
||||
function RoutedTabs (props) {
|
||||
const { history, tabsArray } = props;
|
||||
|
||||
const getActiveTabId = () => {
|
||||
const match = tabsArray.find(tab => tab.link === history.location.pathname);
|
||||
if (match) {
|
||||
return match.id;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
function handleTabSelect (event, eventKey) {
|
||||
const match = tabsArray.find(tab => tab.id === eventKey);
|
||||
if (match) {
|
||||
history.push(match.link);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Tabs
|
||||
activeKey={getActiveTabId()}
|
||||
onSelect={handleTabSelect}
|
||||
>
|
||||
{tabsArray.map(tab => (
|
||||
<Tab
|
||||
className={`${tab.name}`}
|
||||
aria-label={`${tab.name}`}
|
||||
eventKey={tab.id}
|
||||
key={tab.id}
|
||||
link={tab.link}
|
||||
title={tab.name}
|
||||
/>
|
||||
))}
|
||||
</Tabs>
|
||||
);
|
||||
}
|
||||
RoutedTabs.propTypes = {
|
||||
history: shape({
|
||||
location: shape({
|
||||
pathname: string.isRequired
|
||||
}).isRequired,
|
||||
}).isRequired,
|
||||
tabsArray: arrayOf(shape({
|
||||
id: number.isRequired,
|
||||
link: string.isRequired,
|
||||
name: string.isRequired,
|
||||
})).isRequired,
|
||||
};
|
||||
|
||||
export { RoutedTabs as _RoutedTabs };
|
||||
export default withRouter(RoutedTabs);
|
||||
@@ -1,33 +0,0 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import './tabs.scss';
|
||||
|
||||
const Tab = ({ children, link, replace }) => (
|
||||
<li className="pf-c-tabs__item">
|
||||
<NavLink
|
||||
to={link}
|
||||
replace={replace}
|
||||
className="pf-c-tabs__button"
|
||||
activeClassName="pf-m-current"
|
||||
>
|
||||
{children}
|
||||
</NavLink>
|
||||
</li>
|
||||
);
|
||||
|
||||
Tab.propTypes = {
|
||||
children: PropTypes.oneOfType([
|
||||
PropTypes.arrayOf(PropTypes.node),
|
||||
PropTypes.node
|
||||
]).isRequired,
|
||||
link: PropTypes.string,
|
||||
replace: PropTypes.bool,
|
||||
};
|
||||
|
||||
Tab.defaultProps = {
|
||||
link: null,
|
||||
replace: false,
|
||||
};
|
||||
|
||||
export default Tab;
|
||||
@@ -1,53 +0,0 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Button, Tooltip } from '@patternfly/react-core';
|
||||
import { TimesIcon } from '@patternfly/react-icons';
|
||||
import './tabs.scss';
|
||||
|
||||
const Tabs = ({ children, labelText, closeButton }) => (
|
||||
<div
|
||||
aria-label={labelText}
|
||||
className="pf-c-tabs"
|
||||
>
|
||||
<ul className="pf-c-tabs__list">
|
||||
{children}
|
||||
</ul>
|
||||
{closeButton
|
||||
&& (
|
||||
<Tooltip
|
||||
content={closeButton.text}
|
||||
position="top"
|
||||
>
|
||||
<Link to={closeButton.link}>
|
||||
<Button
|
||||
variant="plain"
|
||||
aria-label={closeButton.text}
|
||||
>
|
||||
<TimesIcon />
|
||||
</Button>
|
||||
</Link>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
);
|
||||
|
||||
Tabs.propTypes = {
|
||||
children: PropTypes.oneOfType([
|
||||
PropTypes.arrayOf(PropTypes.node),
|
||||
PropTypes.node
|
||||
]).isRequired,
|
||||
labelText: PropTypes.string,
|
||||
closeButton: PropTypes.shape({
|
||||
text: PropTypes.string,
|
||||
link: PropTypes.string,
|
||||
}),
|
||||
};
|
||||
|
||||
Tabs.defaultProps = {
|
||||
labelText: null,
|
||||
closeButton: null,
|
||||
};
|
||||
|
||||
export default Tabs;
|
||||
@@ -1,71 +0,0 @@
|
||||
.pf-c-card__header {
|
||||
--pf-c-card__header--PaddingBottom: 0;
|
||||
--pf-c-card__header--PaddingX: 0;
|
||||
--pf-c-card__header--PaddingRight: 0;
|
||||
--pf-c-card__header--PaddingLeft: 0;
|
||||
--pf-c-card__header--PaddingTop: 0;
|
||||
}
|
||||
|
||||
.pf-c-tabs {
|
||||
--pf-global--link--Color: #484848;
|
||||
--pf-global--link--Color--hover: #484848;
|
||||
--pf-global--link--TextDecoration--hover: none;
|
||||
|
||||
align-items: center;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
|
||||
&:before {
|
||||
border-bottom: 1px solid var(--pf-c-tabs__item--BorderColor);
|
||||
border-top: 1px solid var(--pf-c-tabs__item--BorderColor);
|
||||
bottom: 0;
|
||||
content: " ";
|
||||
left: 0;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.pf-c-tabs__button {
|
||||
--pf-c-tabs__button--PaddingLeft: 20px;
|
||||
--pf-c-tabs__button--PaddingRight: 20px;
|
||||
display: block;
|
||||
font-weight: 700;
|
||||
|
||||
&:after {
|
||||
content: '';
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.pf-c-tabs__item:first-child .pf-c-tabs__button:before {
|
||||
border-left: 0;
|
||||
}
|
||||
|
||||
.pf-c-tabs__item:not(.pf-m-current):hover
|
||||
.pf-c-tabs__button::after {
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.pf-c-tabs__item:hover
|
||||
.pf-c-tabs__button:not(.pf-m-current)::after {
|
||||
border-bottom: 3px solid var(--pf-global--Color--dark-200);
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.pf-c-tabs__button.pf-m-current {
|
||||
color: var(--pf-c-tabs__item--m-current--Color);
|
||||
}
|
||||
|
||||
.pf-c-tabs__button.pf-m-current::after {
|
||||
content: '';
|
||||
border-bottom: 3px solid var(--pf-c-tabs__item--m-current--Color);
|
||||
border-top: none;
|
||||
margin-left: 1px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,25 +5,25 @@ import {
|
||||
Switch,
|
||||
Route,
|
||||
withRouter,
|
||||
Redirect
|
||||
Redirect,
|
||||
Link
|
||||
} from 'react-router-dom';
|
||||
import {
|
||||
Card,
|
||||
CardHeader,
|
||||
PageSection
|
||||
PageSection,
|
||||
} from '@patternfly/react-core';
|
||||
|
||||
import {
|
||||
TimesIcon
|
||||
} from '@patternfly/react-icons';
|
||||
import { withNetwork } from '../../../../contexts/Network';
|
||||
|
||||
import Tabs from '../../../../components/Tabs/Tabs';
|
||||
import Tab from '../../../../components/Tabs/Tab';
|
||||
import NotifyAndRedirect from '../../../../components/NotifyAndRedirect';
|
||||
|
||||
import OrganizationAccess from './OrganizationAccess';
|
||||
import OrganizationDetail from './OrganizationDetail';
|
||||
import OrganizationEdit from './OrganizationEdit';
|
||||
import OrganizationNotifications from './OrganizationNotifications';
|
||||
import OrganizationTeams from './OrganizationTeams';
|
||||
import RoutedTabs from '../../../../components/Tabs/RoutedTabs';
|
||||
|
||||
class Organization extends Component {
|
||||
constructor (props) {
|
||||
@@ -79,35 +79,45 @@ class Organization extends Component {
|
||||
loading
|
||||
} = this.state;
|
||||
|
||||
const tabElements = [
|
||||
{ name: i18nMark('Details'), link: `${match.url}/details` },
|
||||
{ name: i18nMark('Access'), link: `${match.url}/access` },
|
||||
{ name: i18nMark('Teams'), link: `${match.url}/teams` },
|
||||
{ name: i18nMark('Notifications'), link: `${match.url}/notifications` },
|
||||
];
|
||||
const tabsPaddingOverride = {
|
||||
padding: '0'
|
||||
};
|
||||
|
||||
let cardHeader = (
|
||||
<CardHeader>
|
||||
<I18n>
|
||||
{({ i18n }) => (
|
||||
<Tabs
|
||||
labelText={i18n._(t`Organization detail tabs`)}
|
||||
closeButton={{ link: '/organizations', text: i18nMark('Close') }}
|
||||
>
|
||||
{tabElements.map(tabElement => (
|
||||
<Tab
|
||||
key={tabElement.name}
|
||||
link={tabElement.link}
|
||||
replace
|
||||
>
|
||||
{tabElement.name}
|
||||
</Tab>
|
||||
))}
|
||||
</Tabs>
|
||||
)}
|
||||
</I18n>
|
||||
</CardHeader>
|
||||
);
|
||||
loading ? ''
|
||||
: (
|
||||
<CardHeader
|
||||
style={tabsPaddingOverride}
|
||||
>
|
||||
<I18n>
|
||||
{({ i18n }) => (
|
||||
<React.Fragment>
|
||||
<RoutedTabs
|
||||
match={match}
|
||||
history={history}
|
||||
labeltext={i18n._(t`Organization detail tabs`)}
|
||||
tabsArray={[
|
||||
{ name: i18nMark('Details'), link: `${match.url}/details`, id: 0 },
|
||||
{ name: i18nMark('Access'), link: `${match.url}/access`, id: 1 },
|
||||
{ name: i18nMark('Teams'), link: `${match.url}/teams`, id: 2 },
|
||||
{ name: i18nMark('Notifications'), link: `${match.url}/notifications`, id: 3 },
|
||||
]}
|
||||
/>
|
||||
<Link
|
||||
aria-label="Close"
|
||||
title="Close"
|
||||
to="/organizations"
|
||||
>
|
||||
<TimesIcon className="OrgsTab-closeButton" />
|
||||
</Link>
|
||||
</React.Fragment>
|
||||
)}
|
||||
</I18n>
|
||||
</CardHeader>
|
||||
));
|
||||
if (!match) {
|
||||
cardHeader = null;
|
||||
}
|
||||
|
||||
if (location.pathname.endsWith('edit')) {
|
||||
cardHeader = null;
|
||||
@@ -185,5 +195,5 @@ class Organization extends Component {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withNetwork(withRouter(Organization));
|
||||
export { Organization as _Organization };
|
||||
|
||||
Reference in New Issue
Block a user