mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-11 18:32:20 +08:00
e83bf2bbec
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
63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
import React, {Component, PropTypes} from 'react'
|
|
import {ListensToObservable, InjectedComponentSet} from 'nylas-component-kit'
|
|
import ThreadListStore from './thread-list-store'
|
|
|
|
|
|
export const ToolbarRole = 'ThreadActionsToolbarButton'
|
|
|
|
|
|
function defaultObservable() {
|
|
return ThreadListStore.selectionObservable()
|
|
}
|
|
|
|
function InjectsToolbarButtons(ToolbarComponent, {getObservable, extraRoles = []}) {
|
|
const roles = [ToolbarRole].concat(extraRoles)
|
|
|
|
class ComposedComponent extends Component {
|
|
static displayName = ToolbarComponent.displayName;
|
|
|
|
static propTypes = {
|
|
items: PropTypes.array,
|
|
};
|
|
|
|
static containerRequired = false;
|
|
|
|
render() {
|
|
const {items} = this.props;
|
|
const {selection} = ThreadListStore.dataSource()
|
|
|
|
// Keep all of the exposed props from deprecated regions that now map to this one
|
|
const exposedProps = {
|
|
items,
|
|
selection,
|
|
thread: items[0],
|
|
}
|
|
const injectedButtons = (
|
|
<InjectedComponentSet
|
|
key="injected"
|
|
matching={{roles}}
|
|
exposedProps={exposedProps} />
|
|
)
|
|
return (
|
|
<ToolbarComponent
|
|
items={items}
|
|
selection={selection}
|
|
injectedButtons={injectedButtons}
|
|
/>
|
|
)
|
|
}
|
|
}
|
|
|
|
const getStateFromObservable = (items) => {
|
|
if (!items) {
|
|
return {items: []}
|
|
}
|
|
return {items}
|
|
}
|
|
return ListensToObservable(ComposedComponent, {
|
|
getObservable: getObservable || defaultObservable,
|
|
getStateFromObservable,
|
|
})
|
|
}
|
|
|
|
export default InjectsToolbarButtons
|