mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-15 14:20:38 +08:00
687597134d
Summary: - New behavior is that the in split mode, you will perform actions on the selection via the MessageListToolbar (the toolbar positioned above the message list) - Refactored and moved around a bunch of code to achieve this: - Mostly renaming stuff and moving stuff around and removing some duplication - Update naming of toolbar role to a single role, and update relevant code - Converted and refactored a bunch of code into ES6, specifically to reuse the code for the ThreadActionsToolbar at the 2 locations - Deprecated MultiselectActionBar in favor of MultiselectToolbar - Deprecated old roles - Punted the animation for the stackable cards in the selection display for now. - #370 Test Plan: - Manual and unit tests Reviewers: evan, drew, bengotow Reviewed By: bengotow Differential Revision: https://phab.nylas.com/D2756
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
import React, {Component, PropTypes} from "react"
|
|
import DraftListStore from './draft-list-store'
|
|
import {ListensToObservable, MultiselectToolbar, InjectedComponentSet} from 'nylas-component-kit'
|
|
|
|
|
|
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"}}
|
|
exposedProps={{selection, items}} />
|
|
)
|
|
|
|
return (
|
|
<MultiselectToolbar
|
|
collection="draft"
|
|
selectionCount={items.length}
|
|
toolbarElement={toolbarElement}
|
|
onClearSelection={this.onClearSelection}
|
|
/>
|
|
)
|
|
}
|
|
}
|
|
|
|
export default ListensToObservable(DraftListToolbar, {getObservable, getStateFromObservable})
|