From: Stas Vilchik Date: Fri, 1 Jun 2018 15:21:13 +0000 (+0200) Subject: SONAR-10843 Projects facet does not show all organizations X-Git-Tag: 7.5~1101 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d9591923fcffc90a24eee16af6a585bee25f18d7;p=sonarqube.git SONAR-10843 Projects facet does not show all organizations --- diff --git a/server/sonar-web/src/main/js/api/issues.ts b/server/sonar-web/src/main/js/api/issues.ts index f5ec6453bcc..80a02c70f05 100644 --- a/server/sonar-web/src/main/js/api/issues.ts +++ b/server/sonar-web/src/main/js/api/issues.ts @@ -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; diff --git a/server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx b/server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx index 4e92ea5c959..8ef80073218 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx @@ -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) => { - if (!issues.length) { +const fetchIssueOrganizations = (organizationKeys: string[]) => (dispatch: Dispatch) => { + 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);