aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-09-20 11:48:54 +0200
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-09-25 13:18:37 +0200
commit5d38b922a6a3976f9e8097c7cd3eac360006a905 (patch)
tree09fb92577344f7dbf40ae7b283dc2243981bf90a /server/sonar-web/src
parent95b1981ba64f1cd37ef680eeec539a793305c4a7 (diff)
downloadsonarqube-5d38b922a6a3976f9e8097c7cd3eac360006a905.tar.gz
sonarqube-5d38b922a6a3976f9e8097c7cd3eac360006a905.zip
Fix quality flaws
Diffstat (limited to 'server/sonar-web/src')
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.js12
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.js38
2 files changed, 13 insertions, 37 deletions
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) ? <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}
/>
)
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 = (
<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()}