Mailspring/app/internal_packages/thread-list/lib/message-list-toolbar.jsx
Ben Gotow ae72cf1c65 Bump to React 16.2 now that the old composer is gone 🎉
commit 3c10d22199ea6428a6b45c6361d281b1d281ef4f
Author: Ben Gotow <ben@foundry376.com>
Date:   Fri Jan 19 08:10:43 2018 -0800

    Small fixes

commit e7d4ba85eb011a6fd58b57e079bf3a19c19126d8
Author: Ben Gotow <ben@foundry376.com>
Date:   Thu Jan 18 23:47:03 2018 -0800

    Rewrite UnsafeComponent using Error Boundaries

commit aa772694fdee6c57887b75b3abb2e654e146fab5
Author: Ben Gotow <ben@foundry376.com>
Date:   Thu Jan 18 23:15:53 2018 -0800

    Remove GeneratedForm

commit f9ea4296f07d446f942dfc2532deea37db43ddac
Author: Ben Gotow <ben@foundry376.com>
Date:   Thu Jan 18 23:08:45 2018 -0800

    Fully remove calendar related dead code and spec_disabled

    It’s making it hard to see what I need to edit and what I don’t care about

commit 6192ce6073244bc66b7908b66b5033d34e947efb
Author: Ben Gotow <ben@foundry376.com>
Date:   Thu Jan 18 23:08:16 2018 -0800

    Bump to React 16.2 🎉
2018-01-22 22:18:46 -08:00

48 lines
1.4 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { CSSTransitionGroup } from 'react-transition-group';
import { Rx, FocusedContentStore } from 'mailspring-exports';
import ThreadListStore from './thread-list-store';
import InjectsToolbarButtons, { ToolbarRole } from './injects-toolbar-buttons';
function getObservable() {
return Rx.Observable
.combineLatest(
Rx.Observable.fromStore(FocusedContentStore),
ThreadListStore.selectionObservable(),
(store, items) => ({ focusedThread: store.focused('thread'), items })
)
.map(({ focusedThread, items }) => {
if (focusedThread) {
return [focusedThread];
}
return items;
});
}
const MessageListToolbar = ({ items, injectedButtons }) => {
const shouldRender = items.length > 0;
return (
<CSSTransitionGroup
className="message-toolbar-items"
transitionLeaveTimeout={125}
transitionEnterTimeout={125}
transitionName="opacity-125ms"
>
{shouldRender ? injectedButtons : undefined}
</CSSTransitionGroup>
);
};
MessageListToolbar.displayName = 'MessageListToolbar';
MessageListToolbar.propTypes = {
items: PropTypes.array,
injectedButtons: PropTypes.element,
};
const toolbarProps = {
getObservable,
extraRoles: [`MessageList:${ToolbarRole}`],
};
export default InjectsToolbarButtons(MessageListToolbar, toolbarProps);