2015-05-20 07:06:59 +08:00
|
|
|
_ = require 'underscore'
|
2015-03-07 04:03:32 +08:00
|
|
|
React = require 'react'
|
2015-04-25 02:33:10 +08:00
|
|
|
classNames = require 'classnames'
|
2015-03-07 04:03:32 +08:00
|
|
|
|
2015-07-22 05:16:11 +08:00
|
|
|
{Actions,
|
|
|
|
WorkspaceStore,
|
|
|
|
FocusedContentStore} = require 'nylas-exports'
|
|
|
|
|
|
|
|
{Menu,
|
|
|
|
Popover,
|
|
|
|
RetinaImg,
|
2015-10-22 01:34:14 +08:00
|
|
|
TimeoutTransitionGroup,
|
2015-07-22 05:16:11 +08:00
|
|
|
InjectedComponentSet} = require 'nylas-component-kit'
|
2015-03-07 04:03:32 +08:00
|
|
|
|
2015-05-01 02:35:38 +08:00
|
|
|
class MessageToolbarItems extends React.Component
|
|
|
|
@displayName: "MessageToolbarItems"
|
2015-03-07 04:03:32 +08:00
|
|
|
|
2015-05-01 02:35:38 +08:00
|
|
|
constructor: (@props) ->
|
|
|
|
@state =
|
2015-06-26 01:33:26 +08:00
|
|
|
thread: FocusedContentStore.focused('thread')
|
2015-03-07 04:03:32 +08:00
|
|
|
|
2015-05-01 02:35:38 +08:00
|
|
|
render: =>
|
2015-10-22 01:34:14 +08:00
|
|
|
<TimeoutTransitionGroup
|
|
|
|
className="message-toolbar-items"
|
|
|
|
leaveTimeout={125}
|
|
|
|
enterTimeout={125}
|
|
|
|
transitionName="opacity-125ms">
|
|
|
|
{@_renderContents()}
|
|
|
|
</TimeoutTransitionGroup>
|
|
|
|
|
|
|
|
_renderContents: =>
|
2015-10-01 05:59:45 +08:00
|
|
|
return false unless @state.thread
|
2015-10-22 01:34:14 +08:00
|
|
|
<InjectedComponentSet key="injected" matching={role: "message:Toolbar"} exposedProps={thread: @state.thread}/>
|
2015-03-07 04:03:32 +08:00
|
|
|
|
2015-05-01 02:35:38 +08:00
|
|
|
componentDidMount: =>
|
2015-03-07 04:03:32 +08:00
|
|
|
@_unsubscribers = []
|
2015-04-09 10:25:00 +08:00
|
|
|
@_unsubscribers.push FocusedContentStore.listen @_onChange
|
2015-03-07 04:03:32 +08:00
|
|
|
|
2015-05-01 02:35:38 +08:00
|
|
|
componentWillUnmount: =>
|
2015-09-10 06:27:42 +08:00
|
|
|
return unless @_unsubscribers
|
2015-03-07 04:03:32 +08:00
|
|
|
unsubscribe() for unsubscribe in @_unsubscribers
|
|
|
|
|
feat(*): draft icon, misc fixes, and WorkspaceStore / custom toolbar in secondary windows
Summary:
Features:
- ThreadListParticipants ignores drafts when computing participants, renders "Draft" label, pending design
- Put the WorkspaceStore in every window—means they all get toolbars and custom gumdrop icons on Mac OS X
Bug Fixes:
- Never display notifications for email the user just sent
- Fix obscure issue with DatabaseView trying to update metadata on items it froze. This resolves issue with names remaining bold after marking as read, drafts not appearing in message list immediately.
- When you pop out a draft, save it first and *wait* for the commit() promise to succeed.
- If you scroll very fast, you node.contentWindow can be null in eventedIframe
Other:
Make it OK to re-register the same component
Make it possible to unregister a hot window
Break the Sheet Toolbar out into it's own file to make things manageable
Replace `package.windowPropsReceived` with a store-style model where anyone can listen for changes to `windowProps`
When I put the WorkspaceStore in every window, I ran into a problem because the package was no longer rendering an instance of the Composer, it was declaring a root sheet with a composer in it. This meant that it was actually a React component that needed to listen to window props, not the package itself.
`atom` is already an event emitter, so I added a `onWindowPropsReceived` hook so that components can listen to window props as if they were listening to a store. I think this might be more flexible than only broadcasting the props change event to packages.
Test Plan: Run tests
Reviewers: evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D1592
2015-06-04 07:02:19 +08:00
|
|
|
_onChange: =>
|
2015-03-07 04:03:32 +08:00
|
|
|
@setState
|
2015-06-26 01:33:26 +08:00
|
|
|
thread: FocusedContentStore.focused('thread')
|
2015-05-01 02:35:38 +08:00
|
|
|
|
|
|
|
module.exports = MessageToolbarItems
|