import React from 'react'; import { Utils } from 'mailspring-exports'; import { InjectedComponentSet, ListTabular } from 'mailspring-component-kit'; function snippet(html) { if (!(html && typeof html === 'string')) { return ''; } try { return Utils.extractTextFromHtml(html, { maxLength: 400 }).substr(0, 200); } catch (err) { return ''; } } function subject(subj) { if ((subj || '').trim().length === 0) { return (No Subject); } return Utils.extractTextFromHtml(subj); } const ParticipantsColumn = new ListTabular.Column({ name: 'Participants', width: 200, resolver: draft => { const list = [].concat(draft.to, draft.cc, draft.bcc); if (list.length > 0) { return (
{list.map(p => p.displayName()).join(', ')}
); } else { return
(No Recipients)
; } }, }); const ContentsColumn = new ListTabular.Column({ name: 'Contents', flex: 4, resolver: draft => { let attachments = []; if (draft.files && draft.files.length > 0) { attachments =
; } return ( {subject(draft.subject)} {snippet(draft.body)} {attachments} ); }, }); const StatusColumn = new ListTabular.Column({ name: 'State', resolver: draft => { return ( ); }, }); module.exports = { Wide: [ParticipantsColumn, ContentsColumn, StatusColumn], };