import * as React from "react"; import { Link } from "react-router-dom"; import classNames from "classnames"; import styled from "styled-components"; import { binder, ExtensionPoint } from "@scm-manager/ui-extensions"; import { File } from "@scm-manager/ui-types"; import { DateFromNow, FileSize, Tooltip } from "@scm-manager/ui-components"; import FileIcon from "./FileIcon"; import { Icon } from "@scm-manager/ui-components/src"; import { WithTranslation, withTranslation } from "react-i18next"; type Props = WithTranslation & { file: File; baseUrl: string; }; const MinWidthTd = styled.td` min-width: 10em; `; export function createLink(base: string, file: File) { let link = base; if (file.path) { let path = file.path; if (path.startsWith("/")) { path = path.substring(1); } link += "/" + path; } if (!link.endsWith("/")) { link += "/"; } return link; } class FileTreeLeaf extends React.Component { createLink = (file: File) => { return createLink(this.props.baseUrl, file); }; createFileIcon = (file: File) => { if (file.directory) { return ( ); } return ( ); }; createFileName = (file: File) => { if (file.directory) { return {file.name}; } return {file.name}; }; contentIfPresent = (file: File, content: any) => { const { t } = this.props; if (file.computationAborted) { return ( ); } else if (file.partialResult) { return ( ); } else { return content; } }; render() { const { file } = this.props; const fileSize = file.directory ? "" : ; return ( {this.createFileIcon(file)} {this.createFileName(file)} {fileSize} {this.contentIfPresent(file, )} {this.contentIfPresent(file, file.description)} {binder.hasExtension("repos.sources.tree.row.right") && ( {!file.directory && ( )} )} ); } } export default withTranslation("repos")(FileTreeLeaf);