Changes InventoriesLookup to InventoryLookup and removes pluralization of lookup headers for Inventory and Project since only one can be selected.

This commit is contained in:
mabashian
2019-09-19 11:13:55 -04:00
parent b00fc29cdc
commit a6a50f0eb1
6 changed files with 15 additions and 15 deletions

View File

@@ -11,7 +11,7 @@ import Lookup from '@components/Lookup';
const getInventories = async params => InventoriesAPI.read(params); const getInventories = async params => InventoriesAPI.read(params);
class InventoriesLookup extends React.Component { class InventoryLookup extends React.Component {
render() { render() {
const { value, tooltip, onChange, required, i18n } = this.props; const { value, tooltip, onChange, required, i18n } = this.props;
@@ -19,7 +19,7 @@ class InventoriesLookup extends React.Component {
<FormGroup <FormGroup
label={ label={
<Fragment> <Fragment>
{i18n._(t`Inventories`)}{' '} {i18n._(t`Inventory`)}{' '}
{tooltip && ( {tooltip && (
<Tooltip position="right" content={tooltip}> <Tooltip position="right" content={tooltip}>
<QuestionCircleIcon /> <QuestionCircleIcon />
@@ -28,12 +28,12 @@ class InventoriesLookup extends React.Component {
</Fragment> </Fragment>
} }
isRequired={required} isRequired={required}
fieldId="inventories-lookup" fieldId="inventory-lookup"
> >
<Lookup <Lookup
id="inventories-lookup" id="inventory-lookup"
lookupHeader={i18n._(t`Inventories`)} lookupHeader={i18n._(t`Inventory`)}
name="inventories" name="inventory"
value={value} value={value}
onLookupSave={onChange} onLookupSave={onChange}
getItems={getInventories} getItems={getInventories}
@@ -61,17 +61,17 @@ class InventoriesLookup extends React.Component {
} }
} }
InventoriesLookup.propTypes = { InventoryLookup.propTypes = {
value: Inventory, value: Inventory,
tooltip: string, tooltip: string,
onChange: func.isRequired, onChange: func.isRequired,
required: bool, required: bool,
}; };
InventoriesLookup.defaultProps = { InventoryLookup.defaultProps = {
value: null, value: null,
tooltip: '', tooltip: '',
required: false, required: false,
}; };
export default withI18n()(InventoriesLookup); export default withI18n()(InventoryLookup);

View File

@@ -1,3 +1,3 @@
export { default } from './Lookup'; export { default } from './Lookup';
export { default as InstanceGroupsLookup } from './InstanceGroupsLookup'; export { default as InstanceGroupsLookup } from './InstanceGroupsLookup';
export { default as InventoriesLookup } from './InventoriesLookup'; export { default as InventoryLookup } from './InventoryLookup';

View File

@@ -61,7 +61,7 @@ describe('<JobTemplateAdd />', () => {
expect(wrapper.find('input#template-description').text()).toBe( expect(wrapper.find('input#template-description').text()).toBe(
defaultProps.description defaultProps.description
); );
expect(wrapper.find('InventoriesLookup').prop('value')).toBe(null); expect(wrapper.find('InventoryLookup').prop('value')).toBe(null);
expect(wrapper.find('AnsibleSelect[name="job_type"]').props().value).toBe( expect(wrapper.find('AnsibleSelect[name="job_type"]').props().value).toBe(
defaultProps.job_type defaultProps.job_type
); );

View File

@@ -25,7 +25,7 @@ import CollapsibleSection from '@components/CollapsibleSection';
import { required } from '@util/validators'; import { required } from '@util/validators';
import styled from 'styled-components'; import styled from 'styled-components';
import { JobTemplate } from '@types'; import { JobTemplate } from '@types';
import { InventoriesLookup, InstanceGroupsLookup } from '@components/Lookup'; import { InventoryLookup, InstanceGroupsLookup } from '@components/Lookup';
import ProjectLookup from './ProjectLookup'; import ProjectLookup from './ProjectLookup';
import { JobTemplatesAPI, LabelsAPI, ProjectsAPI } from '@api'; import { JobTemplatesAPI, LabelsAPI, ProjectsAPI } from '@api';
@@ -397,7 +397,7 @@ class JobTemplateForm extends Component {
name="inventory" name="inventory"
validate={required(null, i18n)} validate={required(null, i18n)}
render={({ form }) => ( render={({ form }) => (
<InventoriesLookup <InventoryLookup
value={inventory} value={inventory}
tooltip={i18n._(t`Select the inventory containing the hosts tooltip={i18n._(t`Select the inventory containing the hosts
you want this job to manage.`)} you want this job to manage.`)}

View File

@@ -109,7 +109,7 @@ describe('<JobTemplateForm />', () => {
target: { value: 'new job type', name: 'job_type' }, target: { value: 'new job type', name: 'job_type' },
}); });
expect(form.state('values').job_type).toEqual('new job type'); expect(form.state('values').job_type).toEqual('new job type');
wrapper.find('InventoriesLookup').prop('onChange')({ wrapper.find('InventoryLookup').prop('onChange')({
id: 3, id: 3,
name: 'inventory', name: 'inventory',
}); });

View File

@@ -43,7 +43,7 @@ class ProjectLookup extends React.Component {
)} )}
<Lookup <Lookup
id="project" id="project"
lookupHeader={i18n._(t`Projects`)} lookupHeader={i18n._(t`Project`)}
name="project" name="project"
value={value} value={value}
onBlur={onBlur} onBlur={onBlur}