mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 04:25:31 +08:00
1fe51ef586
Summary: - Setting the locale in moment was not sufficient to actually use the correct localized formats. - Moment provides localized format via the formats : 'L', 'LL', 'll', etc. See: http://momentjs.com/docs/#/displaying/format/ - Updates to set our date formats based on localized formats: - Unfortunately, localized formats always contain the year, so I manually removed the year from our short format. - Actually fixes: #1515 - Fixes bug where setting nextWeek or thisWeekend returned incorrect date if the current day was saturday or sunday - Add specs Test Plan: Unit tests Reviewers: evan, drew, bengotow Reviewed By: bengotow Differential Revision: https://phab.nylas.com/D2688
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
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'
|
|
import {PLUGIN_ID} from './send-later-constants'
|
|
|
|
const {DATE_FORMAT_SHORT} = DateUtils
|
|
|
|
|
|
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">
|
|
<span className="time">
|
|
{`Scheduled for ${formatted}`}
|
|
</span>
|
|
<RetinaImg
|
|
name="image-cancel-button.png"
|
|
title="Cancel Send Later"
|
|
onClick={this.onCancelSendLater}
|
|
mode={RetinaImg.Mode.ContentPreserve} />
|
|
</div>
|
|
)
|
|
}
|
|
return <span />
|
|
}
|
|
}
|