]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9403 Add information message when selecting a metric to build a custom graph
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Mon, 10 Jul 2017 13:51:33 +0000 (15:51 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Thu, 13 Jul 2017 12:34:17 +0000 (14:34 +0200)
server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddGraphMetric.js
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 8d8b861fd2484b45b40f31650626a5a05b27956b..847a41ff8ee211672229bcc718117482c91c3386 100644 (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">
index 78886e2d67bc42976e7e6cf33703651de84305de..70928d877468dc0092ca681a2fcda4c2b874d27f 100644 (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