]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9566, SONAR-9569 Update facets to only show items of the selected organization...
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Wed, 19 Jul 2017 14:38:48 +0000 (16:38 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Tue, 25 Jul 2017 07:20:30 +0000 (09:20 +0200)
server/sonar-web/src/main/js/apps/issues/components/App.js
server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.js
server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.js
server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.js
server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.js
server/sonar-web/src/main/js/apps/issues/utils.js

index 48b6dbfcb0c58e477194485c4cb783ce39b5b4b7..4e7d31c1ead58c719fb711fce829f0c7758c2204 100644 (file)
@@ -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}
index f20e721b0ecc636a97dec9aaa3253503633a3c89..20b3387486fced66f50060ae568ae303bc0e9f36 100644 (file)
 // @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;
index e000234b6d465c99d85901e828539a8d84d1bd29..843f659a275ea23bf249ef5d28f8008b1e9e601d 100644 (file)
@@ -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) => {
index 5d9d8988c026e0a9fd4d35a4243947a20c5f8365..98e3cde5543a1ea5012454d7cda8e8bbe37c1c04 100644 (file)
@@ -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}
index 319bf8df0ebe91dd4ee7964cb30d2e5a4dbfd169..e979418cab00c29d78943620f5f54c0d8f1cd16b 100644 (file)
@@ -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 }))
     );
   };
index 72451971f7a991d6f5967b28cb5c571f5e4d4ec9..c3be4a5207baa81e19e44c32bcf6ce600c67d336 100644 (file)
@@ -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,