Mailspring/internal_packages/thread-snooze/lib/snooze-mail-label.jsx
Juan Tejada 0fd2d107b2 test(plugins): Add snooze and send later specs
Summary:
- Also refactors the code a bit for testability and maintainability
- Fixes #1515

Test Plan: - Unit tests

Reviewers: evan, drew, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2651
2016-03-03 12:38:42 -08:00

46 lines
1.4 KiB
JavaScript

import _ from 'underscore';
import React, {Component, PropTypes} from 'react';
import {RetinaImg, MailLabel} from 'nylas-component-kit';
import {SNOOZE_CATEGORY_NAME, PLUGIN_ID} from './snooze-constants';
import {snoozedUntilMessage} from './snooze-utils';
class SnoozeMailLabel extends Component {
static displayName = 'SnoozeMailLabel';
static propTypes = {
thread: PropTypes.object,
};
static containerRequired = false;
render() {
const {thread} = this.props;
if (_.findWhere(thread.categories, {displayName: SNOOZE_CATEGORY_NAME})) {
const metadata = thread.metadataForPluginId(PLUGIN_ID);
if (metadata) {
// TODO this is such a hack
const {snoozeDate} = metadata;
const message = snoozedUntilMessage(snoozeDate).replace('Snoozed', '')
const content = (
<span className="snooze-mail-label">
<RetinaImg
name="icon-snoozed.png"
mode={RetinaImg.Mode.ContentIsMask} />
<span className="date-message">{message}</span>
</span>
)
const label = {
displayName: content,
isLockedCategory: ()=> true,
hue: ()=> 259,
}
return <MailLabel label={label} key={'snooze-message-' + thread.id} />;
}
return <span />
}
return <span />
}
}
export default SnoozeMailLabel;