From 5d38b922a6a3976f9e8097c7cd3eac360006a905 Mon Sep 17 00:00:00 2001 From: Grégoire Aubert Date: Wed, 20 Sep 2017 11:48:54 +0200 Subject: Fix quality flaws --- .../apps/component-measures/sidebar/DomainFacet.js | 12 +++---- .../js/apps/issues/components/BulkChangeModal.js | 38 ++++------------------ 2 files changed, 13 insertions(+), 37 deletions(-) (limited to 'server/sonar-web/src') diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.js b/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.js index b3c62520459..4a0e1620798 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.js +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.js @@ -63,10 +63,14 @@ export default class DomainFacet extends React.PureComponent { return measureSelected || overviewSelected; }; + renderItemFacetStat = (item /*: MeasureEnhanced */) => + hasFacetStat(item.metric.key) ? : 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={ - {hasCategories ? ( - getLocalizedCategoryMetricName(item.metric) - ) : ( - getLocalizedMetricName(item.metric) - )} + {translateMetric(item.metric)} } onClick={this.props.onChange} - stat={hasFacetStat(item.metric.key) ? : null} + stat={this.renderItemFacetStat(item)} value={item.metric.key} /> ) diff --git a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.js b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.js index c1202812707..13de0c50c22 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.js +++ b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.js @@ -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 = ( - ); - - 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()} -- cgit v1.2.3