2015-05-20 07:06:59 +08:00
|
|
|
_ = require 'underscore'
|
2015-03-21 10:15:32 +08:00
|
|
|
React = require "react"
|
|
|
|
moment = require 'moment-timezone'
|
|
|
|
InternalAdminStore = require "./internal-admin-store"
|
|
|
|
|
|
|
|
AccountStates =
|
|
|
|
"developer_program": "Developer Program"
|
|
|
|
"trial-expired": "Trial Expired"
|
|
|
|
"paid": "Paid"
|
|
|
|
"cancelled": "Cancelled"
|
|
|
|
|
|
|
|
AccountKeys =
|
|
|
|
"deleted_at": "Deleted At"
|
|
|
|
"healthy": "Healthy"
|
|
|
|
"initial_sync": "Initial Sync"
|
|
|
|
"is_enabled": "Enabled"
|
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
|
|
|
"account_id": "Account Id"
|
2015-03-21 10:15:32 +08:00
|
|
|
"provider": "Provider"
|
|
|
|
"remote_count": "Remote Count"
|
|
|
|
"state": "State"
|
|
|
|
"status": "Status"
|
|
|
|
"sync_disabled_reason": "Sync Disabled Reason"
|
|
|
|
"sync_end_time": "Sync End Time"
|
|
|
|
"sync_error": "Sync Error"
|
|
|
|
"sync_host": "Sync Host"
|
|
|
|
"sync_restart_time": "Sync Restart Time"
|
|
|
|
"sync_start_time": "Sync Start Time"
|
|
|
|
"sync_type": "Sync Type"
|
|
|
|
|
feat(unsafe-components): Wrap injected components, catch exceptions, clean up ComponentRegistry
Summary:
This diff gives the ComponentRegistry a cleaner, smaller API. Instead of querying by name, location or role,
it's now just location and role, and you can register components for one or more location and one or more
roles without assigning the entries in the registry separate names.
When you register with the ComponentRegistry, the syntax is also cleaner and uses the component's displayName
instead of requiring you to provide a name. You also provide the actual component when unregistering, ensuring
that you can't unregister someone else's component.
InjectedComponent and InjectedComponentSet now wrap their children in UnsafeComponent, which prevents
render/component lifecycle problems from propogating.
Existing components have been updated:
1. maxWidth / minWidth are now containerStyles.maxWidth/minWidth
2. displayName is now required to use the CR.
3. containerRequired = false can be provided to exempt a component from being wrapped in an UnsafeComponent.
This is useful because it's slightly faster and keeps DOM flat.
This diff also makes the "Show Component Regions" more awesome. It displays column regions, since they now
use the InjectedComponentSet, and also shows for InjectedComponent as well as InjectedComponentSet.
Change ComponentRegistry syntax, lots more work on safely wrapping items. See description.
Fix for inline flexbox scenarios (message actions)
Allow ~/.inbox/packages to be symlinked to a github repo
Test Plan: Run tests!
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1457
2015-05-01 07:10:15 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
class SidebarInternal extends React.Component
|
|
|
|
@displayName: "SidebarInternal"
|
2015-03-21 10:15:32 +08:00
|
|
|
|
feat(unsafe-components): Wrap injected components, catch exceptions, clean up ComponentRegistry
Summary:
This diff gives the ComponentRegistry a cleaner, smaller API. Instead of querying by name, location or role,
it's now just location and role, and you can register components for one or more location and one or more
roles without assigning the entries in the registry separate names.
When you register with the ComponentRegistry, the syntax is also cleaner and uses the component's displayName
instead of requiring you to provide a name. You also provide the actual component when unregistering, ensuring
that you can't unregister someone else's component.
InjectedComponent and InjectedComponentSet now wrap their children in UnsafeComponent, which prevents
render/component lifecycle problems from propogating.
Existing components have been updated:
1. maxWidth / minWidth are now containerStyles.maxWidth/minWidth
2. displayName is now required to use the CR.
3. containerRequired = false can be provided to exempt a component from being wrapped in an UnsafeComponent.
This is useful because it's slightly faster and keeps DOM flat.
This diff also makes the "Show Component Regions" more awesome. It displays column regions, since they now
use the InjectedComponentSet, and also shows for InjectedComponent as well as InjectedComponentSet.
Change ComponentRegistry syntax, lots more work on safely wrapping items. See description.
Fix for inline flexbox scenarios (message actions)
Allow ~/.inbox/packages to be symlinked to a github repo
Test Plan: Run tests!
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1457
2015-05-01 07:10:15 +08:00
|
|
|
@containerStyles:
|
2015-05-02 03:58:25 +08:00
|
|
|
order: 10
|
feat(unsafe-components): Wrap injected components, catch exceptions, clean up ComponentRegistry
Summary:
This diff gives the ComponentRegistry a cleaner, smaller API. Instead of querying by name, location or role,
it's now just location and role, and you can register components for one or more location and one or more
roles without assigning the entries in the registry separate names.
When you register with the ComponentRegistry, the syntax is also cleaner and uses the component's displayName
instead of requiring you to provide a name. You also provide the actual component when unregistering, ensuring
that you can't unregister someone else's component.
InjectedComponent and InjectedComponentSet now wrap their children in UnsafeComponent, which prevents
render/component lifecycle problems from propogating.
Existing components have been updated:
1. maxWidth / minWidth are now containerStyles.maxWidth/minWidth
2. displayName is now required to use the CR.
3. containerRequired = false can be provided to exempt a component from being wrapped in an UnsafeComponent.
This is useful because it's slightly faster and keeps DOM flat.
This diff also makes the "Show Component Regions" more awesome. It displays column regions, since they now
use the InjectedComponentSet, and also shows for InjectedComponent as well as InjectedComponentSet.
Change ComponentRegistry syntax, lots more work on safely wrapping items. See description.
Fix for inline flexbox scenarios (message actions)
Allow ~/.inbox/packages to be symlinked to a github repo
Test Plan: Run tests!
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1457
2015-05-01 07:10:15 +08:00
|
|
|
maxWidth: 300
|
|
|
|
minWidth: 200
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
constructor: (@props) ->
|
|
|
|
@state = @_getStateFromStores()
|
2015-03-21 10:15:32 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
componentDidMount: =>
|
2015-03-21 10:15:32 +08:00
|
|
|
@unsubscribe = InternalAdminStore.listen @_onChange
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
componentWillUnmount: =>
|
2015-03-21 10:15:32 +08:00
|
|
|
@unsubscribe()
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
render: =>
|
2015-03-22 02:59:47 +08:00
|
|
|
return <div></div> unless @state.enabled
|
|
|
|
|
|
|
|
<div className="internal-sidebar">
|
|
|
|
<div className="internal-sidebar-sections">
|
2015-03-21 10:15:32 +08:00
|
|
|
<div className="sidebar-section">
|
|
|
|
<h2 className="sidebar-h2">Mailsync Account</h2>
|
|
|
|
{@_renderAccount()}
|
|
|
|
</div>
|
|
|
|
<div className="sidebar-section">
|
|
|
|
<h2 className="sidebar-h2">Authenticated Applications</h2>
|
|
|
|
{@_renderApplications()}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_renderAccount: =>
|
2015-03-22 02:59:47 +08:00
|
|
|
if @state.error
|
|
|
|
return <div>{@_errorString()}</div>
|
|
|
|
else if @state.data.loading
|
2015-03-21 10:15:32 +08:00
|
|
|
return <div>Loading...</div>
|
|
|
|
else
|
2015-03-22 02:59:47 +08:00
|
|
|
acct = @state.data.account
|
|
|
|
if acct
|
|
|
|
<div className="sidebar-item">
|
|
|
|
<h3 className="sidebar-h3"><a href={@_accountUrl(acct)}>{acct.email} ({acct.id})</a></h3>
|
|
|
|
<div className="sidebar-extra-info">{@_accountDetails(acct)}</div>
|
|
|
|
</div>
|
|
|
|
else
|
|
|
|
<div>No Matching Account</div>
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_renderApplications: =>
|
2015-03-22 02:59:47 +08:00
|
|
|
if @state.error
|
|
|
|
return <div>{@_errorString()}</div>
|
|
|
|
else if @state.data.loading
|
2015-03-21 10:15:32 +08:00
|
|
|
return <div>Loading...</div>
|
2015-03-22 02:59:47 +08:00
|
|
|
else if @state.data.apps
|
2015-03-21 10:15:32 +08:00
|
|
|
@state.data.apps.map (app) =>
|
|
|
|
<div className="sidebar-item">
|
|
|
|
<h3 className="sidebar-h3"><a href={@_appUrl(app)}>{app.name}</a></h3>
|
|
|
|
<div className="sidebar-extra-info">{@_appDetails(app)}</div>
|
|
|
|
</div>
|
|
|
|
else
|
|
|
|
<div>No Matching Applications</div>
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_errorString: =>
|
2015-03-22 02:59:47 +08:00
|
|
|
if @state.error.toString().indexOf('ENOTFOUND') >= 0
|
2015-05-15 08:08:30 +08:00
|
|
|
"Unable to reach admin.nylas.com"
|
2015-03-22 02:59:47 +08:00
|
|
|
else
|
|
|
|
@state.error.toString()
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_accountUrl: (account) =>
|
2015-05-15 08:08:30 +08:00
|
|
|
"https://admin.nylas.com/accounts/#{account.id}"
|
2015-03-21 10:15:32 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_accountDetails: (account) =>
|
2015-03-21 10:15:32 +08:00
|
|
|
cjsx = []
|
|
|
|
for key, value of account
|
|
|
|
displayName = AccountKeys[key]
|
|
|
|
continue unless displayName
|
|
|
|
continue unless value
|
|
|
|
value = "True" if value is true
|
|
|
|
value = "False" if value is false
|
2015-03-22 02:59:47 +08:00
|
|
|
value = moment.unix(value).format("DD / MM / YYYY h:mm a z") if key.indexOf("_time") > 0
|
2015-08-07 03:22:06 +08:00
|
|
|
cjsx.push <div style={textAlign:'right'} key={key}><span style={float:'left'}>{displayName}:</span>{value}</div>
|
2015-03-21 10:15:32 +08:00
|
|
|
cjsx
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_appUrl: (app) =>
|
2015-05-15 08:08:30 +08:00
|
|
|
"https://admin.nylas.com/apps/#{app.id}"
|
2015-03-21 10:15:32 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_appDetails: (app) =>
|
2015-03-21 10:15:32 +08:00
|
|
|
"No Extra Details"
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_onChange: =>
|
2015-03-21 10:15:32 +08:00
|
|
|
@setState(@_getStateFromStores())
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_getStateFromStores: =>
|
2015-03-21 10:15:32 +08:00
|
|
|
data: InternalAdminStore.dataForFocusedContact()
|
2015-03-22 02:59:47 +08:00
|
|
|
enabled: InternalAdminStore.enabled()
|
|
|
|
error: InternalAdminStore.error()
|
2015-03-21 10:15:32 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
|
|
|
|
module.exports = SidebarInternal
|