2015-07-22 05:16:11 +08:00
|
|
|
_ = require 'underscore'
|
|
|
|
React = require 'react'
|
2016-03-29 16:41:24 +08:00
|
|
|
ReactDOM = require 'react-dom'
|
2015-07-22 05:16:11 +08:00
|
|
|
|
2016-03-10 02:01:18 +08:00
|
|
|
{Actions,
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
AccountStore,
|
2016-03-10 02:01:18 +08:00
|
|
|
WorkspaceStore} = require 'nylas-exports'
|
2015-07-22 05:16:11 +08:00
|
|
|
|
2016-03-10 02:01:18 +08:00
|
|
|
{RetinaImg,
|
|
|
|
KeyCommandsRegion} = require 'nylas-component-kit'
|
|
|
|
|
2016-05-04 07:42:28 +08:00
|
|
|
CategoryPickerPopover = require('./category-picker-popover').default
|
2015-07-22 05:16:11 +08:00
|
|
|
|
2016-01-09 09:49:27 +08:00
|
|
|
|
2015-07-22 05:16:11 +08:00
|
|
|
# This changes the category on one or more threads.
|
|
|
|
class CategoryPicker extends React.Component
|
|
|
|
@displayName: "CategoryPicker"
|
2016-03-10 02:01:18 +08:00
|
|
|
|
2015-07-22 05:16:11 +08:00
|
|
|
@containerRequired: false
|
|
|
|
|
2016-03-10 02:01:18 +08:00
|
|
|
@propTypes:
|
|
|
|
items: React.PropTypes.array
|
2015-07-22 05:16:11 +08:00
|
|
|
|
2015-07-24 02:47:46 +08:00
|
|
|
@contextTypes:
|
|
|
|
sheetDepth: React.PropTypes.number
|
|
|
|
|
2016-03-10 02:01:18 +08:00
|
|
|
constructor: (@props) ->
|
2016-03-18 00:50:30 +08:00
|
|
|
@_account = AccountStore.accountForItems(@props.items)
|
2016-01-09 09:49:27 +08:00
|
|
|
|
2016-01-09 01:31:24 +08:00
|
|
|
# If the threads we're picking categories for change, (like when they
|
|
|
|
# get their categories updated), we expect our parents to pass us new
|
|
|
|
# props. We don't listen to the DatabaseStore ourselves.
|
2015-07-22 05:16:11 +08:00
|
|
|
componentWillReceiveProps: (nextProps) ->
|
2016-03-18 00:50:30 +08:00
|
|
|
@_account = AccountStore.accountForItems(nextProps.items)
|
2015-11-07 03:47:06 +08:00
|
|
|
|
|
|
|
_keymapHandlers: ->
|
2016-04-25 01:16:25 +08:00
|
|
|
"core:change-category": @_onOpenCategoryPopover
|
2015-07-22 05:16:11 +08:00
|
|
|
|
2015-07-24 02:47:46 +08:00
|
|
|
_onOpenCategoryPopover: =>
|
2016-03-18 00:50:30 +08:00
|
|
|
return unless @props.items.length > 0
|
2015-07-24 02:47:46 +08:00
|
|
|
return unless @context.sheetDepth is WorkspaceStore.sheetStack().length - 1
|
2016-03-29 16:41:24 +08:00
|
|
|
buttonRect = ReactDOM.findDOMNode(@refs.button).getBoundingClientRect()
|
2016-03-10 02:01:18 +08:00
|
|
|
Actions.openPopover(
|
|
|
|
<CategoryPickerPopover
|
2016-03-18 00:50:30 +08:00
|
|
|
threads={@props.items}
|
2016-03-10 02:01:18 +08:00
|
|
|
account={@_account} />,
|
|
|
|
{originRect: buttonRect, direction: 'down'}
|
|
|
|
)
|
2015-07-24 02:47:46 +08:00
|
|
|
return
|
|
|
|
|
2016-03-10 02:01:18 +08:00
|
|
|
render: =>
|
|
|
|
return <span /> unless @_account
|
|
|
|
btnClasses = "btn btn-toolbar btn-category-picker"
|
|
|
|
img = ""
|
|
|
|
tooltip = ""
|
2015-12-03 03:43:37 +08:00
|
|
|
if @_account.usesLabels()
|
2016-03-10 02:01:18 +08:00
|
|
|
img = "toolbar-tag.png"
|
|
|
|
tooltip = "Apply Labels"
|
2015-12-03 03:43:37 +08:00
|
|
|
else
|
2016-03-10 02:01:18 +08:00
|
|
|
img = "toolbar-movetofolder.png"
|
|
|
|
tooltip = "Move to Folder"
|
2015-08-04 08:05:31 +08:00
|
|
|
|
2016-03-10 02:01:18 +08:00
|
|
|
return (
|
2016-04-25 01:16:25 +08:00
|
|
|
<KeyCommandsRegion
|
|
|
|
style={order: -103}
|
|
|
|
globalHandlers={@_keymapHandlers()}
|
|
|
|
globalMenuItems={[
|
|
|
|
{
|
|
|
|
"label": "Thread",
|
|
|
|
"submenu": [{ "label": "#{tooltip}...", "command": "core:change-category", "position": "endof=thread-actions" }]
|
|
|
|
}
|
|
|
|
]}
|
|
|
|
>
|
2016-03-10 02:01:18 +08:00
|
|
|
<button
|
fix(focus): Remove focusedField in favor of imperative focus, break apart ComposerView
Summary:
- Removes controlled focus in the composer!
- No React components ever perfom focus in lifecycle methods. Never again.
- A new `Utils.schedule({action, after, timeout})` helper makes it easy to say "setState or load draft, etc. and then focus"
- The DraftStore issues a focusDraft action after creating a draft, which causes the MessageList to focus and scroll to the desired composer, which itself decides which field to focus.
- The MessageList never focuses anything automatically.
- Refactors ComposerView apart — ComposerHeader handles all top fields, DraftSessionContainer handles draft session initialization and exposes props to ComposerView
- ComposerHeader now uses a KeyCommandRegion (with focusIn and focusOut) to do the expanding and collapsing of the participants fields. May rename that container very soon.
- Removes all CommandRegistry handling of tab and shift-tab. Unless you preventDefault, the browser does it's thing.
- Removes all tabIndexes greater than 1. This is an anti-pattern—assigning everything a tabIndex of 0 tells the browser to move between them based on their order in the DOM, and is almost always what you want.
- Adds "TabGroupRegion" which allows you to create a tab/shift-tabbing group, (so tabbing does not leave the active composer). Can't believe this isn't a browser feature.
Todos:
- Occasionally, clicking out of the composer contenteditable requires two clicks. This is because atomicEdit is restoring selection within the contenteditable and breaking blur.
- Because the ComposerView does not render until it has a draft, we're back to it being white in popout composers for a brief moment. We will fix this another way - all the "return unless draft" statements were untenable.
- Clicking a row in the thread list no longer shifts focus to the message list and focuses the last draft. This will be restored soon.
Test Plan: Broken
Reviewers: juan, evan
Reviewed By: juan, evan
Differential Revision: https://phab.nylas.com/D2814
2016-04-05 06:22:01 +08:00
|
|
|
tabIndex={-1}
|
2016-03-10 02:01:18 +08:00
|
|
|
ref="button"
|
|
|
|
title={tooltip}
|
|
|
|
onClick={@_onOpenCategoryPopover}
|
|
|
|
className={btnClasses} >
|
|
|
|
<RetinaImg name={img} mode={RetinaImg.Mode.ContentIsMask}/>
|
|
|
|
</button>
|
|
|
|
</KeyCommandsRegion>
|
|
|
|
)
|
2015-07-22 05:16:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
module.exports = CategoryPicker
|