aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.js18
-rw-r--r--server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGate-test.js42
-rw-r--r--server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/QualityGate-test.js.snap34
-rw-r--r--server/sonar-web/src/main/less/init/misc.less2
-rw-r--r--sonar-core/src/main/resources/org/sonar/l10n/core.properties2
5 files changed, 96 insertions, 2 deletions
diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.js b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.js
index b840599b347..df5fbf0c801 100644
--- a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.js
+++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.js
@@ -23,6 +23,8 @@ import QualityGateConditions from './QualityGateConditions';
import EmptyQualityGate from './EmptyQualityGate';
import { translate } from '../../../helpers/l10n';
import Level from '../../../components/ui/Level';
+import Tooltip from '../../../components/controls/Tooltip';
+import HelpIcon from '../../../components/icons-components/HelpIcon';
/*:: import type { Component, MeasuresList } from '../types'; */
function parseQualityGateDetails(rawDetails /*: string */) {
@@ -52,8 +54,11 @@ export default function QualityGate({ branch, component, measures } /*: Props */
const level = statusMeasure.value;
let conditions = [];
+ let ignoredConditions = false;
if (detailsMeasure && detailsMeasure.value) {
- conditions = parseQualityGateDetails(detailsMeasure.value).conditions || [];
+ const details = parseQualityGateDetails(detailsMeasure.value);
+ conditions = details.conditions || [];
+ ignoredConditions = details.ignoredConditions;
}
return (
@@ -63,6 +68,17 @@ export default function QualityGate({ branch, component, measures } /*: Props */
<Level level={level} />
</h2>
+ {ignoredConditions && (
+ <div className="alert alert-info display-inline-block big-spacer-top">
+ {translate('overview.quality_gate.ignored_conditions')}
+ <Tooltip overlay={translate('overview.quality_gate.ignored_conditions.tooltip')}>
+ <span className="spacer-left">
+ <HelpIcon fill="#4b9fd5" />
+ </span>
+ </Tooltip>
+ </div>
+ )}
+
{conditions.length > 0 && (
<QualityGateConditions branch={branch} component={component} conditions={conditions} />
)}
diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGate-test.js b/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGate-test.js
new file mode 100644
index 00000000000..b21b1c67a16
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGate-test.js
@@ -0,0 +1,42 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import React from 'react';
+import { shallow } from 'enzyme';
+import QualityGate from '../QualityGate';
+
+it('renders message about ignored conditions', () => {
+ expect(
+ shallow(
+ <QualityGate
+ component={{ id: 'foo' }}
+ measures={[
+ {
+ metric: { key: 'alert_status' },
+ value: 'OK'
+ },
+ {
+ metric: { key: 'quality_gate_details' },
+ value: '{"level":"OK","conditions":[],"ignoredConditions":true}'
+ }
+ ]}
+ />
+ )
+ ).toMatchSnapshot();
+});
diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/QualityGate-test.js.snap b/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/QualityGate-test.js.snap
new file mode 100644
index 00000000000..13d1efdd295
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/QualityGate-test.js.snap
@@ -0,0 +1,34 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`renders message about ignored conditions 1`] = `
+<div
+ className="overview-quality-gate"
+ id="overview-quality-gate"
+>
+ <h2
+ className="overview-title"
+ >
+ overview.quality_gate
+ <Level
+ level="OK"
+ />
+ </h2>
+ <div
+ className="alert alert-info display-inline-block big-spacer-top"
+ >
+ overview.quality_gate.ignored_conditions
+ <Tooltip
+ overlay="overview.quality_gate.ignored_conditions.tooltip"
+ placement="bottom"
+ >
+ <span
+ className="spacer-left"
+ >
+ <HelpIcon
+ fill="#4b9fd5"
+ />
+ </span>
+ </Tooltip>
+ </div>
+</div>
+`;
diff --git a/server/sonar-web/src/main/less/init/misc.less b/server/sonar-web/src/main/less/init/misc.less
index ddca44d3771..c927347bea7 100644
--- a/server/sonar-web/src/main/less/init/misc.less
+++ b/server/sonar-web/src/main/less/init/misc.less
@@ -227,7 +227,7 @@ td.big-spacer-top {
}
.display-inline-block {
- display: inline-block;
+ display: inline-block !important;
}
.rounded {
diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
index 7d1eed01f40..69937115678 100644
--- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties
+++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
@@ -2239,6 +2239,8 @@ system.set_log_level=Set logs level
overview.quality_gate=Quality Gate
overview.quality_gate_x=Quality Gate: {0}
overview.you_should_define_quality_gate=You should define a quality gate on this project.
+overview.quality_gate.ignored_conditions=Some Quality Gate conditions on New Code were ignored because of the small number of New Lines
+overview.quality_gate.ignored_conditions.tooltip=At the start of a leak period, if very few lines have been added or modified, it might be difficult to reach the desired level of code coverage or duplications. To prevent Quality Gate failure when there's little that can be done about it, Quality Gate conditions about duplications in new code and coverage on new code are ignored until the number of new lines is at least 20.
overview.quality_profiles=Quality Profiles
overview.leak_period_x=Leak Period: {0}
overview.started_x=started {0}