id: number;
metric: string;
op?: string;
- period?: number;
}
export interface CoveredFile {
*/
import * as React from 'react';
import ConditionOperator from './ConditionOperator';
-import Period from './Period';
import ConditionModal from './ConditionModal';
import ActionsDropdown, { ActionsDropdownItem } from '../../../components/controls/ActionsDropdown';
import { translate, getLocalizedMetricName, translateWithParameters } from '../../../helpers/l10n';
)}
</td>
- <td className="thin text-middle nowrap">
- <Period canEdit={false} metric={metric} period={condition.period === 1} />
- </td>
-
<td className="thin text-middle nowrap">
<ConditionOperator canEdit={false} metric={metric} op={condition.op} />
</td>
import AddConditionSelect from './AddConditionSelect';
import ConditionOperator from './ConditionOperator';
import ThresholdInput from './ThresholdInput';
-import Period from './Period';
import { translate, getLocalizedMetricName } from '../../../helpers/l10n';
import { createCondition, updateCondition } from '../../../api/quality-gates';
-import { isDiffMetric } from '../../../helpers/measures';
import ConfirmModal from '../../../components/controls/ConfirmModal';
import { Alert } from '../../../components/ui/Alert';
errorMessage?: string;
metric?: T.Metric;
op?: string;
- period: boolean;
}
export default class ConditionModal extends React.PureComponent<Props, State> {
super(props);
this.state = {
error: props.condition ? props.condition.error : '',
- period: props.condition ? props.condition.period === 1 : false,
metric: props.metric ? props.metric : undefined,
op: props.condition ? props.condition.op : undefined
};
}
getUpdatedCondition = (metric: T.Metric) => {
- const data: T.Omit<T.Condition, 'id'> = {
+ return {
metric: metric.key,
op: metric.type === 'RATING' ? 'GT' : this.state.op,
error: this.state.error
};
-
- const { period } = this.state;
- if (period && metric.type !== 'RATING') {
- data.period = period ? 1 : 0;
- }
-
- if (isDiffMetric(metric.key)) {
- data.period = 1;
- }
- return data;
};
handleFormSubmit = () => {
this.setState({ metric });
};
- handlePeriodChange = (period: boolean) => {
- this.setState({ period });
- };
-
handleOperatorChange = (op: string) => {
this.setState({ op });
};
render() {
const { header, metrics, onClose } = this.props;
- const { period, op, error, metric } = this.state;
+ const { op, error, metric } = this.state;
return (
<ConfirmModal
confirmButtonText={header}
</div>
{metric && (
<>
- <div className="modal-field">
- <label>{translate('quality_gates.conditions.new_code')}</label>
- <Period
- canEdit={true}
- metric={metric}
- onPeriodChange={this.handlePeriodChange}
- period={period}
- />
- </div>
<div className="modal-field">
<label>{translate('quality_gates.conditions.operator')}</label>
<ConditionOperator
const duplicates: T.Condition[] = [];
const savedConditions = existingConditions.filter(condition => condition.id != null);
savedConditions.forEach(condition => {
- const sameCount = savedConditions.filter(
- sample => sample.metric === condition.metric && sample.period === condition.period
- ).length;
+ const sameCount = savedConditions.filter(sample => sample.metric === condition.metric).length;
if (sameCount > 1) {
duplicates.push(condition);
}
/>
</div>
</th>
- <th className="thin nowrap">{translate('quality_gates.conditions.new_code')}</th>
<th className="thin nowrap">{translate('quality_gates.conditions.operator')}</th>
<th className="thin nowrap">{translate('quality_gates.conditions.error')}</th>
{canEdit && <th />}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2019 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 * as React from 'react';
-import Checkbox from '../../../components/controls/Checkbox';
-import { isDiffMetric } from '../../../helpers/measures';
-import { translate } from '../../../helpers/l10n';
-
-interface Props {
- canEdit: boolean;
- metric: T.Metric;
- onPeriodChange?: (checked: boolean) => void;
- period: boolean;
-}
-
-export default class Period extends React.PureComponent<Props> {
- renderPeriodValue() {
- const { metric, period } = this.props;
- const isRating = metric.type === 'RATING';
-
- if (isDiffMetric(metric.key)) {
- return (
- <span className="note">{translate('quality_gates.condition.leak.unconditional')}</span>
- );
- }
-
- if (isRating) {
- return <span className="note">{translate('quality_gates.condition.leak.never')}</span>;
- }
-
- return period
- ? translate('quality_gates.condition.leak.yes')
- : translate('quality_gates.condition.leak.no');
- }
-
- render() {
- const { canEdit, metric, onPeriodChange, period } = this.props;
- const isRating = metric && metric.type === 'RATING';
-
- if (isRating || isDiffMetric(metric.key) || !canEdit) {
- return this.renderPeriodValue();
- }
-
- return <Checkbox checked={period} onCheck={onPeriodChange || (() => {})} />;
- }
-}
quality_gates.projects=Projects
quality_gates.add_condition=Add Condition
quality_gates.update_condition=Update Condition
-quality_gates.condition.leak.never=Never
quality_gates.no_conditions=No Conditions
quality_gates.introduction=Only project measures are checked against thresholds. Sub-projects, directories and files are ignored.
quality_gates.health_icons=Project health icons represent:
quality_gates.delete.confirm.default=Are you sure you want to delete the "{0}" quality gate, which is the default quality gate?
quality_gates.delete_condition=Delete Condition
quality_gates.delete_condition.confirm.message=Are you sure you want to delete the "{0}" condition?
-quality_gates.condition.leak.yes=Yes
-quality_gates.condition.leak.no=No
-quality_gates.condition.leak.unconditional=Always
quality_gates.conditions.metric=Metric
quality_gates.conditions.new_code=On New Code
quality_gates.conditions.operator=Operator