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 =>
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}
/>
)
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) {
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 = () => {
{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()}