/* eslint-disable react/no-multi-comp */ import * as React from 'react'; import {gettext} from 'core/utils'; import {filesize, fileicon} from 'core/ui/ui'; import {Item, Column, Row, ActionMenu} from 'core/ui/components/List'; import {IAttachment} from 'superdesk-api'; import {attachmentsApi} from './attachmentsService'; interface IProps { attachments: Array; readOnly: boolean; editAttachment: (attachment: IAttachment) => void; removeAttachment: (attachment: IAttachment) => void; } export class AttachmentsList extends React.PureComponent { constructor(props) { super(props); this.renderAttachment = this.renderAttachment.bind(this); } renderAttachment(file: IAttachment) { const {readOnly, editAttachment, removeAttachment} = this.props; return (

{file.title}

{file.filename} {`(${filesize(file.media.length)})`}
{file.description}
{ file.internal === true && ( internal ) }
{ readOnly === true ? null : ( ) } { readOnly === true ? null : ( ) }
); } render() { const {attachments} = this.props; return (
{!!attachments.length && (
    {attachments.map(this.renderAttachment)}
)}
); } }