diff options
Diffstat (limited to 'server')
4 files changed, 23 insertions, 26 deletions
diff --git a/server/sonar-web/src/main/js/api/quality-profiles.ts b/server/sonar-web/src/main/js/api/quality-profiles.ts index 9daa0c5051a..5e2715d7b81 100644 --- a/server/sonar-web/src/main/js/api/quality-profiles.ts +++ b/server/sonar-web/src/main/js/api/quality-profiles.ts @@ -97,7 +97,7 @@ export interface SearchQualityProfilesResponse { 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: { diff --git a/server/sonar-web/src/main/js/apps/projectQualityProfiles/App.tsx b/server/sonar-web/src/main/js/apps/projectQualityProfiles/App.tsx index 45bdae0cb28..8038913342d 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityProfiles/App.tsx +++ b/server/sonar-web/src/main/js/apps/projectQualityProfiles/App.tsx @@ -34,7 +34,6 @@ import { translate, translateWithParameters } from '../../helpers/l10n'; interface Props { component: Component; - customOrganizations: boolean; } interface State { @@ -67,11 +66,10 @@ export default class QualityProfiles extends React.PureComponent<Props, 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) { diff --git a/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/App-test.tsx index 9e873f1187f..35a49ed3bd6 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/App-test.tsx @@ -66,21 +66,13 @@ const component = { 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' }); @@ -90,7 +82,7 @@ it('changes profile', () => { 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'); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx index fda9bb7ed26..661d0b4b3e7 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx @@ -60,17 +60,24 @@ export default class App extends React.PureComponent<Props, State> { 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 = () => { |