2016-02-23 07:48:07 +08:00
|
|
|
import React, {Component, PropTypes} from 'react';
|
2016-02-25 09:33:20 +08:00
|
|
|
import {Actions, FocusedPerspectiveStore} from 'nylas-exports';
|
2016-02-23 07:48:07 +08:00
|
|
|
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;
|
2016-02-25 07:01:44 +08:00
|
|
|
const {height, width, top, bottom, left, right} = element.getBoundingClientRect()
|
2016-02-23 07:48:07 +08:00
|
|
|
|
|
|
|
// The parent node is a bit too much to the left, lets adjust this.
|
2016-02-25 07:01:44 +08:00
|
|
|
const rect = {height, width, top, bottom, right, left: left + 5}
|
2016-02-23 07:48:07 +08:00
|
|
|
Actions.openPopover(
|
2016-02-25 07:33:13 +08:00
|
|
|
<SnoozePopoverBody threads={[thread]} closePopover={Actions.closePopover}/>,
|
2016-02-23 07:48:07 +08:00
|
|
|
rect,
|
|
|
|
"left"
|
2016-02-25 12:05:16 +08:00
|
|
|
);
|
2016-02-23 07:48:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static containerRequired = false;
|
|
|
|
|
|
|
|
render() {
|
2016-02-25 09:33:20 +08:00
|
|
|
if (!FocusedPerspectiveStore.current().isInbox()) {
|
|
|
|
return <span />;
|
|
|
|
}
|
2016-02-23 07:48:07 +08:00
|
|
|
return <div title="Snooze" className="btn action action-snooze" onClick={this.onClick}/>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default QuickActionSnoozeButton
|