mirror of
https://github.com/ansible/awx.git
synced 2026-03-05 10:41:05 -03:30
add tooltip proptype
This commit is contained in:
23
__tests__/components/CardCloseButton.test.jsx
Normal file
23
__tests__/components/CardCloseButton.test.jsx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { mountWithContexts } from '../enzymeHelpers';
|
||||||
|
import CardCloseButton from '../../src/components/CardCloseButton';
|
||||||
|
|
||||||
|
describe('<CardCloseButton>', () => {
|
||||||
|
test('should render close button', () => {
|
||||||
|
const wrapper = mountWithContexts(<CardCloseButton />);
|
||||||
|
const button = wrapper.find('Button');
|
||||||
|
expect(button).toHaveLength(1);
|
||||||
|
expect(button.prop('variant')).toBe('plain');
|
||||||
|
expect(button.prop('className')).toBe('pf-c-card__close');
|
||||||
|
expect(wrapper.find('Link')).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render close link when `linkTo` prop provided', () => {
|
||||||
|
const wrapper = mountWithContexts(<CardCloseButton linkTo="/foo" />);
|
||||||
|
expect(wrapper.find('Button')).toHaveLength(0);
|
||||||
|
const link = wrapper.find('Link');
|
||||||
|
expect(link).toHaveLength(1);
|
||||||
|
expect(link.prop('to')).toEqual('/foo');
|
||||||
|
expect(link.prop('className')).toEqual('pf-c-button pf-c-card__close');
|
||||||
|
});
|
||||||
|
});
|
||||||
29
src/app.scss
29
src/app.scss
@@ -34,7 +34,7 @@
|
|||||||
// sidebar overrides
|
// sidebar overrides
|
||||||
//
|
//
|
||||||
|
|
||||||
.pf-c-page__sidebar{
|
.pf-c-page__sidebar {
|
||||||
--pf-c-page__sidebar--md--Width: 255px;
|
--pf-c-page__sidebar--md--Width: 255px;
|
||||||
|
|
||||||
.pf-c-nav {
|
.pf-c-nav {
|
||||||
@@ -205,8 +205,25 @@
|
|||||||
// pf card overrides
|
// pf card overrides
|
||||||
//
|
//
|
||||||
|
|
||||||
.pf-c-card {
|
// specificity hack to override PatternFly
|
||||||
|
.pf-c-card.pf-c-card {
|
||||||
|
--pf-c-card--child--PaddingRight: 20px;
|
||||||
|
--pf-c-card--child--PaddingBottom: 24px;
|
||||||
|
--pf-c-card--child--PaddingLeft: 20px;
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pf-c-card__close {
|
||||||
|
position: absolute;
|
||||||
|
top: 10px;
|
||||||
|
right: 4px;
|
||||||
|
color: var(--pf-c-button--m-plain--Color);
|
||||||
|
|
||||||
|
&.pf-c-button {
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.pf-c-card__header {
|
.pf-c-card__header {
|
||||||
@@ -300,14 +317,6 @@
|
|||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.OrgsTab-closeButton {
|
|
||||||
color: black;
|
|
||||||
float: right;
|
|
||||||
position: relative;
|
|
||||||
top: -25px;
|
|
||||||
margin: 0 10px;
|
|
||||||
right: 10px;
|
|
||||||
}
|
|
||||||
.awx-c-form-action-group {
|
.awx-c-form-action-group {
|
||||||
float: right;
|
float: right;
|
||||||
display: block;
|
display: block;
|
||||||
|
|||||||
49
src/components/CardCloseButton.jsx
Normal file
49
src/components/CardCloseButton.jsx
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { string } from 'prop-types';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import { Button } from '@patternfly/react-core';
|
||||||
|
import { TimesIcon } from '@patternfly/react-icons';
|
||||||
|
import { I18n } from '@lingui/react';
|
||||||
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
|
function CardCloseButton ({ linkTo, ...props }) {
|
||||||
|
if (linkTo) {
|
||||||
|
return (
|
||||||
|
<I18n>
|
||||||
|
{({ i18n }) => (
|
||||||
|
<Link
|
||||||
|
className="pf-c-button pf-c-card__close"
|
||||||
|
aria-label={i18n._(t`Close`)}
|
||||||
|
title={i18n._(t`Close`)}
|
||||||
|
to={linkTo}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<TimesIcon />
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
|
</I18n>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<I18n>
|
||||||
|
{({ i18n }) => (
|
||||||
|
<Button
|
||||||
|
variant="plain"
|
||||||
|
className="pf-c-card__close"
|
||||||
|
aria-label={i18n._(t`Close`)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<TimesIcon />
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</I18n>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
CardCloseButton.propTypes = {
|
||||||
|
linkTo: string,
|
||||||
|
};
|
||||||
|
CardCloseButton.defaultProps = {
|
||||||
|
linkTo: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CardCloseButton;
|
||||||
@@ -1,21 +1,19 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import { I18n } from '@lingui/react';
|
import { I18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ActionGroup,
|
ActionGroup,
|
||||||
Toolbar,
|
Toolbar,
|
||||||
ToolbarGroup,
|
ToolbarGroup,
|
||||||
Button
|
Button
|
||||||
} from '@patternfly/react-core';
|
} from '@patternfly/react-core';
|
||||||
|
import './styles.scss';
|
||||||
|
|
||||||
const formActionGroupStyle = {
|
const formActionGroupStyle = {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
justifyContent: 'flex-end',
|
justifyContent: 'flex-end',
|
||||||
marginTop: '10px'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const buttonGroupStyle = {
|
const buttonGroupStyle = {
|
||||||
3
src/components/FormActionGroup/index.js
Normal file
3
src/components/FormActionGroup/index.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import FormActionGroup from './FormActionGroup';
|
||||||
|
|
||||||
|
export default FormActionGroup;
|
||||||
3
src/components/FormActionGroup/styles.scss
Normal file
3
src/components/FormActionGroup/styles.scss
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
.pf-c-form__group.pf-m-action {
|
||||||
|
--pf-c-form__group--m-action--MarginTop: 0;
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
} from '@lingui/react';
|
} from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
import '@patternfly/patternfly/patternfly.css';
|
import '@patternfly/react-core/dist/styles/base.css';
|
||||||
import './app.scss';
|
import './app.scss';
|
||||||
import './components/Pagination/styles.scss';
|
import './components/Pagination/styles.scss';
|
||||||
import './components/DataListToolbar/styles.scss';
|
import './components/DataListToolbar/styles.scss';
|
||||||
|
|||||||
@@ -1,23 +1,11 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { I18n, i18nMark } from '@lingui/react';
|
import { I18n, i18nMark } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import {
|
import { Switch, Route, withRouter, Redirect } from 'react-router-dom';
|
||||||
Switch,
|
import { Card, CardHeader, PageSection } from '@patternfly/react-core';
|
||||||
Route,
|
|
||||||
withRouter,
|
|
||||||
Redirect,
|
|
||||||
Link
|
|
||||||
} from 'react-router-dom';
|
|
||||||
import {
|
|
||||||
Card,
|
|
||||||
CardHeader,
|
|
||||||
PageSection,
|
|
||||||
} from '@patternfly/react-core';
|
|
||||||
import {
|
|
||||||
TimesIcon
|
|
||||||
} from '@patternfly/react-icons';
|
|
||||||
import { withNetwork } from '../../../../contexts/Network';
|
import { withNetwork } from '../../../../contexts/Network';
|
||||||
import NotifyAndRedirect from '../../../../components/NotifyAndRedirect';
|
import NotifyAndRedirect from '../../../../components/NotifyAndRedirect';
|
||||||
|
import CardCloseButton from '../../../../components/CardCloseButton';
|
||||||
import OrganizationAccess from './OrganizationAccess';
|
import OrganizationAccess from './OrganizationAccess';
|
||||||
import OrganizationDetail from './OrganizationDetail';
|
import OrganizationDetail from './OrganizationDetail';
|
||||||
import OrganizationEdit from './OrganizationEdit';
|
import OrganizationEdit from './OrganizationEdit';
|
||||||
@@ -164,13 +152,7 @@ class Organization extends Component {
|
|||||||
labeltext={i18n._(t`Organization detail tabs`)}
|
labeltext={i18n._(t`Organization detail tabs`)}
|
||||||
tabsArray={tabsArray}
|
tabsArray={tabsArray}
|
||||||
/>
|
/>
|
||||||
<Link
|
<CardCloseButton linkTo="/organizations" />
|
||||||
aria-label="Close"
|
|
||||||
title="Close"
|
|
||||||
to="/organizations"
|
|
||||||
>
|
|
||||||
<TimesIcon className="OrgsTab-closeButton" />
|
|
||||||
</Link>
|
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)}
|
)}
|
||||||
</I18n>
|
</I18n>
|
||||||
|
|||||||
@@ -8,13 +8,11 @@ import {
|
|||||||
Card,
|
Card,
|
||||||
CardHeader,
|
CardHeader,
|
||||||
CardBody,
|
CardBody,
|
||||||
Button,
|
|
||||||
Tooltip,
|
Tooltip,
|
||||||
} from '@patternfly/react-core';
|
} from '@patternfly/react-core';
|
||||||
import { TimesIcon } from '@patternfly/react-icons';
|
|
||||||
|
|
||||||
import { withNetwork } from '../../../contexts/Network';
|
import { withNetwork } from '../../../contexts/Network';
|
||||||
|
import CardCloseButton from '../../../components/CardCloseButton';
|
||||||
import OrganizationForm from '../components/OrganizationForm';
|
import OrganizationForm from '../components/OrganizationForm';
|
||||||
|
|
||||||
class OrganizationAdd extends React.Component {
|
class OrganizationAdd extends React.Component {
|
||||||
@@ -70,13 +68,7 @@ class OrganizationAdd extends React.Component {
|
|||||||
content={i18n._(t`Close`)}
|
content={i18n._(t`Close`)}
|
||||||
position="top"
|
position="top"
|
||||||
>
|
>
|
||||||
<Button
|
<CardCloseButton onClick={this.handleCancel} />
|
||||||
variant="plain"
|
|
||||||
aria-label={i18n._(t`Close`)}
|
|
||||||
onClick={this.handleCancel}
|
|
||||||
>
|
|
||||||
<TimesIcon />
|
|
||||||
</Button>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardBody>
|
<CardBody>
|
||||||
|
|||||||
Reference in New Issue
Block a user