diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2018-12-10 14:06:35 +0100 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-01-08 20:21:06 +0100 |
commit | f085494e7c0a846c4e293cd4cc07ccc87bbf9b82 (patch) | |
tree | 6287eb08a039e6a6376af43f0d9a83c4e8f1d5f6 /server/sonar-web/src/main/js/apps/quality-gates/components | |
parent | ceedfa6d9ad9239289e1e6d170b9400b7ec6b36a (diff) | |
download | sonarqube-f085494e7c0a846c4e293cd4cc07ccc87bbf9b82.tar.gz sonarqube-f085494e7c0a846c4e293cd4cc07ccc87bbf9b82.zip |
SONAR-11570 drop ability to set period from UI
Diffstat (limited to 'server/sonar-web/src/main/js/apps/quality-gates/components')
4 files changed, 3 insertions, 100 deletions
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.tsx index 6905dfb2b88..6b775c72712 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.tsx @@ -19,7 +19,6 @@ */ 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'; @@ -90,10 +89,6 @@ export default class Condition extends React.PureComponent<Props, State> { </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> diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx index 686450f80d8..e480bd53c91 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx @@ -21,10 +21,8 @@ import * as React from 'react'; 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'; @@ -44,7 +42,6 @@ interface State { errorMessage?: string; metric?: T.Metric; op?: string; - period: boolean; } export default class ConditionModal extends React.PureComponent<Props, State> { @@ -54,7 +51,6 @@ 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 }; @@ -69,21 +65,11 @@ export default class ConditionModal extends React.PureComponent<Props, State> { } 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 = () => { @@ -105,10 +91,6 @@ export default class ConditionModal extends React.PureComponent<Props, State> { this.setState({ metric }); }; - handlePeriodChange = (period: boolean) => { - this.setState({ period }); - }; - handleOperatorChange = (op: string) => { this.setState({ op }); }; @@ -119,7 +101,7 @@ export default class ConditionModal extends React.PureComponent<Props, State> { render() { const { header, metrics, onClose } = this.props; - const { period, op, error, metric } = this.state; + const { op, error, metric } = this.state; return ( <ConfirmModal confirmButtonText={header} @@ -140,15 +122,6 @@ export default class ConditionModal extends React.PureComponent<Props, State> { {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 canEdit={true} diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx index a1f169b9696..a61b6da38ff 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx @@ -56,9 +56,7 @@ export default class Conditions extends React.PureComponent<Props> { 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); } @@ -132,7 +130,6 @@ export default class Conditions extends React.PureComponent<Props> { /> </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 />} diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Period.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/Period.tsx deleted file mode 100644 index 3a0962d9da1..00000000000 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Period.tsx +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 || (() => {})} />; - } -} |