import React from 'react'; import { Button, Modal } from 'react-bootstrap'; import Icon from '../Common/Icon'; import User from '../User/User'; export default class DeleteAttachmentModal extends React.Component { constructor(props) { super(props); this._onDeleteConfirm = this._onDeleteConfirm.bind(this); } _onDeleteConfirm() { this.props.onAttachmentDeleteClickedConfirm(this.props.attachmentToDelete); } renderByFileFormat(attachment) { if (attachment.fileFormat.match(/image\/.+/i)) { return (

{attachment.originalName} uploaded by

); } return (

); } render() { const attachment = this.props.attachmentToDelete; if (attachment === null) { return null; } const inUse = this.props.inUse; const props = Object.assign({}, this.props); delete props.onAttachmentDeleteClickedConfirm; delete props.attachmentToDelete; delete props.inUse; delete props.deleting; delete props.deleteError; let deletingIndicator = ''; if (this.props.deleting) { deletingIndicator = ; } if (this.props.deleteError) { deletingIndicator =

{this.props.deleteError}

; } let renderAttachment = this.renderByFileFormat(attachment); return ( Delete attachment? {renderAttachment} {deletingIndicator} ); } }