export function searchQualityProfiles(
parameters: SearchQualityProfilesParameters
): Promise<SearchQualityProfilesResponse> {
- return getJSON('/api/qualityprofiles/search', parameters);
+ return getJSON('/api/qualityprofiles/search', parameters).catch(throwGlobalError);
}
export function getQualityProfile(data: {
interface Props {
component: Component;
- customOrganizations: boolean;
}
interface State {
}
fetchProfiles() {
- const { component } = this.props;
- const organization = this.props.customOrganizations ? component.organization : undefined;
+ const { key, organization } = this.props.component;
Promise.all([
searchQualityProfiles({ organization }).then(r => r.profiles),
- searchQualityProfiles({ organization, project: component.key }).then(r => r.profiles)
+ searchQualityProfiles({ organization, project: key }).then(r => r.profiles)
]).then(
([allProfiles, profiles]) => {
if (this.mounted) {
it('checks permissions', () => {
handleRequiredAuthorization.mockClear();
- mount(<App component={{ ...component, configuration: undefined }} customOrganizations={false} />);
+ mount(<App component={{ ...component, configuration: undefined }} />);
expect(handleRequiredAuthorization).toBeCalled();
});
it('fetches profiles', () => {
searchQualityProfiles.mockClear();
- mount(<App component={component} customOrganizations={false} />);
- expect(searchQualityProfiles.mock.calls).toHaveLength(2);
- expect(searchQualityProfiles).toBeCalledWith({ organization: undefined });
- expect(searchQualityProfiles).toBeCalledWith({ organization: undefined, project: 'foo' });
-});
-
-it('fetches profiles with organization', () => {
- searchQualityProfiles.mockClear();
- mount(<App component={component} customOrganizations={true} />);
+ mount(<App component={component} />);
expect(searchQualityProfiles.mock.calls).toHaveLength(2);
expect(searchQualityProfiles).toBeCalledWith({ organization: 'org' });
expect(searchQualityProfiles).toBeCalledWith({ organization: 'org', project: 'foo' });
associateProject.mockClear();
dissociateProject.mockClear();
addGlobalSuccessMessage.mockClear();
- const wrapper = mount(<App component={component} customOrganizations={false} />);
+ const wrapper = mount(<App component={component} />);
const fooJava = randomProfile('foo-java', 'java');
const fooJs = randomProfile('foo-js', 'js');
loadData() {
this.setState({ loading: true });
- Promise.all([getExporters(), this.fetchProfiles()]).then(responses => {
- if (this.mounted) {
- const [exporters, profilesResponse] = responses;
- this.setState({
- actions: profilesResponse.actions,
- exporters,
- profiles: sortProfiles(profilesResponse.profiles),
- loading: false
- });
+ Promise.all([getExporters(), this.fetchProfiles()]).then(
+ responses => {
+ if (this.mounted) {
+ const [exporters, profilesResponse] = responses;
+ this.setState({
+ actions: profilesResponse.actions,
+ exporters,
+ profiles: sortProfiles(profilesResponse.profiles),
+ loading: false
+ });
+ }
+ },
+ () => {
+ if (this.mounted) {
+ this.setState({ loading: false });
+ }
}
- });
+ );
}
updateProfiles = () => {