Mailspring/internal_packages/thread-snooze/lib/snooze-quick-action-button.jsx
Juan Tejada f22fdbae49 feat(snooze): Add snooze date label to snooze threads
- Adds a new InjectedComponentSet for the role 'ThreadList:Label'.
- Adds a new label to the thread list indicating the snooze date if the
  thread has been snoozed
- Coerces MailLabel to achieve this. This is a temporary hack, we should
  design a better view to display snooze date information
2016-02-25 13:12:40 -08:00

42 lines
1.2 KiB
JavaScript

import React, {Component, PropTypes} from 'react';
import {Actions, FocusedPerspectiveStore} from 'nylas-exports';
import SnoozePopoverBody from './snooze-popover-body';
class QuickActionSnoozeButton extends Component {
static displayName = 'QuickActionSnoozeButton';
static propTypes = {
thread: PropTypes.object,
};
onClick = (event)=> {
event.stopPropagation()
const {thread} = this.props;
// Grab the parent node because of the zoom applied to this button. If we
// took this element directly, we'd have to divide everything by 2
const element = React.findDOMNode(this).parentNode;
const {height, width, top, bottom, left, right} = element.getBoundingClientRect()
// The parent node is a bit too much to the left, lets adjust this.
const rect = {height, width, top, bottom, right, left: left + 5}
Actions.openPopover(
<SnoozePopoverBody threads={[thread]} closePopover={Actions.closePopover}/>,
rect,
"left"
);
};
static containerRequired = false;
render() {
if (!FocusedPerspectiveStore.current().isInbox()) {
return <span />;
}
return <div title="Snooze" className="btn action action-snooze" onClick={this.onClick}/>
}
}
export default QuickActionSnoozeButton