aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-07-19 16:38:48 +0200
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-07-25 09:20:30 +0200
commit1b282fb36a9f0387b526ac9d360b52c551942dae (patch)
tree7c22d6f65bdfa8ccf95ac3a2086185c8c922f70f /server/sonar-web
parent2e4e9ce93371a82532ffa2dc83b6ff47d6888abb (diff)
downloadsonarqube-1b282fb36a9f0387b526ac9d360b52c551942dae.tar.gz
sonarqube-1b282fb36a9f0387b526ac9d360b52c551942dae.zip
SONAR-9566, SONAR-9569 Update facets to only show items of the selected organization when doing a search
Diffstat (limited to 'server/sonar-web')
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/App.js6
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.js13
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.js43
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.js5
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.js9
-rw-r--r--server/sonar-web/src/main/js/apps/issues/utils.js6
6 files changed, 51 insertions, 31 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 48b6dbfcb0c..4e7d31c1ead 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
@@ -355,14 +355,11 @@ export default class App extends React.PureComponent {
s: 'FILE_LINE',
...serializeQuery(query),
ps: 100,
+ organization: organization && organization.key,
facets,
...additional
};
- if (organization) {
- parameters.organization = organization.key;
- }
-
// only sorting by CREATION_DATE is allowed, so let's sort DESC
if (query.sort) {
Object.assign(parameters, { asc: 'false' });
@@ -696,6 +693,7 @@ export default class App extends React.PureComponent {
onFacetToggle={this.handleFacetToggle}
onFilterChange={this.handleFilterChange}
openFacets={this.state.openFacets}
+ organization={this.props.organization}
query={query}
referencedComponents={this.state.referencedComponents}
referencedLanguages={this.state.referencedLanguages}
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.js b/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.js
index f20e721b0ec..20b3387486f 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.js
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.js
@@ -20,15 +20,15 @@
// @flow
import React from 'react';
import { sortBy, uniq, without } from 'lodash';
+import Avatar from '../../../components/ui/Avatar';
import FacetBox from './components/FacetBox';
import FacetHeader from './components/FacetHeader';
import FacetItem from './components/FacetItem';
import FacetItemsList from './components/FacetItemsList';
import FacetFooter from './components/FacetFooter';
import { searchAssignees } from '../utils';
-import type { ReferencedUser, Component } from '../utils';
-import Avatar from '../../../components/ui/Avatar';
import { translate } from '../../../helpers/l10n';
+import type { ReferencedUser, Component } from '../utils';
type Props = {|
assigned: boolean,
@@ -38,6 +38,7 @@ type Props = {|
onChange: (changes: {}) => void,
onToggle: (property: string) => void,
open: boolean,
+ organization?: { key: string },
stats?: { [string]: number },
referencedUsers: { [string]: ReferencedUser }
|};
@@ -73,7 +74,13 @@ export default class AssigneeFacet extends React.PureComponent {
this.props.onChange({ assigned: true, assignees: [] });
};
- handleSearch = (query: string) => searchAssignees(query, this.props.component);
+ handleSearch = (query: string) => {
+ let organization = this.props.component && this.props.component.organization;
+ if (this.props.organization && !organization) {
+ organization = this.props.organization.key;
+ }
+ return searchAssignees(query, organization);
+ };
handleSelect = (assignee: string) => {
const { assignees } = this.props;
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 e000234b6d4..843f659a275 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
@@ -37,6 +37,7 @@ type Props = {|
onChange: (changes: { [string]: Array<string> }) => void,
onToggle: (property: string) => void,
open: boolean,
+ organization?: { key: string },
stats?: { [string]: number },
referencedComponents: { [string]: ReferencedComponent },
projects: Array<string>
@@ -68,26 +69,28 @@ export default class ProjectFacet extends React.PureComponent {
};
handleSearch = (query: string) => {
- const { component } = this.props;
-
- return component != null && ['VW', 'SVW'].includes(component.qualifier)
- ? getTree(component.key, { ps: 50, q: query, qualifiers: 'TRK' }).then(response =>
- response.components.map(component => ({
- label: component.name,
- organization: component.organization,
- value: component.refId
- }))
- )
- : searchProjects({
- ps: 50,
- filter: query ? `query = "${query}"` : ''
- }).then(response =>
- response.components.map(component => ({
- label: component.name,
- organization: component.organization,
- value: component.id
- }))
- );
+ const { component, organization } = this.props;
+ if (component != null && ['VW', 'SVW'].includes(component.qualifier)) {
+ return getTree(component.key, { ps: 50, q: query, qualifiers: 'TRK' }).then(response =>
+ response.components.map(component => ({
+ label: component.name,
+ organization: component.organization,
+ value: component.refId
+ }))
+ );
+ }
+
+ return searchProjects({
+ ps: 50,
+ filter: query ? `query = "${query}"` : '',
+ organization: organization && organization.key
+ }).then(response =>
+ response.components.map(component => ({
+ label: component.name,
+ organization: component.organization,
+ value: component.id
+ }))
+ );
};
handleSelect = (rule: string) => {
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.js b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.js
index 5d9d8988c02..98e3cde5543 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.js
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.js
@@ -50,6 +50,7 @@ type Props = {|
onFacetToggle: (property: string) => void,
onFilterChange: (changes: { [string]: Array<string> }) => void,
openFacets: { [string]: boolean },
+ organization?: { key: string },
query: Query,
referencedComponents: { [string]: ReferencedComponent },
referencedLanguages: { [string]: ReferencedLanguage },
@@ -130,10 +131,12 @@ export default class Sidebar extends React.PureComponent {
rules={query.rules}
/>
<TagFacet
+ component={component}
facetMode={query.facetMode}
onChange={this.props.onFilterChange}
onToggle={this.props.onFacetToggle}
open={!!openFacets.tags}
+ organization={this.props.organization}
stats={facets.tags}
tags={query.tags}
/>
@@ -144,6 +147,7 @@ export default class Sidebar extends React.PureComponent {
onChange={this.props.onFilterChange}
onToggle={this.props.onFacetToggle}
open={!!openFacets.projects}
+ organization={this.props.organization}
projects={query.projects}
referencedComponents={this.props.referencedComponents}
stats={facets.projects}
@@ -185,6 +189,7 @@ export default class Sidebar extends React.PureComponent {
onChange={this.props.onFilterChange}
onToggle={this.props.onFacetToggle}
open={!!openFacets.assignees}
+ organization={this.props.organization}
assigned={query.assigned}
assignees={query.assignees}
referencedUsers={this.props.referencedUsers}
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.js b/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.js
index 319bf8df0eb..e979418cab0 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.js
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.js
@@ -27,12 +27,15 @@ import FacetItemsList from './components/FacetItemsList';
import FacetFooter from './components/FacetFooter';
import { searchIssueTags } from '../../../api/issues';
import { translate } from '../../../helpers/l10n';
+import type { Component } from '../utils';
type Props = {|
+ component?: Component,
facetMode: string,
onChange: (changes: { [string]: Array<string> }) => void,
onToggle: (property: string) => void,
open: boolean,
+ organization?: { key: string },
stats?: { [string]: number },
tags: Array<string>
|};
@@ -63,7 +66,11 @@ export default class TagFacet extends React.PureComponent {
};
handleSearch = (query: string) => {
- return searchIssueTags({ ps: 50, q: query }).then(tags =>
+ let organization = this.props.component && this.props.component.organization;
+ if (this.props.organization && !organization) {
+ organization = this.props.organization.key;
+ }
+ return searchIssueTags({ organization, ps: 50, q: query }).then(tags =>
tags.map(tag => ({ label: tag, value: tag }))
);
};
diff --git a/server/sonar-web/src/main/js/apps/issues/utils.js b/server/sonar-web/src/main/js/apps/issues/utils.js
index 72451971f7a..c3be4a5207b 100644
--- a/server/sonar-web/src/main/js/apps/issues/utils.js
+++ b/server/sonar-web/src/main/js/apps/issues/utils.js
@@ -192,9 +192,9 @@ export type CurrentUser =
| { isLoggedIn: false }
| { isLoggedIn: true, email?: string, login: string, name: string };
-export const searchAssignees = (query: string, component?: Component) => {
- return component
- ? searchMembers({ organization: component.organization, ps: 50, q: query }).then(response =>
+export const searchAssignees = (query: string, organization?: string) => {
+ return organization
+ ? searchMembers({ organization, ps: 50, q: query }).then(response =>
response.users.map(user => ({
avatar: user.avatar,
label: user.name,