incorporate feedback on instance groups pagination

This commit is contained in:
John Mitchell
2019-02-12 11:59:49 -05:00
parent 6431ec603f
commit c1381f7b98
3 changed files with 19 additions and 21 deletions

View File

@@ -50,13 +50,13 @@ class Lookup extends React.Component {
}
async getData (queryParams) {
const { getEndpoint } = this.props;
const { getItems } = this.props;
const { page } = queryParams;
this.setState({ error: false });
try {
const { data } = await getEndpoint(queryParams);
const { data } = await getItems(queryParams);
const { results, count } = data;
const stateToUpdate = {
@@ -150,7 +150,7 @@ class Lookup extends React.Component {
<Button key="cancel" variant="secondary" onClick={this.handleModalToggle}>{(results.length === 0) ? i18n._(t`Close`) : i18n._(t`Cancel`)}</Button>
]}
>
{(results.length === 0) && (
{(results.length === 0) ? (
<EmptyState>
<EmptyStateIcon icon={CubesIcon} />
<Title size="lg">
@@ -160,7 +160,7 @@ class Lookup extends React.Component {
<Trans>{`Please add ${lookupHeader.toLowerCase()} to populate this list`}</Trans>
</EmptyStateBody>
</EmptyState>
) || (
) : (
<Fragment>
<ul className="pf-c-data-list awx-c-list">
{results.map(i => (

View File

@@ -16,14 +16,6 @@ import Lookup from '../../../components/Lookup';
import AnsibleSelect from '../../../components/AnsibleSelect';
import FormActionGroup from '../../../components/FormActionGroup';
const initialFormState = {
name: '',
description: '',
custom_virtualenv: '',
instanceGroups: [],
error: '',
};
class OrganizationAdd extends React.Component {
constructor (props) {
super(props);
@@ -34,9 +26,15 @@ class OrganizationAdd extends React.Component {
this.onSubmit = this.onSubmit.bind(this);
this.onCancel = this.onCancel.bind(this);
this.onSuccess = this.onSuccess.bind(this);
}
state = initialFormState;
this.state = {
name: '',
description: '',
custom_virtualenv: '',
instanceGroups: [],
error: '',
};
}
onFieldChange (val, evt) {
this.setState({ [evt.target.name]: val || evt.target.value });
@@ -132,7 +130,7 @@ class OrganizationAdd extends React.Component {
name="instanceGroups"
value={instanceGroups}
onLookupSave={this.onLookupSave}
getEndpoint={this.getInstanceGroups}
getItems={this.getInstanceGroups}
/>
</FormGroup>
<ConfigContext.Consumer>