mirror of
https://github.com/ansible/awx.git
synced 2026-02-01 09:38:10 -03:30
Implement React Context API
- Move API GET request to /v2/config out to the top level of our App. - Store /v2/config response data in sessionStorage. - Use Context API to pass down relevant data to Organizations component. - Wrap our AnsibleSelect component as a context consumer and pass in the list of Ansible Environments of the logged in user. - Clear sessionStorage object when user logs out. - Update unit tests.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React from 'react';
|
||||
|
||||
import {
|
||||
FormGroup,
|
||||
Select,
|
||||
@@ -16,19 +17,19 @@ class AnsibleSelect extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { hidden } = this.props;
|
||||
if (hidden) {
|
||||
return null;
|
||||
} else {
|
||||
if (this.props.data.length > 1) {
|
||||
return (
|
||||
<FormGroup label={this.props.labelName} fieldId="ansible-select">
|
||||
<Select value={this.props.selected} onChange={this.onSelectChange} aria-label="Select Input">
|
||||
{this.props.data.map((env, index) => (
|
||||
<SelectOption isDisabled={env.disabled} key={index} value={env} label={env} />
|
||||
{this.props.data.map((datum, index) => (
|
||||
<SelectOption isDisabled={datum.disabled} key={index} value={datum} label={datum} />
|
||||
))}
|
||||
</Select>
|
||||
</FormGroup>
|
||||
);
|
||||
)
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user