Mailspring/app/internal_packages/composer/lib/attachments-area.tsx
Ben Gotow 21bc2ef398
Upgrade to Slate 0.45.1 for better composer perf and "setStart on Range" error fix (#1518)
* Move to Slate 44, start using types more extensively in Composer

* More types and cleanup

* Expose the editor object to the draft session, try exposing editor to session

* Bump to Slate 45 for https://github.com/ianstormtaylor/slate/pull/2225/files

* How did the unsubscribe plugin get in here

* Bump Slate types, fix TS errors, start testing

* Polish

* Fix issue with emails not shrinking when you close quoted text

* Fix the “remove quoted text” button

* More polish

* Fix issues with PR, improve typings

* Remove spurious log
2019-06-10 19:15:07 -05:00

39 lines
1.3 KiB
TypeScript

import React from 'react';
import { Utils, Actions, AttachmentStore, Message } from 'mailspring-exports';
import { AttachmentItem, ImageAttachmentItem } from 'mailspring-component-kit';
export const AttachmentsArea: React.FunctionComponent<{ draft: Message }> = props => {
const { files, headerMessageId } = props.draft;
return (
<div className="attachments-area">
{files
.filter(f => !Utils.shouldDisplayAsImage(f))
.map(file => (
<AttachmentItem
key={file.id}
className="file-upload"
draggable={false}
filePath={AttachmentStore.pathForFile(file)}
displayName={file.filename}
fileIconName={`file-${file.displayExtension()}.png`}
onRemoveAttachment={() => Actions.removeAttachment(headerMessageId, file)}
/>
))}
{files
.filter(f => Utils.shouldDisplayAsImage(f))
.filter(f => !f.contentId)
.map(file => (
<ImageAttachmentItem
key={file.id}
draggable={false}
className="file-upload"
filePath={AttachmentStore.pathForFile(file)}
displayName={file.filename}
onRemoveAttachment={() => Actions.removeAttachment(headerMessageId, file)}
/>
))}
</div>
);
};