_ = require 'underscore-plus' 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" "namespace_id": "Namespace Id" "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" class SidebarInternal extends React.Component @displayName: "SidebarInternal" @containerStyles: order: 10 maxWidth: 300 minWidth: 200 constructor: (@props) -> @state = @_getStateFromStores() componentDidMount: => @unsubscribe = InternalAdminStore.listen @_onChange componentWillUnmount: => @unsubscribe() render: => return
unless @state.enabled

Mailsync Account

{@_renderAccount()}

Authenticated Applications

{@_renderApplications()}
_renderAccount: => if @state.error return
{@_errorString()}
else if @state.data.loading return
Loading...
else acct = @state.data.account if acct

{acct.email} ({acct.id})

{@_accountDetails(acct)}
else
No Matching Account
_renderApplications: => if @state.error return
{@_errorString()}
else if @state.data.loading return
Loading...
else if @state.data.apps @state.data.apps.map (app) =>

{app.name}

{@_appDetails(app)}
else
No Matching Applications
_errorString: => if @state.error.toString().indexOf('ENOTFOUND') >= 0 "Unable to reach admin.nilas.com" else @state.error.toString() _accountUrl: (account) => "https://admin.inboxapp.com/accounts/#{account.id}" _accountDetails: (account) => 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 value = moment.unix(value).format("DD / MM / YYYY h:mm a z") if key.indexOf("_time") > 0 cjsx.push
{displayName}:{value}
cjsx _appUrl: (app) => "https://admin.inboxapp.com/apps/#{app.id}" _appDetails: (app) => "No Extra Details" _onChange: => @setState(@_getStateFromStores()) _getStateFromStores: => data: InternalAdminStore.dataForFocusedContact() enabled: InternalAdminStore.enabled() error: InternalAdminStore.error() module.exports = SidebarInternal