2017-09-27 02:42:18 +08:00
|
|
|
import { React, PropTypes, DateUtils } from 'mailspring-exports';
|
2017-09-27 02:46:00 +08:00
|
|
|
import { Flexbox } from 'mailspring-component-kit';
|
2017-09-07 07:19:48 +08:00
|
|
|
import ActivityListStore from '../../activity-list/lib/activity-list-store';
|
|
|
|
|
|
|
|
class OpenTrackingMessagePopover extends React.Component {
|
|
|
|
static displayName = 'OpenTrackingMessagePopover';
|
|
|
|
|
|
|
|
static propTypes = {
|
2017-09-27 02:33:08 +08:00
|
|
|
message: PropTypes.object,
|
|
|
|
openMetadata: PropTypes.object,
|
2017-09-07 07:19:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
renderOpenActions() {
|
|
|
|
const opens = this.props.openMetadata.open_data;
|
2017-09-27 02:33:08 +08:00
|
|
|
return opens.map(open => {
|
|
|
|
const recipients = this.props.message.to.concat(
|
|
|
|
this.props.message.cc,
|
|
|
|
this.props.message.bcc
|
|
|
|
);
|
2017-09-07 07:19:48 +08:00
|
|
|
const recipient = ActivityListStore.getRecipient(open.recipient, recipients);
|
|
|
|
const date = new Date(0);
|
|
|
|
date.setUTCSeconds(open.timestamp);
|
|
|
|
return (
|
|
|
|
<Flexbox key={`${open.timestamp}`} className="open-action">
|
2017-09-27 02:33:08 +08:00
|
|
|
<div className="recipient">{recipient ? recipient.displayName() : 'Someone'}</div>
|
2017-09-07 07:19:48 +08:00
|
|
|
<div className="spacer" />
|
2017-09-27 02:33:08 +08:00
|
|
|
<div className="timestamp">{DateUtils.shortTimeString(date)}</div>
|
2017-09-07 07:19:48 +08:00
|
|
|
</Flexbox>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2017-09-27 02:33:08 +08:00
|
|
|
<div className="open-tracking-message-popover" tabIndex="-1">
|
2017-09-07 07:19:48 +08:00
|
|
|
<div className="open-tracking-header">Opened by:</div>
|
2017-09-27 02:33:08 +08:00
|
|
|
<div className="open-history-container">{this.renderOpenActions()}</div>
|
2017-09-07 07:19:48 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default OpenTrackingMessagePopover;
|