From f085494e7c0a846c4e293cd4cc07ccc87bbf9b82 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Mon, 10 Dec 2018 14:06:35 +0100 Subject: [PATCH] SONAR-11570 drop ability to set period from UI --- server/sonar-web/src/main/js/app/types.d.ts | 1 - .../quality-gates/components/Condition.tsx | 5 -- .../components/ConditionModal.tsx | 31 +--------- .../quality-gates/components/Conditions.tsx | 5 +- .../apps/quality-gates/components/Period.tsx | 62 ------------------- .../resources/org/sonar/l10n/core.properties | 4 -- 6 files changed, 3 insertions(+), 105 deletions(-) delete mode 100644 server/sonar-web/src/main/js/apps/quality-gates/components/Period.tsx diff --git a/server/sonar-web/src/main/js/app/types.d.ts b/server/sonar-web/src/main/js/app/types.d.ts index 4fb1cfccffe..52e7ee1fd13 100644 --- a/server/sonar-web/src/main/js/app/types.d.ts +++ b/server/sonar-web/src/main/js/app/types.d.ts @@ -181,7 +181,6 @@ declare namespace T { id: number; metric: string; op?: string; - period?: number; } export interface CoveredFile { 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'; @@ -89,10 +88,6 @@ export default class Condition extends React.PureComponent { )} - - - - 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 { @@ -54,7 +51,6 @@ export default class ConditionModal extends React.PureComponent { 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 { } getUpdatedCondition = (metric: T.Metric) => { - const data: T.Omit = { + 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 { 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 { render() { const { header, metrics, onClose } = this.props; - const { period, op, error, metric } = this.state; + const { op, error, metric } = this.state; return ( { {metric && ( <> -
- - -
{ 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 { />
- {translate('quality_gates.conditions.new_code')} {translate('quality_gates.conditions.operator')} {translate('quality_gates.conditions.error')} {canEdit && } 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 { - renderPeriodValue() { - const { metric, period } = this.props; - const isRating = metric.type === 'RATING'; - - if (isDiffMetric(metric.key)) { - return ( - {translate('quality_gates.condition.leak.unconditional')} - ); - } - - if (isRating) { - return {translate('quality_gates.condition.leak.never')}; - } - - 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 {})} />; - } -} 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 015c3b7265d..d13743b6434 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1228,7 +1228,6 @@ quality_gates.conditions=Conditions 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: @@ -1255,9 +1254,6 @@ quality_gates.delete.confirm.message=Are you sure you want to delete the "{0}" q 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 -- 2.39.5