/* * SonarQube * Copyright (C) 2009-2024 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 styled from '@emotion/styled'; import { LightGreyCard, LightLabel, SnoozeCircleIcon, TextError, TextSubdued, TrendUpCircleIcon, themeColor, } from 'design-system'; import React from 'react'; import { useIntl } from 'react-intl'; import { getTabPanelId } from '../../../components/controls/BoxedTabs'; import { getLeakValue } from '../../../components/measure/utils'; import { DEFAULT_ISSUES_QUERY } from '../../../components/shared/utils'; import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { findMeasure, formatMeasure } from '../../../helpers/measures'; import { getComponentDrilldownUrl, getComponentIssuesUrl, getComponentSecurityHotspotsUrl, } from '../../../helpers/urls'; import { Branch } from '../../../types/branch-like'; import { isApplication } from '../../../types/component'; import { IssueStatus } from '../../../types/issues'; import { MetricKey, MetricType } from '../../../types/metrics'; import { QualityGateStatus } from '../../../types/quality-gates'; import { Component, MeasureEnhanced } from '../../../types/types'; import { IssueMeasuresCardInner } from '../components/IssueMeasuresCardInner'; import MeasuresCardNumber from '../components/MeasuresCardNumber'; import MeasuresCardPercent from '../components/MeasuresCardPercent'; import { MeasurementType, MeasuresTabs, Status, getConditionRequiredLabel, getMeasurementMetricKey, } from '../utils'; interface Props { branch?: Branch; component: Component; measures: MeasureEnhanced[]; qgStatuses?: QualityGateStatus[]; } export default function NewCodeMeasuresPanel(props: Readonly) { const { branch, component, measures, qgStatuses } = props; const intl = useIntl(); const isApp = isApplication(component.qualifier); const failedConditions = qgStatuses?.flatMap((qg) => qg.failedConditions) ?? []; const newIssues = getLeakValue(findMeasure(measures, MetricKey.new_violations)); const newIssuesCondition = failedConditions.find((c) => c.metric === MetricKey.new_violations); const issuesConditionFailed = newIssuesCondition?.level === Status.ERROR; const newAcceptedIssues = getLeakValue(findMeasure(measures, MetricKey.new_accepted_issues)); const newSecurityHotspots = getLeakValue( findMeasure(measures, MetricKey.new_security_hotspots), ) as string; let issuesFooter; if (newIssuesCondition && !isApp) { issuesFooter = issuesConditionFailed ? ( ) : ( {getConditionRequiredLabel(newIssuesCondition, intl)} ); } return (
} footer={issuesFooter} /> {intl.formatMessage({ id: 'overview.accepted_issues.help' })} } icon={ } />
); } const StyledCardSeparator = styled.div` width: 1px; background-color: ${themeColor('projectCardBorder')}; `;