Browse Source

SONAR-9403 Add information message when selecting a metric to build a custom graph

tags/6.5-RC1
Grégoire Aubert 7 years ago
parent
commit
faaee054e8

+ 11
- 4
server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddGraphMetric.js View File

@@ -22,7 +22,7 @@ import React from 'react';
import Modal from 'react-modal';
import Select from 'react-select';
import { isDiffMetric } from '../../../../helpers/measures';
import { translate } from '../../../../helpers/l10n';
import { translate, translateWithParameters } from '../../../../helpers/l10n';
import type { Metric } from '../../types';

type Props = {
@@ -52,8 +52,7 @@ export default class AddGraphMetric extends React.PureComponent {
}
};

getMetricsOptions = () => {
const selectedType = this.getMetricsType();
getMetricsOptions = (selectedType: ?string) => {
return this.props.metrics
.filter(metric => {
if (metric.hidden || isDiffMetric(metric.key)) {
@@ -95,6 +94,7 @@ export default class AddGraphMetric extends React.PureComponent {
};

renderModal() {
const metricType = this.getMetricsType();
return (
<Modal
isOpen={true}
@@ -115,11 +115,18 @@ export default class AddGraphMetric extends React.PureComponent {
clearable={false}
noResultsText={translate('no_results')}
onChange={this.handleChange}
options={this.getMetricsOptions()}
options={this.getMetricsOptions(metricType)}
placeholder=""
searchable={true}
value={this.state.selectedMetric}
/>
{metricType != null &&
<span className="note">
{translateWithParameters(
'project_activity.graphs.custom.type_x_message',
translate('metric.type', metricType)
)}
</span>}
</div>
</div>
<footer className="modal-foot">

+ 1
- 0
sonar-core/src/main/resources/org/sonar/l10n/core.properties View File

@@ -1292,6 +1292,7 @@ project_activity.graphs.custom.add=Add metric
project_activity.graphs.custom.add_metric=Add a metric
project_activity.graphs.custom.no_history=There is no historical data to show, please add more metrics to your graph.
project_activity.graphs.custom.search=Search for a metric by name
project_activity.graphs.custom.type_x_message=Only "{0}" metrics are available with your current selection.

project_activity.custom_metric.covered_lines=Covered Lines


Loading…
Cancel
Save