/* * SonarQube * Copyright (C) 2009-2022 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 classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router-dom'; import { ButtonIcon } from '../../../components/controls/buttons'; import { ClipboardIconButton } from '../../../components/controls/clipboard'; import ExpandSnippetIcon from '../../../components/icons/ExpandSnippetIcon'; import QualifierIcon from '../../../components/icons/QualifierIcon'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { collapsedDirFromPath, fileFromPath } from '../../../helpers/path'; import { getBranchLikeUrl, getComponentIssuesUrl, getPathUrlAsString } from '../../../helpers/urls'; import { BranchLike } from '../../../types/branch-like'; import { ComponentQualifier } from '../../../types/component'; import { SourceViewerFile } from '../../../types/types'; import './IssueSourceViewerHeader.css'; export interface Props { branchLike: BranchLike | undefined; expandable?: boolean; displayProjectName?: boolean; linkToProject?: boolean; loading?: boolean; onExpand?: () => void; sourceViewerFile: SourceViewerFile; } export default function IssueSourceViewerHeader(props: Props) { const { branchLike, expandable, displayProjectName = true, linkToProject = true, loading, onExpand, sourceViewerFile } = props; const { measures, path, project, projectName, q } = sourceViewerFile; const projectNameLabel = ( <> {projectName} ); const isProjectRoot = q === ComponentQualifier.Project; return (
{displayProjectName && (
{linkToProject ? ( {projectNameLabel} ) : ( projectNameLabel )}
)} {!isProjectRoot && ( <>
{collapsedDirFromPath(path)} {fileFromPath(path)}
)}
{!isProjectRoot && measures.issues !== undefined && (
{translate('source_viewer.view_all_issues')}
)} {expandable && (
)}
); }