mirror of
https://github.com/ansible/awx.git
synced 2026-02-21 05:00:07 -03:30
update api calls to utilized network context
This commit is contained in:
@@ -7,6 +7,8 @@ import { t } from '@lingui/macro';
|
||||
|
||||
import Lookup from '../../../components/Lookup';
|
||||
|
||||
import { withNetwork } from '../../../contexts/Network';
|
||||
|
||||
const INSTANCE_GROUPS_LOOKUP_COLUMNS = [
|
||||
{ name: i18nMark('Name'), key: 'name', isSortable: true },
|
||||
{ name: i18nMark('Modified'), key: 'modified', isSortable: false, isNumeric: true },
|
||||
@@ -69,9 +71,6 @@ class InstanceGroupsLookup extends React.Component {
|
||||
}
|
||||
|
||||
InstanceGroupsLookup.propTypes = {
|
||||
api: PropTypes.shape({
|
||||
getInstanceGroups: PropTypes.func,
|
||||
}).isRequired,
|
||||
value: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
tooltip: PropTypes.string,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
@@ -81,4 +80,4 @@ InstanceGroupsLookup.defaultProps = {
|
||||
tooltip: '',
|
||||
};
|
||||
|
||||
export default InstanceGroupsLookup;
|
||||
export default withNetwork(InstanceGroupsLookup);
|
||||
|
||||
@@ -13,6 +13,8 @@ import {
|
||||
Link
|
||||
} from 'react-router-dom';
|
||||
|
||||
import { withNetwork } from '../../../contexts/Network';
|
||||
|
||||
import AlertModal from '../../../components/AlertModal';
|
||||
import Pagination from '../../../components/Pagination';
|
||||
import DataListToolbar from '../../../components/DataListToolbar';
|
||||
@@ -238,20 +240,16 @@ class OrganizationAccessList extends React.Component {
|
||||
}
|
||||
|
||||
async removeAccessRole (roleId, resourceId, type) {
|
||||
const { removeRole } = this.props;
|
||||
const { removeRole, handleHttpError } = this.props;
|
||||
const url = `/api/v2/${type}/${resourceId}/roles/`;
|
||||
try {
|
||||
await removeRole(url, roleId);
|
||||
const queryParams = this.getQueryParams();
|
||||
await this.fetchOrgAccessList(queryParams);
|
||||
this.setState({ showWarning: false });
|
||||
} catch (error) {
|
||||
this.setState({ error });
|
||||
handleHttpError(error) || this.setState({ error });
|
||||
}
|
||||
const queryParams = this.getQueryParams();
|
||||
try {
|
||||
this.fetchOrgAccessList(queryParams);
|
||||
} catch (error) {
|
||||
this.setState({ error });
|
||||
}
|
||||
this.setState({ showWarning: false });
|
||||
}
|
||||
|
||||
handleWarning (roleName, roleId, resourceName, resourceId, type) {
|
||||
@@ -432,4 +430,4 @@ OrganizationAccessList.propTypes = {
|
||||
removeRole: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default OrganizationAccessList;
|
||||
export default withNetwork(OrganizationAccessList);
|
||||
|
||||
@@ -9,7 +9,8 @@ import {
|
||||
FormGroup,
|
||||
} from '@patternfly/react-core';
|
||||
|
||||
import { ConfigContext } from '../../../context';
|
||||
import { Config } from '../../../contexts/Config';
|
||||
import { withNetwork } from '../../../contexts/Network';
|
||||
import FormRow from '../../../components/FormRow';
|
||||
import FormField from '../../../components/FormField';
|
||||
import FormActionGroup from '../../../components/FormActionGroup';
|
||||
@@ -81,7 +82,7 @@ class OrganizationForm extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
const { api, organization, handleCancel } = this.props;
|
||||
const { organization, handleCancel } = this.props;
|
||||
const { instanceGroups, formIsValid, error } = this.state;
|
||||
const defaultVenv = '/venv/ansible/';
|
||||
|
||||
@@ -112,7 +113,7 @@ class OrganizationForm extends Component {
|
||||
type="text"
|
||||
label={i18n._(t`Description`)}
|
||||
/>
|
||||
<ConfigContext.Consumer>
|
||||
<Config>
|
||||
{({ custom_virtualenvs }) => (
|
||||
custom_virtualenvs && custom_virtualenvs.length > 1 && (
|
||||
<Field
|
||||
@@ -133,10 +134,9 @@ class OrganizationForm extends Component {
|
||||
/>
|
||||
)
|
||||
)}
|
||||
</ConfigContext.Consumer>
|
||||
</Config>
|
||||
</FormRow>
|
||||
<InstanceGroupsLookup
|
||||
api={api}
|
||||
value={instanceGroups}
|
||||
onChange={this.handleInstanceGroupsChange}
|
||||
tooltip={i18n._(t`Select the Instance Groups for this Organization to run on.`)}
|
||||
@@ -157,7 +157,6 @@ class OrganizationForm extends Component {
|
||||
}
|
||||
|
||||
OrganizationForm.propTypes = {
|
||||
api: PropTypes.shape().isRequired,
|
||||
organization: PropTypes.shape(),
|
||||
handleSubmit: PropTypes.func.isRequired,
|
||||
handleCancel: PropTypes.func.isRequired,
|
||||
@@ -175,4 +174,4 @@ OrganizationForm.contextTypes = {
|
||||
custom_virtualenvs: PropTypes.arrayOf(PropTypes.string)
|
||||
};
|
||||
|
||||
export default withRouter(OrganizationForm);
|
||||
export default withNetwork(withRouter(OrganizationForm));
|
||||
|
||||
Reference in New Issue
Block a user