You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ConditionValueDescription.tsx 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2023 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. import * as React from 'react';
  21. import { translate } from '../../../helpers/l10n';
  22. import { formatMeasure } from '../../../helpers/measures';
  23. import { MetricKey } from '../../../types/metrics';
  24. import { Condition, Metric } from '../../../types/types';
  25. import { GreenColorText } from './ConditionValue';
  26. const NO_DESCRIPTION_CONDITION = [
  27. MetricKey.new_violations,
  28. MetricKey.new_security_hotspots_reviewed,
  29. MetricKey.new_coverage,
  30. MetricKey.new_duplicated_lines_density,
  31. MetricKey.new_reliability_rating,
  32. MetricKey.new_security_rating,
  33. MetricKey.new_maintainability_rating,
  34. ];
  35. interface Props {
  36. condition: Condition;
  37. metric: Metric;
  38. isToBeModified?: boolean;
  39. }
  40. export default function ConditionValueDescription({
  41. condition,
  42. metric,
  43. isToBeModified = false,
  44. }: Readonly<Props>) {
  45. return (
  46. <GreenColorText isToBeModified={isToBeModified}>
  47. {condition.isCaycCondition &&
  48. !NO_DESCRIPTION_CONDITION.includes(condition.metric as MetricKey) && (
  49. <>
  50. (
  51. {translate(
  52. `quality_gates.cayc.${condition.metric}.${formatMeasure(
  53. condition.error,
  54. metric.type,
  55. )}`,
  56. )}
  57. )
  58. </>
  59. )}
  60. </GreenColorText>
  61. );
  62. }