mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
Fix linter and existing unit tests.
This commit is contained in:
@@ -120,11 +120,4 @@ describe('<App />', () => {
|
|||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Componenet makes REST call to API_CONFIG endpoint when mounted', () => {
|
|
||||||
api.get = jest.fn().mockImplementation(() => Promise.resolve({}));
|
|
||||||
const appWrapper = shallow(<App.WrappedComponent />);
|
|
||||||
expect(api.get).toHaveBeenCalledTimes(1);
|
|
||||||
expect(api.get).toHaveBeenCalledWith(API_CONFIG);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class APIClient {
|
|||||||
return this.http.get(endpoint);
|
return this.http.get(endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
getInstanceGroups (){
|
getInstanceGroups () {
|
||||||
return this.http.get(API_INSTANCE_GROUPS);
|
return this.http.get(API_INSTANCE_GROUPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +82,6 @@ class APIClient {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default APIClient;
|
export default APIClient;
|
||||||
|
|||||||
@@ -73,11 +73,20 @@ class OrganizationAdd extends React.Component {
|
|||||||
async onSubmit() {
|
async onSubmit() {
|
||||||
const { api } = this.props;
|
const { api } = this.props;
|
||||||
const data = Object.assign({}, { ...this.state });
|
const data = Object.assign({}, { ...this.state });
|
||||||
const { data: response } = await api.createOrganization(data);
|
try {
|
||||||
const url = response.related.instance_groups;
|
const { data: response } = await api.createOrganization(data);
|
||||||
const selected = this.state.results.filter(group => group.isChecked);
|
const url = response.related.instance_groups;
|
||||||
await api.createInstanceGroups(url, selected);
|
const selected = this.state.results.filter(group => group.isChecked);
|
||||||
this.resetForm();
|
try {
|
||||||
|
await api.createInstanceGroups(url, selected);
|
||||||
|
this.resetForm();
|
||||||
|
} catch (err) {
|
||||||
|
this.setState({ createInstanceGroupsError: err })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.setState({ onSubmitError: err })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onCancel() {
|
onCancel() {
|
||||||
@@ -86,12 +95,17 @@ class OrganizationAdd extends React.Component {
|
|||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
const { api } = this.props;
|
const { api } = this.props;
|
||||||
const { data } = await api.getInstanceGroups();
|
try {
|
||||||
let results = [];
|
const { data } = await api.getInstanceGroups();
|
||||||
data.results.map((result) => {
|
let results = [];
|
||||||
results.push({ id: result.id, name: result.name, isChecked: false });
|
data.results.map((result) => {
|
||||||
})
|
results.push({ id: result.id, name: result.name, isChecked: false });
|
||||||
this.setState({ results });
|
})
|
||||||
|
this.setState({ results });
|
||||||
|
} catch (error) {
|
||||||
|
this.setState({ getInstanceGroupsError: error })
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
Reference in New Issue
Block a user