2016-10-18 08:59:33 +08:00
|
|
|
import React, {Component, PropTypes} from 'react'
|
2016-03-18 00:50:30 +08:00
|
|
|
import {ListensToObservable, MultiselectToolbar, InjectedComponentSet} from 'nylas-component-kit'
|
|
|
|
|
2016-10-18 08:59:33 +08:00
|
|
|
import DraftListStore from './draft-list-store'
|
|
|
|
|
2016-03-18 00:50:30 +08:00
|
|
|
|
|
|
|
function getObservable() {
|
|
|
|
return DraftListStore.selectionObservable()
|
|
|
|
}
|
|
|
|
|
|
|
|
function getStateFromObservable(items) {
|
|
|
|
if (!items) {
|
|
|
|
return {items: []}
|
|
|
|
}
|
|
|
|
return {items}
|
|
|
|
}
|
|
|
|
|
|
|
|
class DraftListToolbar extends Component {
|
|
|
|
static displayName = 'DraftListToolbar';
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
items: PropTypes.array,
|
|
|
|
};
|
|
|
|
|
|
|
|
onClearSelection = () => {
|
|
|
|
DraftListStore.dataSource().selection.clear()
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {selection} = DraftListStore.dataSource()
|
|
|
|
const {items} = this.props
|
|
|
|
|
|
|
|
// Keep all of the exposed props from deprecated regions that now map to this one
|
|
|
|
const toolbarElement = (
|
|
|
|
<InjectedComponentSet
|
|
|
|
matching={{role: "DraftActionsToolbarButton"}}
|
2016-05-07 07:24:40 +08:00
|
|
|
exposedProps={{selection, items}}
|
|
|
|
/>
|
2016-03-18 00:50:30 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<MultiselectToolbar
|
|
|
|
collection="draft"
|
|
|
|
selectionCount={items.length}
|
|
|
|
toolbarElement={toolbarElement}
|
|
|
|
onClearSelection={this.onClearSelection}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ListensToObservable(DraftListToolbar, {getObservable, getStateFromObservable})
|