mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
Restore FormGroup to parent Add Org component for AnsibleSelect.
This commit is contained in:
parent
2a254ea538
commit
bba1c4f5b6
@ -2,7 +2,6 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import {
|
||||
FormGroup,
|
||||
Select,
|
||||
SelectOption,
|
||||
} from '@patternfly/react-core';
|
||||
@ -13,19 +12,6 @@ class AnsibleSelect extends React.Component {
|
||||
this.onSelectChange = this.onSelectChange.bind(this);
|
||||
}
|
||||
|
||||
state = {
|
||||
count: 1,
|
||||
}
|
||||
|
||||
static getDerivedStateFromProps (nexProps) {
|
||||
if (nexProps.data) {
|
||||
return {
|
||||
count: nexProps.data.length,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
onSelectChange (val, event) {
|
||||
const { onChange, name } = this.props;
|
||||
event.target.name = name;
|
||||
@ -33,23 +19,14 @@ class AnsibleSelect extends React.Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
const { count } = this.state;
|
||||
const { label = '', value, data, name, defaultSelected } = this.props;
|
||||
let elem;
|
||||
if (count > 1) {
|
||||
elem = (
|
||||
<FormGroup label={label} fieldId={`ansible-select-${name}`}>
|
||||
const { label, value, data, defaultSelected } = this.props;
|
||||
return (
|
||||
<Select value={value} onChange={this.onSelectChange} aria-label="Select Input">
|
||||
{data.map((datum) => (datum === defaultSelected
|
||||
? (<SelectOption key="" value="" label={`Use Default ${label}`} />) : (<SelectOption key={datum} value={datum} label={datum} />)))
|
||||
}
|
||||
</Select>
|
||||
</FormGroup>
|
||||
);
|
||||
} else {
|
||||
elem = null;
|
||||
}
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,14 +34,13 @@ AnsibleSelect.defaultProps = {
|
||||
data: [],
|
||||
label: 'Ansible Select',
|
||||
defaultSelected: null,
|
||||
name: null,
|
||||
};
|
||||
|
||||
AnsibleSelect.propTypes = {
|
||||
data: PropTypes.arrayOf(PropTypes.string),
|
||||
defaultSelected: PropTypes.string,
|
||||
label: PropTypes.string,
|
||||
name: PropTypes.string,
|
||||
name: PropTypes.string.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
value: PropTypes.string.isRequired,
|
||||
};
|
||||
|
@ -137,6 +137,8 @@ class OrganizationAdd extends React.Component {
|
||||
</FormGroup>
|
||||
<ConfigContext.Consumer>
|
||||
{({ custom_virtualenvs }) => (
|
||||
custom_virtualenvs && custom_virtualenvs.length > 1 && (
|
||||
<FormGroup label="Ansible Environment" fieldId="add-org-custom-virtualenv">
|
||||
<AnsibleSelect
|
||||
label="Ansible Environment"
|
||||
name="custom_virtualenv"
|
||||
@ -145,6 +147,8 @@ class OrganizationAdd extends React.Component {
|
||||
data={custom_virtualenvs}
|
||||
defaultSelected={defaultEnv}
|
||||
/>
|
||||
</FormGroup>
|
||||
)
|
||||
)}
|
||||
</ConfigContext.Consumer>
|
||||
</Gallery>
|
||||
|
Loading…
Reference in New Issue
Block a user