diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-10-18 10:16:33 +0200 |
---|---|---|
committer | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-10-19 11:07:32 +0200 |
commit | 439ea68c8cdb11a1d56cad9dd5c9e9dc5afd9c25 (patch) | |
tree | 75f58eba610ed54f05d5bca03bd8d3577c007d00 /server/sonar-web/src/main/js/apps/issues | |
parent | a5924775906ba082f6415423f460f762c6c3de02 (diff) | |
download | sonarqube-439ea68c8cdb11a1d56cad9dd5c9e9dc5afd9c25.tar.gz sonarqube-439ea68c8cdb11a1d56cad9dd5c9e9dc5afd9c25.zip |
avoid requesting organizations when issues facet opens
Diffstat (limited to 'server/sonar-web/src/main/js/apps/issues')
-rw-r--r-- | server/sonar-web/src/main/js/apps/issues/components/App.js | 13 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/apps/issues/components/AppContainer.js | 17 |
2 files changed, 22 insertions, 8 deletions
diff --git a/server/sonar-web/src/main/js/apps/issues/components/App.js b/server/sonar-web/src/main/js/apps/issues/components/App.js index cf11407a64b..c11071c20de 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/App.js +++ b/server/sonar-web/src/main/js/apps/issues/components/App.js @@ -69,7 +69,7 @@ export type Props = { branch?: { name: string }, component?: Component, currentUser: CurrentUser, - fetchIssues: (query: RawQuery) => Promise<*>, + fetchIssues: (query: RawQuery, requestOrganizations?: boolean) => Promise<*>, location: { pathname: string, query: RawQuery }, organization?: { key: string }, router: { @@ -367,7 +367,11 @@ export default class App extends React.PureComponent { } }; - fetchIssues = (additional /*: ?{} */, requestFacets /*: ?boolean */ = false) => { + fetchIssues = ( + additional /*: ?{} */, + requestFacets /*: ?boolean */ = false, + requestOrganizations /*: boolean | void */ = true + ) => { const { component, organization } = this.props; const { myIssues, openFacets, query } = this.state; @@ -398,7 +402,7 @@ export default class App extends React.PureComponent { Object.assign(parameters, { assignees: '__me__' }); } - return this.props.fetchIssues(parameters); + return this.props.fetchIssues(parameters, requestOrganizations); }; fetchFirstIssues() { @@ -527,7 +531,8 @@ export default class App extends React.PureComponent { }; fetchFacet = (facet /*: string */) => { - return this.fetchIssues({ ps: 1, facets: mapFacet(facet) }).then( + const requestOrganizations = facet === 'projects'; + return this.fetchIssues({ ps: 1, facets: mapFacet(facet) }, false, requestOrganizations).then( ({ facets, ...other }) => { if (this.mounted) { this.setState(state => ({ 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 2f6b4368a87..c7c6608573f 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 @@ -24,7 +24,7 @@ import { withRouter } from 'react-router'; import { uniq } from 'lodash'; import App from './App'; import throwGlobalError from '../../../app/utils/throwGlobalError'; -import { getCurrentUser } from '../../../store/rootReducer'; +import { getCurrentUser, areThereCustomOrganizations } from '../../../store/rootReducer'; import { getOrganizations } from '../../../api/organizations'; import { receiveOrganizations } from '../../../store/organizations/duck'; import { searchIssues } from '../../../api/issues'; @@ -47,16 +47,25 @@ const fetchIssueOrganizations = issues => dispatch => { ); }; -const fetchIssues = (query /*: RawQuery */) => dispatch => - searchIssues({ ...query, additionalFields: '_all' }) +const fetchIssues = (query /*: RawQuery */, requestOrganizations /*: boolean */ = true) => ( + dispatch, + getState +) => { + const organizationsEnabled = areThereCustomOrganizations(getState()); + return 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)) + .then(response => { + return organizationsEnabled && requestOrganizations + ? dispatch(fetchIssueOrganizations(response.issues)).then(() => response) + : response; + }) .catch(throwGlobalError); +}; const mapDispatchToProps = { fetchIssues }; |