const { Actions, AccountStore, React, PropTypes, WorkspaceStore } = require('mailspring-exports'); const { RetinaImg, KeyCommandsRegion } = require('mailspring-component-kit'); const LabelPickerPopover = require('./label-picker-popover').default; // This changes the category on one or more threads. class LabelPicker extends React.Component { static displayName = 'LabelPicker'; static containerRequired = false; static propTypes = { items: PropTypes.array }; static contextTypes = { sheetDepth: PropTypes.number }; constructor(props) { super(props); this._account = AccountStore.accountForItems(this.props.items); } // If the threads we're picking categories for change, (like when they // get their categories updated), we expect our parents to pass us new // props. We don't listen to the DatabaseStore ourselves. componentWillReceiveProps(nextProps) { return (this._account = AccountStore.accountForItems(nextProps.items)); } _keymapHandlers() { return { 'core:change-labels': this._onOpenCategoryPopover }; } _onOpenCategoryPopover = () => { if (!(this.props.items.length > 0)) { return; } if (this.context.sheetDepth !== WorkspaceStore.sheetStack().length - 1) { return; } const buttonRect = this._buttonEl.getBoundingClientRect(); Actions.openPopover(, { originRect: buttonRect, direction: 'down', }); }; render() { if (!this._account) { return ; } if (!this._account.usesLabels()) { return ; } const btnClasses = 'btn btn-toolbar btn-category-picker'; return ( ); } } module.exports = LabelPicker;