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 */) {
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 (
<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} />
)}
--- /dev/null
+/*
+ * 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();
+});
--- /dev/null
+// 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>
+`;
}
.display-inline-block {
- display: inline-block;
+ display: inline-block !important;
}
.rounded {
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}