]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Wed, 20 Sep 2017 09:48:54 +0000 (11:48 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Mon, 25 Sep 2017 11:18:37 +0000 (13:18 +0200)
server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.js
server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.js

index b3c6252045900f3882276be4158a2177b166431b..4a0e1620798b3a16cf9b4f6531798eab046ca0d8 100644 (file)
@@ -63,10 +63,14 @@ export default class DomainFacet extends React.PureComponent {
     return measureSelected || overviewSelected;
   };
 
+  renderItemFacetStat = (item /*: MeasureEnhanced */) =>
+    hasFacetStat(item.metric.key) ? <FacetMeasureValue measure={item} /> : null;
+
   renderItemsFacet = () => {
     const { domain, selected } = this.props;
     const items = addMeasureCategories(domain.name, filterMeasures(domain.measures));
     const hasCategories = items.some(item => typeof item === 'string');
+    const translateMetric = hasCategories ? getLocalizedCategoryMetricName : getLocalizedMetricName;
     const sortedItems = sortMeasures(domain.name, items);
     return sortedItems.map(
       item =>
@@ -83,15 +87,11 @@ export default class DomainFacet extends React.PureComponent {
             key={item.metric.key}
             name={
               <span className="big-spacer-left" id={`measure-${item.metric.key}-name`}>
-                {hasCategories ? (
-                  getLocalizedCategoryMetricName(item.metric)
-                ) : (
-                  getLocalizedMetricName(item.metric)
-                )}
+                {translateMetric(item.metric)}
               </span>
             }
             onClick={this.props.onChange}
-            stat={hasFacetStat(item.metric.key) ? <FacetMeasureValue measure={item} /> : null}
+            stat={this.renderItemFacetStat(item)}
             value={item.metric.key}
           />
         )
index c120281270731cb39cac7f08973eecc153f9c6d0..13de0c50c228aa8c874bac0abdff9760ae647ab3 100644 (file)
@@ -368,7 +368,7 @@ export default class BulkChangeModal extends React.PureComponent {
     return this.renderField('severity', 'issue.set_severity', affected, input);
   };
 
-  renderAddTagsField = () => {
+  renderTagsField = (field /*: string */, label /*: string */) => {
     const affected /*: number */ = this.state.issues.filter(hasAction('set_tags')).length;
 
     if (this.state.tags == null || affected === 0) {
@@ -380,40 +380,16 @@ export default class BulkChangeModal extends React.PureComponent {
     const input = (
       <Select
         clearable={false}
-        id="add_tags"
+        id={field}
         multi={true}
-        onChange={this.handleMultiSelectFieldChange('addTags')}
+        onChange={this.handleMultiSelectFieldChange(field)}
         options={options}
         searchable={true}
-        value={this.state.addTags}
+        value={this.state[field]}
       />
     );
 
-    return this.renderField('addTags', 'issue.add_tags', affected, input);
-  };
-
-  renderRemoveTagsField = () => {
-    const affected /*: number */ = this.state.issues.filter(hasAction('set_tags')).length;
-
-    if (this.state.tags == null || affected === 0) {
-      return null;
-    }
-
-    const options = this.state.tags.map(tag => ({ label: tag, value: tag }));
-
-    const input = (
-      <Select
-        clearable={false}
-        id="remove_tags"
-        multi={true}
-        onChange={this.handleMultiSelectFieldChange('removeTags')}
-        options={options}
-        searchable={true}
-        value={this.state.removeTags}
-      />
-    );
-
-    return this.renderField('removeTags', 'issue.remove_tags', affected, input);
+    return this.renderField(field, label, affected, input);
   };
 
   renderTransitionsField = () => {
@@ -509,8 +485,8 @@ export default class BulkChangeModal extends React.PureComponent {
           {this.renderAssigneeField()}
           {this.renderTypeField()}
           {this.renderSeverityField()}
-          {this.renderAddTagsField()}
-          {this.renderRemoveTagsField()}
+          {this.renderTagsField('addTags', 'issue.add_tags')}
+          {this.renderTagsField('removeTags', 'issue.remove_tags')}
           {this.renderTransitionsField()}
           {this.renderCommentField()}
           {this.renderNotificationsField()}