]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10992 Make bugs, vulnerabilities and code smells default selection (#488)
authorStas Vilchik <stas.vilchik@sonarsource.com>
Fri, 6 Jul 2018 10:34:21 +0000 (12:34 +0200)
committerSonarTech <sonartech@sonarsource.com>
Tue, 17 Jul 2018 18:21:24 +0000 (20:21 +0200)
server/sonar-web/src/main/js/apps/issues/sidebar/ResolutionFacet.tsx
server/sonar-web/src/main/js/apps/issues/sidebar/TypeFacet.tsx
server/sonar-web/src/main/js/components/facet/FacetHeader.tsx

index e909d06372c1a01bfdfc832cbe874faeb4d676af..1a6163d9124323181b743a10952f21acf8335360 100644 (file)
@@ -116,6 +116,7 @@ export default class ResolutionFacet extends React.PureComponent<Props> {
     return (
       <FacetBox property={this.property}>
         <FacetHeader
+          clearLabel="reset_verb"
           name={translate('issues.facet', this.property)}
           onClear={this.handleClear}
           onClick={this.handleHeaderClick}
index 0cb0497549d566b57cec04dbb945a8596bde5f6e..62900a529a3c8ba3dbf7ba2589d369ecbd0b69cb 100644 (file)
@@ -70,8 +70,18 @@ export default class TypeFacet extends React.PureComponent<Props> {
     return stats ? stats[type] : undefined;
   }
 
+  isFacetItemActive(type: string) {
+    const { types } = this.props;
+    return (
+      // type is selected explicitly
+      types.includes(type) ||
+      // bugs, vulnerabilities and code smells are selected implicitly by default
+      (types.length === 0 && ['BUG', 'VULNERABILITY', 'CODE_SMELL'].includes(type))
+    );
+  }
+
   renderItem = (type: string) => {
-    const active = this.props.types.includes(type);
+    const active = this.isFacetItemActive(type);
     const stat = this.getStat(type);
 
     return (
@@ -100,6 +110,7 @@ export default class TypeFacet extends React.PureComponent<Props> {
     return (
       <FacetBox property={this.property}>
         <FacetHeader
+          clearLabel="reset_verb"
           name={translate('issues.facet', this.property)}
           onClear={this.handleClear}
           onClick={this.handleHeaderClick}
index f4544cf5028d7cc493296857628fd773d031782c..0c49627838192eec47ba8dfd929878f8cee7c456 100644 (file)
@@ -25,6 +25,7 @@ import { translate, translateWithParameters } from '../../helpers/l10n';
 
 interface Props {
   children?: React.ReactNode;
+  clearLabel?: string;
   helper?: string;
   name: React.ReactNode;
   onClear?: () => void;
@@ -94,7 +95,7 @@ export default class FacetHeader extends React.PureComponent<Props> {
           <Button
             className="search-navigator-facet-header-button button-small button-red"
             onClick={this.props.onClear}>
-            {translate('clear')}
+            {translate(this.props.clearLabel || 'clear')}
           </Button>
         )}
       </div>