2015-08-15 06:40:11 +08:00
|
|
|
React = require 'react'
|
|
|
|
_ = require 'underscore'
|
2015-12-10 04:35:40 +08:00
|
|
|
{AccountStore, Actions} = require 'nylas-exports'
|
|
|
|
PreferencesAccountList = require './preferences-account-list'
|
|
|
|
PreferencesAccountDetails = require './preferences-account-details'
|
2015-08-15 06:40:11 +08:00
|
|
|
|
|
|
|
class PreferencesAccounts extends React.Component
|
|
|
|
@displayName: 'PreferencesAccounts'
|
|
|
|
|
|
|
|
constructor: (@props) ->
|
|
|
|
@state = @getStateFromStores()
|
2015-12-10 04:35:40 +08:00
|
|
|
@state.selected = @state.accounts[0]
|
2015-08-15 06:40:11 +08:00
|
|
|
|
|
|
|
componentDidMount: =>
|
2015-12-10 04:35:40 +08:00
|
|
|
@unsubscribe = AccountStore.listen @_onAccountsChanged
|
2015-08-15 06:40:11 +08:00
|
|
|
|
|
|
|
componentWillUnmount: =>
|
|
|
|
@unsubscribe?()
|
|
|
|
|
|
|
|
getStateFromStores: =>
|
2016-01-09 01:31:24 +08:00
|
|
|
accounts: AccountStore.accounts()
|
2015-08-15 06:40:11 +08:00
|
|
|
|
2015-12-10 04:35:40 +08:00
|
|
|
_onAccountsChanged: =>
|
|
|
|
@setState(@getStateFromStores())
|
|
|
|
|
2015-08-15 06:40:11 +08:00
|
|
|
|
2015-12-10 04:35:40 +08:00
|
|
|
# Update account list 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
|
|
|
_onAddAccount: =>
|
2015-11-24 14:09:17 +08:00
|
|
|
ipc = require('electron').ipcRenderer
|
2015-09-25 05:51:15 +08:00
|
|
|
ipc.send('command', 'application:add-account')
|
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
|
|
|
|
2016-02-02 06:06:54 +08:00
|
|
|
_onReorderAccount: (account, oldIdx, newIdx) =>
|
|
|
|
Actions.reorderAccount(account.id, newIdx)
|
|
|
|
|
feat(mail-rules): Per-account mail rules filter incoming, existing mail
Summary:
Originally, this was going to be a totally independent package, but
I wasn't able to isolate the functionality and get it tied in to
the delta-stream consumption. Here's how it currently works:
- The preferences package has a new tab which allows you to edit
mail filters. Filters are saved in a new core store, and a new
stock component (ScenarioEditor) renders the editor. The editor
takes a set of templates that define a value space, and outputs
a valid set of values.
- A new MailFilterProcessor takes messages and creates tasks to
apply the actions from the MailFiltersStore.
- The worker-sync package now uses the MailFilterProcessor to
apply filters /before/ it calls didPassivelyReceiveNewModels,
so filtrs are applied before any notifications are created.
- A new task, ReprocessMailFiltersTask allows you to run filters
on all of your existing mail. It leverages the existing TaskQueue
architecture to: a) resume where it left off if you quit midway,
b) be queryable (for status) from all windows and c) cancelable.
The TaskQueue is a bit strange because it runs performLocal and
performRemote very differently, and I had to use `performRemote`.
(todo refactor soon.)
This diff also changes the EditableList a bit to behave like a
controlled component and render focused / unfocused states.
Test Plan: Run tests, only for actual filter processing atm.
Reviewers: juan, evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D2379
2015-12-23 15:19:32 +08:00
|
|
|
_onSelectAccount: (account) =>
|
2015-12-10 04:35:40 +08:00
|
|
|
@setState(selected: account)
|
|
|
|
|
|
|
|
_onRemoveAccount: (account) =>
|
|
|
|
Actions.removeAccount(account.id)
|
2015-08-15 06:40:11 +08:00
|
|
|
|
2015-12-10 04:35:40 +08:00
|
|
|
# Update account actions
|
|
|
|
#
|
|
|
|
_onAccountUpdated: (account, updates) =>
|
|
|
|
Actions.updateAccount(account.id, updates)
|
|
|
|
|
|
|
|
render: =>
|
|
|
|
<section className="preferences-accounts">
|
|
|
|
<h2>Accounts</h2>
|
|
|
|
<div className="accounts-content">
|
|
|
|
<PreferencesAccountList
|
|
|
|
accounts={@state.accounts}
|
feat(mail-rules): Per-account mail rules filter incoming, existing mail
Summary:
Originally, this was going to be a totally independent package, but
I wasn't able to isolate the functionality and get it tied in to
the delta-stream consumption. Here's how it currently works:
- The preferences package has a new tab which allows you to edit
mail filters. Filters are saved in a new core store, and a new
stock component (ScenarioEditor) renders the editor. The editor
takes a set of templates that define a value space, and outputs
a valid set of values.
- A new MailFilterProcessor takes messages and creates tasks to
apply the actions from the MailFiltersStore.
- The worker-sync package now uses the MailFilterProcessor to
apply filters /before/ it calls didPassivelyReceiveNewModels,
so filtrs are applied before any notifications are created.
- A new task, ReprocessMailFiltersTask allows you to run filters
on all of your existing mail. It leverages the existing TaskQueue
architecture to: a) resume where it left off if you quit midway,
b) be queryable (for status) from all windows and c) cancelable.
The TaskQueue is a bit strange because it runs performLocal and
performRemote very differently, and I had to use `performRemote`.
(todo refactor soon.)
This diff also changes the EditableList a bit to behave like a
controlled component and render focused / unfocused states.
Test Plan: Run tests, only for actual filter processing atm.
Reviewers: juan, evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D2379
2015-12-23 15:19:32 +08:00
|
|
|
selected={@state.selected}
|
2015-12-10 04:35:40 +08:00
|
|
|
onAddAccount={@_onAddAccount}
|
2016-02-02 06:06:54 +08:00
|
|
|
onReorderAccount={@_onReorderAccount}
|
feat(mail-rules): Per-account mail rules filter incoming, existing mail
Summary:
Originally, this was going to be a totally independent package, but
I wasn't able to isolate the functionality and get it tied in to
the delta-stream consumption. Here's how it currently works:
- The preferences package has a new tab which allows you to edit
mail filters. Filters are saved in a new core store, and a new
stock component (ScenarioEditor) renders the editor. The editor
takes a set of templates that define a value space, and outputs
a valid set of values.
- A new MailFilterProcessor takes messages and creates tasks to
apply the actions from the MailFiltersStore.
- The worker-sync package now uses the MailFilterProcessor to
apply filters /before/ it calls didPassivelyReceiveNewModels,
so filtrs are applied before any notifications are created.
- A new task, ReprocessMailFiltersTask allows you to run filters
on all of your existing mail. It leverages the existing TaskQueue
architecture to: a) resume where it left off if you quit midway,
b) be queryable (for status) from all windows and c) cancelable.
The TaskQueue is a bit strange because it runs performLocal and
performRemote very differently, and I had to use `performRemote`.
(todo refactor soon.)
This diff also changes the EditableList a bit to behave like a
controlled component and render focused / unfocused states.
Test Plan: Run tests, only for actual filter processing atm.
Reviewers: juan, evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D2379
2015-12-23 15:19:32 +08:00
|
|
|
onSelectAccount={@_onSelectAccount}
|
2015-12-10 04:35:40 +08:00
|
|
|
onRemoveAccount={@_onRemoveAccount} />
|
|
|
|
<PreferencesAccountDetails
|
|
|
|
account={@state.selected}
|
|
|
|
onAccountUpdated={@_onAccountUpdated} />
|
|
|
|
</div>
|
|
|
|
</section>
|
2015-08-15 06:40:11 +08:00
|
|
|
|
|
|
|
module.exports = PreferencesAccounts
|