2016-02-19 02:00:11 +08:00
|
|
|
import React, {Component, PropTypes} from 'react'
|
|
|
|
import moment from 'moment'
|
|
|
|
import {DateUtils} from 'nylas-exports'
|
|
|
|
import {RetinaImg} from 'nylas-component-kit'
|
|
|
|
import SendLaterActions from './send-later-actions'
|
2016-03-07 08:55:28 +08:00
|
|
|
import {PLUGIN_ID} from './send-later-constants'
|
|
|
|
|
|
|
|
const {DATE_FORMAT_SHORT} = DateUtils
|
|
|
|
|
2016-02-19 02:00:11 +08:00
|
|
|
|
|
|
|
export default class SendLaterStatus extends Component {
|
|
|
|
static displayName = 'SendLaterStatus';
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
draft: PropTypes.object,
|
|
|
|
};
|
|
|
|
|
|
|
|
onCancelSendLater = ()=> {
|
|
|
|
SendLaterActions.cancelSendLater(this.props.draft.clientId)
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {draft} = this.props
|
|
|
|
const metadata = draft.metadataForPluginId(PLUGIN_ID)
|
|
|
|
if (metadata && metadata.sendLaterDate) {
|
|
|
|
const {sendLaterDate} = metadata
|
|
|
|
const formatted = DateUtils.format(moment(sendLaterDate), DATE_FORMAT_SHORT)
|
|
|
|
return (
|
|
|
|
<div className="send-later-status">
|
2016-02-25 05:44:56 +08:00
|
|
|
<span className="time">
|
2016-02-19 02:00:11 +08:00
|
|
|
{`Scheduled for ${formatted}`}
|
2016-02-25 05:44:56 +08:00
|
|
|
</span>
|
2016-02-19 02:00:11 +08:00
|
|
|
<RetinaImg
|
|
|
|
name="image-cancel-button.png"
|
|
|
|
title="Cancel Send Later"
|
|
|
|
onClick={this.onCancelSendLater}
|
|
|
|
mode={RetinaImg.Mode.ContentPreserve} />
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
return <span />
|
|
|
|
}
|
|
|
|
}
|