/* * SonarQube * Copyright (C) 2009-2018 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 * as classNames from 'classnames'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router'; import { getLeakValue } from '../measure/utils'; import CoverageRating from '../ui/CoverageRating'; import { formatMeasure } from '../../helpers/measures'; import HelpTooltip from '../controls/HelpTooltip'; import { translate } from '../../helpers/l10n'; import DuplicationsRating from '../ui/DuplicationsRating'; import { getComponentDrilldownUrl } from '../../helpers/urls'; interface Props { branchLike: T.BranchLike; componentKey: string; measures: T.Measure[]; } export default function BranchMeasures({ branchLike, componentKey, measures }: Props) { const newCoverage = measures.find(measure => measure.metric === 'new_coverage'); const newDuplications = measures.find( measure => measure.metric === 'new_duplicated_lines_density' ); if (!newCoverage && !newDuplications) { return null; } return (
); } interface MeasureProps { branchLike: T.BranchLike; className?: string; componentKey: string; measure: T.Measure | undefined; } export function BranchCoverage({ branchLike, className, componentKey, measure }: MeasureProps) { const value = getLeakValue(measure); return (
{value !== undefined ? formatMeasure(value, 'PERCENT') : '–'} {translate('layout.measures')} ) }} /> ) : ( translate('branches.measures.new_coverage.missing') ) } />
); } export function BranchDuplications({ branchLike, className, componentKey, measure }: MeasureProps) { const value = getLeakValue(measure); return (
{value !== undefined ? formatMeasure(value, 'PERCENT') : '–'} {translate('layout.measures')} ) }} /> ) : ( translate('branches.measures.new_duplicated_lines_density.missing') ) } />
); }