diff --git a/src/pages/Organizations/views/Organization.add.jsx b/src/pages/Organizations/views/Organization.add.jsx index d5815a5f00..e42072ff18 100644 --- a/src/pages/Organizations/views/Organization.add.jsx +++ b/src/pages/Organizations/views/Organization.add.jsx @@ -1,4 +1,5 @@ import React, { Fragment } from 'react'; +import PropTypes from 'prop-types'; import { withRouter } from 'react-router-dom'; import { Trans } from '@lingui/macro'; import { @@ -17,8 +18,8 @@ import { CardBody, } from '@patternfly/react-core'; -import AnsibleSelect from '../../../components/AnsibleSelect'; - +import { ConfigContext } from '../../../context'; +import AnsibleSelect from '../../../components/AnsibleSelect' const { light } = PageSectionVariants; class OrganizationAdd extends React.Component { @@ -37,8 +38,6 @@ class OrganizationAdd extends React.Component { description: '', instanceGroups: '', custom_virtualenv: '', - custom_virtualenvs: [], - hideAnsibleSelect: true, error:'', }; @@ -59,9 +58,9 @@ class OrganizationAdd extends React.Component { } async onSubmit() { + const { api } = this.props; const data = Object.assign({}, { ...this.state }); await api.createOrganization(data); - this.resetForm(); } @@ -69,22 +68,10 @@ class OrganizationAdd extends React.Component { 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() { const { name } = this.state; const enabled = name.length > 0; // TODO: add better form validation + return ( @@ -128,13 +115,16 @@ class OrganizationAdd extends React.Component { onChange={this.handleChange} /> -