2015-05-20 06:59:37 +08:00
|
|
|
React = require 'react'
|
2015-05-20 07:06:59 +08:00
|
|
|
_ = require 'underscore'
|
2015-05-20 06:59:37 +08:00
|
|
|
classNames = require 'classnames'
|
|
|
|
NotificationStore = require './notifications-store'
|
|
|
|
{Actions,
|
|
|
|
TaskQueue,
|
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,
|
feat(work): Create the "Work" window, move TaskQueue, Nylas sync workers
Summary:
Move sync workers and Edgehill token checks to work window
Move the task queue and database setup to the work window
Move ContactStore background refresh to work window
Store the task queue in the database
WIP
The TaskQueue now puts tasks in the database instead of in a file, which also means it can be observed
Move all delta sync and initial sync to a package, make NylasSyncStore which exposes read-only sync state
DraftStore no longer reads task status. Once you set the "sending" bit on a draft, it never gets unset. But that's fine actually.
If your package lists windowTypes, you *only* get loaded in those windowTypes. If you specify no windowTypes, you get loaded in the root window.
This means that onboarding, worker-ui, worker-sync, etc. no longer get loaded into the main window
ActivitySidebar has a special little store that observes the task queue since it's no longer in the window
Move "toggle component regions" / "toggle react remote" to the Developer menu
Move sync worker specs, update draft store specs to not rely on TaskQueue at all
Test Plan: Run existing tests, all pass
Reviewers: dillon, evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D1936
2015-08-28 07:39:40 +08:00
|
|
|
NylasSyncStatusStore,
|
|
|
|
TaskQueueStatusStore,
|
2015-05-20 06:59:37 +08:00
|
|
|
NylasAPI} = require 'nylas-exports'
|
2015-09-19 07:15:15 +08:00
|
|
|
ActivitySidebarLongPollStore = require './activity-sidebar-long-poll-store'
|
|
|
|
{TimeoutTransitionGroup, RetinaImg} = require 'nylas-component-kit'
|
2015-05-20 06:59:37 +08:00
|
|
|
|
|
|
|
class ActivitySidebar extends React.Component
|
|
|
|
@displayName: 'ActivitySidebar'
|
|
|
|
|
|
|
|
@containerRequired: false
|
2015-06-03 10:04:21 +08:00
|
|
|
@containerStyles:
|
|
|
|
minWidth: 165
|
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
|
|
|
maxWidth: 400
|
2015-05-20 06:59:37 +08:00
|
|
|
|
|
|
|
constructor: (@props) ->
|
|
|
|
@state = @_getStateFromStores()
|
|
|
|
|
|
|
|
componentDidMount: =>
|
|
|
|
@_unlisteners = []
|
feat(work): Create the "Work" window, move TaskQueue, Nylas sync workers
Summary:
Move sync workers and Edgehill token checks to work window
Move the task queue and database setup to the work window
Move ContactStore background refresh to work window
Store the task queue in the database
WIP
The TaskQueue now puts tasks in the database instead of in a file, which also means it can be observed
Move all delta sync and initial sync to a package, make NylasSyncStore which exposes read-only sync state
DraftStore no longer reads task status. Once you set the "sending" bit on a draft, it never gets unset. But that's fine actually.
If your package lists windowTypes, you *only* get loaded in those windowTypes. If you specify no windowTypes, you get loaded in the root window.
This means that onboarding, worker-ui, worker-sync, etc. no longer get loaded into the main window
ActivitySidebar has a special little store that observes the task queue since it's no longer in the window
Move "toggle component regions" / "toggle react remote" to the Developer menu
Move sync worker specs, update draft store specs to not rely on TaskQueue at all
Test Plan: Run existing tests, all pass
Reviewers: dillon, evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D1936
2015-08-28 07:39:40 +08:00
|
|
|
@_unlisteners.push TaskQueueStatusStore.listen @_onDataChanged
|
|
|
|
@_unlisteners.push NylasSyncStatusStore.listen @_onDataChanged
|
2015-05-20 06:59:37 +08:00
|
|
|
@_unlisteners.push NotificationStore.listen @_onDataChanged
|
2015-09-19 07:15:15 +08:00
|
|
|
@_unlisteners.push ActivitySidebarLongPollStore.listen @_onDeltaReceived
|
2015-05-20 06:59:37 +08:00
|
|
|
|
|
|
|
componentWillUnmount: =>
|
|
|
|
unlisten() for unlisten in @_unlisteners
|
|
|
|
@_workerUnlisten() if @_workerUnlisten
|
|
|
|
|
|
|
|
render: =>
|
|
|
|
items = [].concat(@_renderSyncActivityItem(), @_renderNotificationActivityItems(), @_renderTaskActivityItems())
|
|
|
|
|
2015-09-19 07:15:15 +08:00
|
|
|
if @state.receivingDelta
|
|
|
|
items.push @_renderDeltaSyncActivityItem()
|
|
|
|
|
2015-05-20 06:59:37 +08:00
|
|
|
names = classNames
|
|
|
|
"sidebar-activity": true
|
|
|
|
"sidebar-activity-error": error?
|
|
|
|
|
2015-09-15 02:04:24 +08:00
|
|
|
wrapperClass = "sidebar-activity-transition-wrapper "
|
|
|
|
|
|
|
|
if items.length is 0
|
|
|
|
wrapperClass += "sidebar-activity-empty"
|
|
|
|
else
|
|
|
|
inside = <TimeoutTransitionGroup
|
|
|
|
className={names}
|
|
|
|
leaveTimeout={625}
|
|
|
|
enterTimeout={125}
|
|
|
|
transitionName="activity-opacity">
|
|
|
|
{items}
|
|
|
|
</TimeoutTransitionGroup>
|
|
|
|
|
2015-05-20 06:59:37 +08:00
|
|
|
<TimeoutTransitionGroup
|
2015-09-15 02:04:24 +08:00
|
|
|
className={wrapperClass}
|
2015-05-20 06:59:37 +08:00
|
|
|
leaveTimeout={625}
|
|
|
|
enterTimeout={125}
|
2015-09-15 02:04:24 +08:00
|
|
|
transitionName="activity-opacity">
|
|
|
|
{inside}
|
2015-05-20 06:59:37 +08:00
|
|
|
</TimeoutTransitionGroup>
|
|
|
|
|
|
|
|
_renderSyncActivityItem: =>
|
|
|
|
count = 0
|
|
|
|
fetched = 0
|
|
|
|
progress = 0
|
|
|
|
incomplete = 0
|
|
|
|
error = null
|
|
|
|
|
feat(work): Create the "Work" window, move TaskQueue, Nylas sync workers
Summary:
Move sync workers and Edgehill token checks to work window
Move the task queue and database setup to the work window
Move ContactStore background refresh to work window
Store the task queue in the database
WIP
The TaskQueue now puts tasks in the database instead of in a file, which also means it can be observed
Move all delta sync and initial sync to a package, make NylasSyncStore which exposes read-only sync state
DraftStore no longer reads task status. Once you set the "sending" bit on a draft, it never gets unset. But that's fine actually.
If your package lists windowTypes, you *only* get loaded in those windowTypes. If you specify no windowTypes, you get loaded in the root window.
This means that onboarding, worker-ui, worker-sync, etc. no longer get loaded into the main window
ActivitySidebar has a special little store that observes the task queue since it's no longer in the window
Move "toggle component regions" / "toggle react remote" to the Developer menu
Move sync worker specs, update draft store specs to not rely on TaskQueue at all
Test Plan: Run existing tests, all pass
Reviewers: dillon, evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D1936
2015-08-28 07:39:40 +08:00
|
|
|
for acctId, state of @state.sync
|
|
|
|
for model, modelState of state
|
|
|
|
incomplete += 1 unless modelState.complete
|
|
|
|
error ?= modelState.error
|
|
|
|
if modelState.count
|
|
|
|
count += modelState.count / 1
|
|
|
|
fetched += modelState.fetched / 1
|
2015-05-20 06:59:37 +08:00
|
|
|
|
|
|
|
progress = (fetched / count) * 100 if count > 0
|
|
|
|
|
|
|
|
if incomplete is 0
|
|
|
|
return []
|
|
|
|
else if error
|
2015-08-07 03:22:06 +08:00
|
|
|
<div className="item" key="initial-sync">
|
2015-05-20 06:59:37 +08:00
|
|
|
<div className="inner">Initial sync encountered an error. Waiting to retry...
|
|
|
|
<div className="btn btn-emphasis" onClick={@_onTryAgain}>Try Again</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
else
|
2015-08-07 03:22:06 +08:00
|
|
|
<div className="item" key="initial-sync">
|
2015-05-20 06:59:37 +08:00
|
|
|
<div className="progress-track">
|
|
|
|
<div className="progress" style={width: "#{progress}%"}></div>
|
|
|
|
</div>
|
2015-09-23 05:05:26 +08:00
|
|
|
<div className="inner">Syncing mail data…</div>
|
2015-05-20 06:59:37 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
_renderTaskActivityItems: =>
|
|
|
|
summary = {}
|
|
|
|
|
|
|
|
@state.tasks.map (task) ->
|
|
|
|
label = task.label?()
|
|
|
|
return unless label
|
|
|
|
summary[label] ?= 0
|
|
|
|
summary[label] += 1
|
|
|
|
|
|
|
|
_.pairs(summary).map ([label, count]) ->
|
|
|
|
<div className="item" key={label}>
|
|
|
|
<div className="inner">
|
|
|
|
{label} <span className="count">({count})</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2015-09-19 07:15:15 +08:00
|
|
|
_renderDeltaSyncActivityItem: =>
|
|
|
|
<div className="item" key="delta-sync-item">
|
2015-09-23 05:05:26 +08:00
|
|
|
<div style={padding: "8px 7px 0 10px", float: "left"}>
|
2015-09-19 07:15:15 +08:00
|
|
|
<RetinaImg name="sending-spinner.gif" mode={RetinaImg.Mode.ContentPreserve} />
|
|
|
|
</div>
|
|
|
|
<div className="inner">
|
2015-09-23 05:05:26 +08:00
|
|
|
Syncing mail data…
|
2015-09-19 07:15:15 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2015-05-20 06:59:37 +08:00
|
|
|
_renderNotificationActivityItems: =>
|
|
|
|
@state.notifications.map (notification) ->
|
|
|
|
<div className="item" key={notification.id}>
|
|
|
|
<div className="inner">
|
|
|
|
{notification.message}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
_onTryAgain: =>
|
2015-08-29 04:24:05 +08:00
|
|
|
Actions.retryInitialSync()
|
2015-05-20 06:59:37 +08:00
|
|
|
|
|
|
|
_onDataChanged: =>
|
|
|
|
@setState(@_getStateFromStores())
|
|
|
|
|
|
|
|
_getStateFromStores: =>
|
|
|
|
notifications: NotificationStore.notifications()
|
feat(work): Create the "Work" window, move TaskQueue, Nylas sync workers
Summary:
Move sync workers and Edgehill token checks to work window
Move the task queue and database setup to the work window
Move ContactStore background refresh to work window
Store the task queue in the database
WIP
The TaskQueue now puts tasks in the database instead of in a file, which also means it can be observed
Move all delta sync and initial sync to a package, make NylasSyncStore which exposes read-only sync state
DraftStore no longer reads task status. Once you set the "sending" bit on a draft, it never gets unset. But that's fine actually.
If your package lists windowTypes, you *only* get loaded in those windowTypes. If you specify no windowTypes, you get loaded in the root window.
This means that onboarding, worker-ui, worker-sync, etc. no longer get loaded into the main window
ActivitySidebar has a special little store that observes the task queue since it's no longer in the window
Move "toggle component regions" / "toggle react remote" to the Developer menu
Move sync worker specs, update draft store specs to not rely on TaskQueue at all
Test Plan: Run existing tests, all pass
Reviewers: dillon, evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D1936
2015-08-28 07:39:40 +08:00
|
|
|
tasks: TaskQueueStatusStore.queue()
|
|
|
|
sync: NylasSyncStatusStore.state()
|
2015-05-20 06:59:37 +08:00
|
|
|
|
2015-09-23 05:05:26 +08:00
|
|
|
_onDeltaReceived: (countDeltas) =>
|
|
|
|
tooSmallForNotification = countDeltas <= 10
|
|
|
|
return if tooSmallForNotification
|
|
|
|
|
2015-09-19 07:15:15 +08:00
|
|
|
if @_timeoutId
|
|
|
|
clearTimeout @_timeoutId
|
|
|
|
|
|
|
|
@_timeoutId = setTimeout(( =>
|
|
|
|
delete @_timeoutId
|
|
|
|
@setState receivingDelta: false
|
2015-09-23 05:05:26 +08:00
|
|
|
), 30000)
|
2015-09-19 07:15:15 +08:00
|
|
|
|
|
|
|
@setState receivingDelta: true
|
|
|
|
|
2015-05-20 06:59:37 +08:00
|
|
|
|
|
|
|
module.exports = ActivitySidebar
|