]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9118 Fix issue project facet and organization name in front of issue
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Fri, 5 May 2017 12:45:05 +0000 (14:45 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Tue, 9 May 2017 09:15:45 +0000 (11:15 +0200)
server/sonar-web/src/main/js/apps/issues/components/AppContainer.js
server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.js
server/sonar-web/src/main/js/apps/projects/store/utils.js

index b654ce9687c584597adf3f74517d81a08506f577..3b2ce07843805ad1e2acd49688a57cd5e6387096 100644 (file)
 import { connect } from 'react-redux';
 import { withRouter } from 'react-router';
 import type { Dispatch } from 'redux';
+import { uniq } from 'lodash';
 import App from './App';
 import { onFail } from '../../../store/rootActions';
 import { getComponent, getCurrentUser } from '../../../store/rootReducer';
+import { getOrganizations } from '../../../api/organizations';
+import { receiveOrganizations } from '../../../store/organizations/duck';
 import { searchIssues } from '../../../api/issues';
 import { parseIssueFromResponse } from '../../../helpers/issues';
 
@@ -36,13 +39,28 @@ const mapStateToProps = (state, ownProps) => ({
   currentUser: getCurrentUser(state)
 });
 
-const fetchIssues = (query: Query) => (dispatch: Dispatch<*>) =>
-  searchIssues({ ...query, additionalFields: '_all' }).then(response => {
-    const parsedIssues = response.issues.map(issue =>
-      parseIssueFromResponse(issue, response.components, response.users, response.rules)
-    );
-    return { ...response, issues: parsedIssues };
-  }, onFail(dispatch));
+const fetchIssueOrganizations = issues => dispatch => {
+  if (!issues.length) {
+    return Promise.resolve();
+  }
+
+  const organizationKeys = uniq(issues.map(issue => issue.organization));
+  return getOrganizations(organizationKeys).then(
+    response => dispatch(receiveOrganizations(response.organizations)),
+    onFail(dispatch)
+  );
+};
+
+const fetchIssues = (query: Query) => dispatch =>
+  searchIssues({ ...query, additionalFields: '_all' })
+    .then(response => {
+      const parsedIssues = response.issues.map(issue =>
+        parseIssueFromResponse(issue, response.components, response.users, response.rules)
+      );
+      return { ...response, issues: parsedIssues };
+    })
+    .then(response => dispatch(fetchIssueOrganizations(response.issues)).then(() => response))
+    .catch(onFail(dispatch));
 
 const onRequestFail = (error: Error) => (dispatch: Dispatch<*>) => onFail(dispatch)(error);
 
index 0fe8bc84ffbd35a366d0ef8675744c2c802d9974..d7b7becca9f82f699d3f460798e50799330d644f 100644 (file)
@@ -28,7 +28,7 @@ import FacetFooter from './components/FacetFooter';
 import type { ReferencedComponent, Component } from '../utils';
 import Organization from '../../../components/shared/Organization';
 import QualifierIcon from '../../../components/shared/QualifierIcon';
-import { searchComponents, getTree } from '../../../api/components';
+import { searchProjects, getTree } from '../../../api/components';
 import { translate } from '../../../helpers/l10n';
 
 type Props = {|
@@ -78,7 +78,10 @@ export default class ProjectFacet extends React.PureComponent {
             value: component.refId
           }))
         )
-      : searchComponents({ ps: 50, q: query, qualifiers: 'TRK' }).then(response =>
+      : searchProjects({
+          ps: 50,
+          filter: query ? `query = "${query}"` : ''
+        }).then(response =>
           response.components.map(component => ({
             label: component.name,
             organization: component.organization,
index 23424ee23ac8811317e843c590af8698386cc0a2..8cba5d71531a9bad6c48049e0820e5ced5d67e97 100644 (file)
@@ -161,7 +161,7 @@ const convertSize = size => {
   }
 };
 
-const convertToFilter = (query, isFavorite) => {
+export const convertToFilter = (query, isFavorite) => {
   const conditions = [];
 
   if (isFavorite) {