1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

add FormRow component; rename unwrapped components with underscore

This commit is contained in:
Keith Grant 2019-03-29 13:50:17 -04:00
parent 2002d48bcc
commit 40b88da9dd
7 changed files with 31 additions and 16 deletions

5
__tests__/.eslintrc Normal file
View File

@ -0,0 +1,5 @@
{
"rules": {
"react/jsx-pascal-case": "ignore"
}
}

View File

@ -2,7 +2,7 @@ import React from 'react';
import { mount } from 'enzyme';
import { MemoryRouter } from 'react-router-dom';
import { I18nProvider } from '@lingui/react';
import OrganizationEdit, { OrganizationEditNoRouter } from '../../../../../src/pages/Organizations/screens/Organization/OrganizationEdit';
import OrganizationEdit, { _OrganizationEdit } from '../../../../../src/pages/Organizations/screens/Organization/OrganizationEdit';
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
@ -94,7 +94,7 @@ describe('<OrganizationEdit />', () => {
const wrapper = mount(
<MemoryRouter>
<I18nProvider>
<OrganizationEditNoRouter
<_OrganizationEdit
history={history}
organization={mockData}
api={api}

View File

@ -3,7 +3,7 @@ import { mount } from 'enzyme';
import { MemoryRouter } from 'react-router-dom';
import { I18nProvider } from '@lingui/react';
import { ConfigContext } from '../../../../src/context';
import OrganizationAdd, { OrganizationAddNoRouter } from '../../../../src/pages/Organizations/screens/OrganizationAdd';
import OrganizationAdd, { _OrganizationAdd } from '../../../../src/pages/Organizations/screens/OrganizationAdd';
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
@ -47,7 +47,7 @@ describe('<OrganizationAdd />', () => {
const wrapper = mount(
<MemoryRouter>
<I18nProvider>
<OrganizationAddNoRouter
<_OrganizationAdd
history={history}
api={api}
/>
@ -68,7 +68,7 @@ describe('<OrganizationAdd />', () => {
const wrapper = mount(
<MemoryRouter>
<I18nProvider>
<OrganizationAddNoRouter
<_OrganizationAdd
history={history}
api={api}
/>
@ -103,7 +103,7 @@ describe('<OrganizationAdd />', () => {
const wrapper = mount(
<MemoryRouter>
<I18nProvider>
<OrganizationAddNoRouter
<_OrganizationAdd
history={history}
api={api}
/>

View File

@ -0,0 +1,15 @@
import React from 'react';
export default function FormRow ({ children }) {
return (
<div
style={{
display: 'grid',
gridGap: '20px',
gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))'
}}
>
{children}
</div>
);
}

View File

@ -10,6 +10,7 @@ import {
} from '@patternfly/react-core';
import { ConfigContext } from '../../../context';
import FormRow from '../../../components/FormRow';
import FormField from '../../../components/FormField';
import FormActionGroup from '../../../components/FormActionGroup';
import AnsibleSelect from '../../../components/AnsibleSelect';
@ -96,13 +97,7 @@ class OrganizationForm extends Component {
onSubmit={this.handleSubmit}
render={formik => (
<Form autoComplete="off" onSubmit={formik.handleSubmit}>
<div
style={{
display: 'grid',
gridGap: '20px',
gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))'
}}
>
<FormRow>
<FormField
id="edit-org-form-name"
name="name"
@ -139,7 +134,7 @@ class OrganizationForm extends Component {
)
)}
</ConfigContext.Consumer>
</div>
</FormRow>
<InstanceGroupsLookup
api={api}
value={instanceGroups}

View File

@ -84,5 +84,5 @@ OrganizationEdit.contextTypes = {
custom_virtualenvs: PropTypes.arrayOf(PropTypes.string)
};
export { OrganizationEdit as OrganizationEditNoRouter };
export { OrganizationEdit as _OrganizationEdit };
export default withRouter(OrganizationEdit);

View File

@ -104,5 +104,5 @@ OrganizationAdd.contextTypes = {
custom_virtualenvs: PropTypes.arrayOf(PropTypes.string)
};
export { OrganizationAdd as OrganizationAddNoRouter };
export { OrganizationAdd as _OrganizationAdd };
export default withRouter(OrganizationAdd);