aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-05-05 14:45:05 +0200
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-05-09 11:15:45 +0200
commit464e95be6c8d4ed4e83dd4811b332047ec6dfee5 (patch)
treea4394c480a061dd86a30077f9193591ff6cc0759 /server/sonar-web/src/main/js/apps
parentfbdda573c5f20a65c86767f6b7828c99dd1e9774 (diff)
downloadsonarqube-464e95be6c8d4ed4e83dd4811b332047ec6dfee5.tar.gz
sonarqube-464e95be6c8d4ed4e83dd4811b332047ec6dfee5.zip
SONAR-9118 Fix issue project facet and organization name in front of issue
Diffstat (limited to 'server/sonar-web/src/main/js/apps')
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/AppContainer.js32
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.js7
-rw-r--r--server/sonar-web/src/main/js/apps/projects/store/utils.js2
3 files changed, 31 insertions, 10 deletions
diff --git a/server/sonar-web/src/main/js/apps/issues/components/AppContainer.js b/server/sonar-web/src/main/js/apps/issues/components/AppContainer.js
index b654ce9687c..3b2ce078438 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/AppContainer.js
+++ b/server/sonar-web/src/main/js/apps/issues/components/AppContainer.js
@@ -21,9 +21,12 @@
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);
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.js b/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.js
index 0fe8bc84ffb..d7b7becca9f 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.js
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.js
@@ -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,
diff --git a/server/sonar-web/src/main/js/apps/projects/store/utils.js b/server/sonar-web/src/main/js/apps/projects/store/utils.js
index 23424ee23ac..8cba5d71531 100644
--- a/server/sonar-web/src/main/js/apps/projects/store/utils.js
+++ b/server/sonar-web/src/main/js/apps/projects/store/utils.js
@@ -161,7 +161,7 @@ const convertSize = size => {
}
};
-const convertToFilter = (query, isFavorite) => {
+export const convertToFilter = (query, isFavorite) => {
const conditions = [];
if (isFavorite) {