mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 12:40:08 +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
73 lines
1.9 KiB
JavaScript
73 lines
1.9 KiB
JavaScript
import _ from 'underscore'
|
|
import React, {Component, PropTypes} from 'react'
|
|
import {ListensToObservable} from 'nylas-component-kit'
|
|
import ThreadListStore from './thread-list-store'
|
|
|
|
|
|
function getObservable() {
|
|
return (
|
|
ThreadListStore.selectionObservable()
|
|
.map(items => items.length)
|
|
)
|
|
}
|
|
|
|
function getStateFromObservable(selectionCount) {
|
|
if (!selectionCount) {
|
|
return {selectionCount: 0}
|
|
}
|
|
return {selectionCount}
|
|
}
|
|
|
|
class SelectedItemsStack extends Component {
|
|
static displayName = "SelectedItemsStack";
|
|
|
|
static propTypes = {
|
|
selectionCount: PropTypes.number,
|
|
};
|
|
|
|
onClearSelection = ()=> {
|
|
ThreadListStore.dataSource().selection.clear()
|
|
};
|
|
|
|
static containerRequired = false;
|
|
|
|
render() {
|
|
const {selectionCount} = this.props
|
|
if (selectionCount <= 1) {
|
|
return <span />
|
|
}
|
|
const cardCount = Math.min(5, selectionCount)
|
|
|
|
return (
|
|
<div className="selected-items-stack">
|
|
<div className="selected-items-stack-content">
|
|
<div className="stack">
|
|
{_.times(cardCount, (idx) => {
|
|
let deg = idx * 0.9;
|
|
|
|
if (idx === 1) {
|
|
deg += 0.5
|
|
}
|
|
let transform = `rotate(${deg}deg)`
|
|
if (idx === cardCount - 1) {
|
|
transform += ' translate(2px, 3px)'
|
|
}
|
|
const style = {
|
|
transform,
|
|
zIndex: 5 - idx,
|
|
}
|
|
return <div style={style} className="card"/>
|
|
})}
|
|
</div>
|
|
<div className="count-info">
|
|
<div className="count">{selectionCount}</div>
|
|
<div className="count-message">messages selected</div>
|
|
<div className="clear" onClick={this.onClearSelection}>clear selection</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
}
|
|
|
|
export default ListensToObservable(SelectedItemsStack, {getObservable, getStateFromObservable})
|