mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
org-add fixup
re-adding a changeset I missed when resolving a merge conflict earlier
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import React, { Fragment } from 'react';
|
import React, { Fragment } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import { withRouter } from 'react-router-dom';
|
import { withRouter } from 'react-router-dom';
|
||||||
import { Trans } from '@lingui/macro';
|
import { Trans } from '@lingui/macro';
|
||||||
import {
|
import {
|
||||||
@@ -17,8 +18,8 @@ import {
|
|||||||
CardBody,
|
CardBody,
|
||||||
} from '@patternfly/react-core';
|
} from '@patternfly/react-core';
|
||||||
|
|
||||||
import AnsibleSelect from '../../../components/AnsibleSelect';
|
import { ConfigContext } from '../../../context';
|
||||||
|
import AnsibleSelect from '../../../components/AnsibleSelect'
|
||||||
const { light } = PageSectionVariants;
|
const { light } = PageSectionVariants;
|
||||||
|
|
||||||
class OrganizationAdd extends React.Component {
|
class OrganizationAdd extends React.Component {
|
||||||
@@ -37,8 +38,6 @@ class OrganizationAdd extends React.Component {
|
|||||||
description: '',
|
description: '',
|
||||||
instanceGroups: '',
|
instanceGroups: '',
|
||||||
custom_virtualenv: '',
|
custom_virtualenv: '',
|
||||||
custom_virtualenvs: [],
|
|
||||||
hideAnsibleSelect: true,
|
|
||||||
error:'',
|
error:'',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -59,9 +58,9 @@ class OrganizationAdd extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onSubmit() {
|
async onSubmit() {
|
||||||
|
const { api } = this.props;
|
||||||
const data = Object.assign({}, { ...this.state });
|
const data = Object.assign({}, { ...this.state });
|
||||||
await api.createOrganization(data);
|
await api.createOrganization(data);
|
||||||
|
|
||||||
this.resetForm();
|
this.resetForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,22 +68,10 @@ class OrganizationAdd extends React.Component {
|
|||||||
this.props.history.push('/organizations');
|
this.props.history.push('/organizations');
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
|
||||||
try {
|
|
||||||
const { data } = await api.getConfig();
|
|
||||||
this.setState({ custom_virtualenvs: [...data.custom_virtualenvs] });
|
|
||||||
if (this.state.custom_virtualenvs.length > 1) {
|
|
||||||
// Show dropdown if we have more than one ansible environment
|
|
||||||
this.setState({ hideAnsibleSelect: !this.state.hideAnsibleSelect });
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
this.setState({ error })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { name } = this.state;
|
const { name } = this.state;
|
||||||
const enabled = name.length > 0; // TODO: add better form validation
|
const enabled = name.length > 0; // TODO: add better form validation
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<PageSection variant={light} className="pf-m-condensed">
|
<PageSection variant={light} className="pf-m-condensed">
|
||||||
@@ -128,13 +115,16 @@ class OrganizationAdd extends React.Component {
|
|||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
<AnsibleSelect
|
<ConfigContext.Consumer>
|
||||||
labelName="Ansible Environment"
|
{({ custom_virtualenvs }) =>
|
||||||
selected={this.state.custom_virtualenv}
|
<AnsibleSelect
|
||||||
selectChange={this.onSelectChange}
|
labelName="Ansible Environment"
|
||||||
data={this.state.custom_virtualenvs}
|
selected={this.state.custom_virtualenv}
|
||||||
hidden={this.state.hideAnsibleSelect}
|
selectChange={this.onSelectChange}
|
||||||
/>
|
data={custom_virtualenvs}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
</ConfigContext.Consumer>
|
||||||
</Gallery>
|
</Gallery>
|
||||||
<ActionGroup className="at-align-right">
|
<ActionGroup className="at-align-right">
|
||||||
<Toolbar>
|
<Toolbar>
|
||||||
@@ -155,4 +145,8 @@ class OrganizationAdd extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OrganizationAdd.contextTypes = {
|
||||||
|
custom_virtualenvs: PropTypes.array,
|
||||||
|
};
|
||||||
|
|
||||||
export default withRouter(OrganizationAdd);
|
export default withRouter(OrganizationAdd);
|
||||||
|
|||||||
Reference in New Issue
Block a user