/* * Copyright (c) 2020 - present Cloudogu GmbH * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License as published by the Free * Software Foundation, version 3. * * 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 Affero General Public License for more * details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see https://www.gnu.org/licenses/. */ import React, { FC, useState } from "react"; import { useTranslation } from "react-i18next"; import classNames from "classnames"; import { Repository } from "@scm-manager/ui-types"; import { ExtensionPoint, extensionPoints } from "@scm-manager/ui-extensions"; import { TooltipLocation } from "../Tooltip"; import RepositoryFlag from "./RepositoryFlag"; import HealthCheckFailureDetail from "./HealthCheckFailureDetail"; import styled from "styled-components"; type Props = { repository: Repository; className?: string; tooltipLocation?: TooltipLocation; }; const GapedContainer = styled.div` gap: 0.5rem; `; const RepositoryFlags: FC = ({ repository, className, tooltipLocation = "right" }) => { const [t] = useTranslation("repos"); const [showHealthCheck, setShowHealthCheck] = useState(false); const repositoryFlags = []; if (repository.archived) { repositoryFlags.push( {t("repository.archived")} ); } if (repository.exporting) { repositoryFlags.push( {t("repository.exporting")} ); } if (repository.healthCheckFailures && repository.healthCheckFailures.length > 0) { repositoryFlags.push( setShowHealthCheck(true)} tooltipLocation={tooltipLocation} > {t("repository.healthCheckFailure")} ); } const modal = ( setShowHealthCheck(false)} active={showHealthCheck} failures={repository.healthCheckFailures} /> ); return ( {modal} {repositoryFlags} name="repository.flags" props={{ repository, tooltipLocation }} renderAll={true} /> ); }; export default RepositoryFlags;