]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11570 drop ability to set period from UI
authorStas Vilchik <stas.vilchik@sonarsource.com>
Mon, 10 Dec 2018 13:06:35 +0000 (14:06 +0100)
committerSonarTech <sonartech@sonarsource.com>
Tue, 8 Jan 2019 19:21:06 +0000 (20:21 +0100)
server/sonar-web/src/main/js/app/types.d.ts
server/sonar-web/src/main/js/apps/quality-gates/components/Condition.tsx
server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx
server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx
server/sonar-web/src/main/js/apps/quality-gates/components/Period.tsx [deleted file]
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 4fb1cfccffedaf82ad70e1c6d2f88f93e2db8876..52e7ee1fd131587bcd3d952763b016b37cfacae5 100644 (file)
@@ -181,7 +181,6 @@ declare namespace T {
     id: number;
     metric: string;
     op?: string;
-    period?: number;
   }
 
   export interface CoveredFile {
index 6905dfb2b882bc4165f49f7ad7430d7b09cd5b0c..6b775c7271230fcddd42c1e985290ce95b519355 100644 (file)
@@ -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<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>
index 686450f80d84dedda09df349f904084b4d2a1628..e480bd53c91b70e5bc2592128d917743ca406d43 100644 (file)
@@ -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}
@@ -139,15 +121,6 @@ export default class ConditionModal extends React.PureComponent<Props, State> {
         </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
index a1f169b969696a1da4d0f424bf3143167a3b8663..a61b6da38ff03f10fda44be84ed3470e8c0e0cf5 100644 (file)
@@ -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 (file)
index 3a0962d..0000000
+++ /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 || (() => {})} />;
-  }
-}
index 015c3b7265de1f30bdefd2ae4df196f9620b5f5a..d13743b6434e99037a70d4e1471e57ec728a58f4 100644 (file)
@@ -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