Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | import React from 'react' import Icon from 'components/Common/Icon' import User from 'components/User/User' import { Attachment as AttachmentType } from 'client/types/crowi' interface Props { attachment: AttachmentType inUse: boolean onAttachmentDeleteClicked: Function } export default class Attachment extends React.Component<Props> { constructor(props: Props) { super(props) this._onAttachmentDeleteClicked = this._onAttachmentDeleteClicked.bind(this) } iconNameByFormat(format: string) { if (format.match(/image\/.+/i)) { return 'fileImage' } return 'file' } _onAttachmentDeleteClicked(event: React.MouseEvent<HTMLAnchorElement>) { this.props.onAttachmentDeleteClicked(this.props.attachment) } render() { const attachment = this.props.attachment const formatIcon = this.iconNameByFormat(attachment.fileFormat) const fileInUse = this.props.inUse ? <span className="attachment-in-use badge badge-info">In Use</span> : '' const fileType = <span className="attachment-filetype badge badge-secondary">{attachment.fileFormat}</span> return ( <li> <User user={attachment.creator} /> <Icon name={formatIcon} /> <a href={attachment.url}> {attachment.originalName}</a> {fileType} {fileInUse} <a className="text-danger attachment-delete" onClick={this._onAttachmentDeleteClicked}> <Icon name="trashCanOutline" /> </a> </li> ) } } |