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 } from '@scm-manager/ui-components'; import FileIcon from './FileIcon'; type Props = { 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; } export default 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}; }; render() { const { file } = this.props; const fileSize = file.directory ? '' : ; return ( {this.createFileIcon(file)} {this.createFileName(file)} {fileSize} {file.description} {binder.hasExtension('repos.sources.tree.row.right') && ( {!file.directory && ( )} )} ); } }