mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
Add default option for AnsibleSelect dropdown.
This commit is contained in:
parent
fb7ccdb726
commit
97477b789a
@ -32,15 +32,17 @@ class AnsibleSelect extends React.Component {
|
||||
|
||||
render () {
|
||||
const { count } = this.state;
|
||||
const { labelName, selected, data } = this.props;
|
||||
const { labelName, selected, data, defaultSelected } = this.props;
|
||||
let elem;
|
||||
if (count > 1) {
|
||||
elem = (
|
||||
<FormGroup label={labelName} fieldId="ansible-select">
|
||||
<Select value={selected} onChange={this.onSelectChange} aria-label="Select Input">
|
||||
{data.map((datum) => (
|
||||
<SelectOption isDisabled={datum.disabled} key={datum} value={datum} label={datum} />
|
||||
))}
|
||||
<SelectOption isDisabled key="" value="" label={`Use Default ${labelName}`} />
|
||||
{data.map((datum) =>
|
||||
datum !== defaultSelected ?
|
||||
(<SelectOption key={datum} value={datum} label={datum} />) : null)
|
||||
}
|
||||
</Select>
|
||||
</FormGroup>
|
||||
);
|
||||
|
@ -47,7 +47,8 @@ class OrganizationAdd extends React.Component {
|
||||
results: [],
|
||||
custom_virtualenv: '',
|
||||
error: '',
|
||||
selectedInstanceGroups: []
|
||||
selectedInstanceGroups: [],
|
||||
defaultEnv: '/venv/ansible/'
|
||||
};
|
||||
|
||||
async componentDidMount () {
|
||||
@ -129,6 +130,7 @@ class OrganizationAdd extends React.Component {
|
||||
description,
|
||||
custom_virtualenv,
|
||||
selectedInstanceGroups,
|
||||
defaultEnv,
|
||||
error
|
||||
} = this.state;
|
||||
const enabled = name.length > 0; // TODO: add better form validation
|
||||
@ -176,6 +178,7 @@ class OrganizationAdd extends React.Component {
|
||||
selected={custom_virtualenv}
|
||||
selectChange={this.onSelectChange}
|
||||
data={custom_virtualenvs}
|
||||
defaultSelected={defaultEnv}
|
||||
/>
|
||||
)}
|
||||
</ConfigContext.Consumer>
|
||||
|
Loading…
Reference in New Issue
Block a user