aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/quality-gates
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2016-05-10 13:50:00 +0200
committerStas Vilchik <vilchiks@gmail.com>2016-05-10 13:50:10 +0200
commit0466aed036d04c8509374dcd5d2fd3da123c136e (patch)
tree10e34733ba4fd7b091aa8f52868cb9d44cfbc4fd /server/sonar-web/src/main/js/apps/quality-gates
parentaf746806513116025cfea334ad2debfa0f5c34e2 (diff)
downloadsonarqube-0466aed036d04c8509374dcd5d2fd3da123c136e.tar.gz
sonarqube-0466aed036d04c8509374dcd5d2fd3da123c136e.zip
SONAR-6336 display warning when duplicated conditions used
Diffstat (limited to 'server/sonar-web/src/main/js/apps/quality-gates')
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.js b/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.js
index 66672a19c4a..2a23c6d3429 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.js
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.js
@@ -19,6 +19,7 @@
*/
import _ from 'underscore';
import React from 'react';
+import uniqBy from 'lodash/uniqBy';
import ConditionsAlert from './ConditionsAlert';
import AddConditionForm from './AddConditionForm';
@@ -45,6 +46,22 @@ export default function Conditions (
return metrics.find(metric => metric.key === condition.metric).name;
});
+ const duplicates = [];
+ conditions.forEach(condition => {
+ const sameCount = conditions
+ .filter(sample => sample.metric === condition.metric && sample.period === condition.period)
+ .length;
+ if (sameCount > 1) {
+ duplicates.push(condition);
+ }
+ });
+
+ const uniqDuplicates = uniqBy(duplicates, d => d.metric)
+ .map(condition => {
+ const metric = metrics.find(metric => metric.key === condition.metric);
+ return { ...condition, metric };
+ });
+
return (
<div id="quality-gate-conditions" className="quality-gate-section">
<h3 className="spacer-bottom">
@@ -53,6 +70,17 @@ export default function Conditions (
<ConditionsAlert/>
+ {uniqDuplicates.length > 0 && (
+ <div className="alert alert-warning">
+ <p>{translate('quality_gates.duplicated_conditions')}</p>
+ <ul className="list-styled spacer-top">
+ {uniqDuplicates.map(d => (
+ <li>{d.metric.name}</li>
+ ))}
+ </ul>
+ </div>
+ )}
+
{sortedConditions.length ? (
<table id="quality-gate-conditions" className="data zebra zebra-hover">
<thead>