/* * MIT License * * Copyright (c) 2020-present Cloudogu GmbH and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import React from "react"; import { Repository } from "@scm-manager/ui-types"; import { CardColumn, DateFromNow } from "@scm-manager/ui-components"; import RepositoryEntryLink from "./RepositoryEntryLink"; import RepositoryAvatar from "./RepositoryAvatar"; import { ExtensionPoint } from "@scm-manager/ui-extensions"; type DateProp = Date | string; type Props = { repository: Repository; // @VisibleForTesting // the baseDate is only to avoid failing snapshot tests baseDate?: DateProp; }; class RepositoryEntry extends React.Component { createLink = (repository: Repository) => { return `/repo/${repository.namespace}/${repository.name}`; }; renderBranchesLink = (repository: Repository, repositoryLink: string) => { if (repository._links["branches"]) { return ; } return null; }; renderChangesetsLink = (repository: Repository, repositoryLink: string) => { if (repository._links["changesets"]) { return ; } return null; }; renderSourcesLink = (repository: Repository, repositoryLink: string) => { if (repository._links["sources"]) { return ; } return null; }; renderModifyLink = (repository: Repository, repositoryLink: string) => { if (repository._links["update"]) { return ; } return null; }; createFooterLeft = (repository: Repository, repositoryLink: string) => { return ( <> {this.renderBranchesLink(repository, repositoryLink)} {this.renderChangesetsLink(repository, repositoryLink)} {this.renderSourcesLink(repository, repositoryLink)} {this.renderModifyLink(repository, repositoryLink)} ); }; createFooterRight = (repository: Repository, baseDate?: DateProp) => { return ( ); }; createTitle = () => { const { repository } = this.props; return ( <> {repository.name} ); }; render() { const { repository, baseDate } = this.props; const repositoryLink = this.createLink(repository); const footerLeft = this.createFooterLeft(repository, repositoryLink); const footerRight = this.createFooterRight(repository, baseDate); const title = this.createTitle(); return ( } title={title} description={repository.description} link={repositoryLink} footerLeft={footerLeft} footerRight={footerRight} /> ); } } export default RepositoryEntry;