]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10843 Projects facet does not show all organizations
authorStas Vilchik <stas.vilchik@sonarsource.com>
Fri, 1 Jun 2018 15:21:13 +0000 (17:21 +0200)
committerSonarTech <sonartech@sonarsource.com>
Mon, 4 Jun 2018 18:20:50 +0000 (20:20 +0200)
server/sonar-web/src/main/js/api/issues.ts
server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx

index f5ec6453bccccb80dd707a00e3461463b0926d80..80a02c70f05e47ad0e7f5a22f422ff07ca0b4d52 100644 (file)
@@ -30,7 +30,7 @@ export interface IssueResponse {
 }
 
 interface IssuesResponse {
-  components?: { key: string; name: string; uuid: string }[];
+  components?: { key: string; organization: string; name: string; uuid: string }[];
   debtTotal?: number;
   facets: Array<{
     property: string;
index 4e92ea5c959253ebf1ea4d46bb24c6716dfdd72a..8ef800732185d045f47a668527856fe2999c7190 100644 (file)
@@ -22,7 +22,7 @@ import { Dispatch } from 'redux';
 import { uniq } from 'lodash';
 import { searchIssues } from '../../../api/issues';
 import { getOrganizations } from '../../../api/organizations';
-import { CurrentUser, Issue } from '../../../app/types';
+import { CurrentUser } from '../../../app/types';
 import throwGlobalError from '../../../app/utils/throwGlobalError';
 import {
   getCurrentUser,
@@ -47,12 +47,11 @@ const mapStateToProps = (state: any): StateProps => {
   };
 };
 
-const fetchIssueOrganizations = (issues: Issue[]) => (dispatch: Dispatch<any>) => {
-  if (!issues.length) {
+const fetchIssueOrganizations = (organizationKeys: string[]) => (dispatch: Dispatch<any>) => {
+  if (!organizationKeys.length) {
     return Promise.resolve();
   }
 
-  const organizationKeys = uniq(issues.map(issue => issue.organization));
   return getOrganizations({ organizations: organizationKeys.join() }).then(
     response => dispatch(receiveOrganizations(response.organizations)),
     throwGlobalError
@@ -73,8 +72,12 @@ const fetchIssues = (query: RawQuery, requestOrganizations = true) => (
       return { ...response, issues: parsedIssues };
     })
     .then(response => {
+      const organizationKeys = uniq([
+        ...response.issues.map(issue => issue.organization),
+        ...(response.components || []).map(component => component.organization)
+      ]);
       return organizationsEnabled && requestOrganizations
-        ? dispatch(fetchIssueOrganizations(response.issues)).then(() => response)
+        ? dispatch(fetchIssueOrganizations(organizationKeys)).then(() => response)
         : response;
     })
     .catch(throwGlobalError);