aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js
diff options
context:
space:
mode:
authorStas Vilchik <stas.vilchik@sonarsource.com>2018-01-09 11:01:22 +0100
committerStas Vilchik <stas.vilchik@sonarsource.com>2018-01-09 20:16:51 +0100
commit1904c96a996c1cba54e2fe7540447fcb031e00d3 (patch)
treecaaba56bb7e80486ffdd19f180997896b232359b /server/sonar-web/src/main/js
parent4ce8eea9aef0854d57e6a0644b363cbed524b5bd (diff)
downloadsonarqube-1904c96a996c1cba54e2fe7540447fcb031e00d3.tar.gz
sonarqube-1904c96a996c1cba54e2fe7540447fcb031e00d3.zip
SONAR-10073 Impossible to set QP of a project from an organization that is not default
Diffstat (limited to 'server/sonar-web/src/main/js')
-rw-r--r--server/sonar-web/src/main/js/api/quality-profiles.ts2
-rw-r--r--server/sonar-web/src/main/js/apps/projectQualityProfiles/App.tsx6
-rw-r--r--server/sonar-web/src/main/js/apps/projectQualityProfiles/__tests__/App-test.tsx14
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx27
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 = () => {