2016-02-23 07:48:07 +08:00
|
|
|
import React, {Component, PropTypes} from 'react';
|
2016-02-25 07:33:13 +08:00
|
|
|
import {Actions} 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,
|
|
|
|
};
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
2016-02-25 07:33:13 +08:00
|
|
|
this.openedPopover = false;
|
2016-02-23 07:48:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
onClick = (event)=> {
|
|
|
|
event.stopPropagation()
|
2016-02-25 07:33:13 +08:00
|
|
|
if (this.openedPopover) {
|
2016-02-23 07:48:07 +08:00
|
|
|
Actions.closePopover();
|
2016-02-25 07:33:13 +08:00
|
|
|
this.openedPopover = false;
|
2016-02-23 07:48:07 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
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 07:33:13 +08:00
|
|
|
this.openedPopover = true;
|
2016-02-23 07:48:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static containerRequired = false;
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return <div title="Snooze" className="btn action action-snooze" onClick={this.onClick}/>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default QuickActionSnoozeButton
|