diff --git a/internal_packages/sidebar-inbox-internal/lib/internal-admin-store.coffee b/internal_packages/sidebar-inbox-internal/lib/internal-admin-store.coffee deleted file mode 100644 index df30b0d71..000000000 --- a/internal_packages/sidebar-inbox-internal/lib/internal-admin-store.coffee +++ /dev/null @@ -1,87 +0,0 @@ -_ = require 'underscore' -Reflux = require 'reflux' -request = require 'request' -{FocusedContactsStore, - AccountStore, - PriorityUICoordinator} = require 'nylas-exports' - -module.exports = -# The InternalAdminStore manages the data that backs the admin sidebar and emits -# a "trigger" event that the view listens to. -# -# If the Admin sidebar allowed you to take actions, like modifying someone's -# Nylas account, the InternalAdminStore would also listen for those user actions -# and perform business logic. -# -InternalAdminStore = Reflux.createStore - - init: -> - @_accountCache = null - @_enabled = false - @_error = null - - # Stores often listen to other stores to vend correct data to their views. - # Since we serve information about a contact we listen for changes to the - # focused contact. Since we only want to be enabled for @nylas.com emails, - # we listen for changes to available Accounts. - @listenTo FocusedContactsStore, @_onFocusedContacts - @listenTo AccountStore, @_onAccountChanged - - @_onAccountChanged() - - - dataForFocusedContact: -> - return {loading: true} if @_accountCache is null - contact = FocusedContactsStore.focusedContact() - return {} unless contact - - account = _.find @_accountCache, (account) -> account.email is contact.email - apps = undefined - apps = account.applications if account - - # Coffeescript shorthand for {account: account, apps: apps} - {account, apps} - - enabled: -> - @_enabled - - error: -> - @_error - - _onFocusedContacts: -> - # When the user focuses on a contact, we don't need to do any work because we - # cache everything. Just trigger so that our view updates and calls - # `dataForFocusedContact`. - @trigger(@) - - _onAccountChanged: -> - clearInterval(@_fetchInterval) if @_fetchInterval - @_fetchInterval = null - - # We only want to enable this package for users with nylas.com email addresses. - n = AccountStore.current() - if n and n.emailAddress.indexOf('@nylas.com') > 0 - @_fetchInterval = setInterval(( => @_fetchAPIData()), 5 * 60 * 1000) - @_fetchAPIData() - @_enabled = true - else - @_accountCache = null - @_enabled = false - @trigger(@) - - _fetchAPIData: -> - # Make a HTTP request to the Admin service using the `request` library. Using - # the priority UI coordinator ensures that the expensive JSON.parse operation - # doesn't happen while an animation is running. - request 'https://admin.nylas.com/api/status/accounts', (err, resp, data) => - PriorityUICoordinator.settle.then => - if err - @_error = err - else - @_error = null - try - @_accountCache = JSON.parse(data) - catch err - @_error = err - @_accountCache = null - @trigger(@) diff --git a/internal_packages/sidebar-inbox-internal/lib/main.cjsx b/internal_packages/sidebar-inbox-internal/lib/main.cjsx deleted file mode 100644 index b32463901..000000000 --- a/internal_packages/sidebar-inbox-internal/lib/main.cjsx +++ /dev/null @@ -1,16 +0,0 @@ -_ = require 'underscore' -React = require "react" -SidebarInternal = require "./sidebar-internal" -{ComponentRegistry, WorkspaceStore} = require "nylas-exports" - -module.exports = - item: null - - activate: (@state={}) -> - ComponentRegistry.register SidebarInternal, - location: WorkspaceStore.Location.MessageListSidebar - - deactivate: -> - ComponentRegistry.unregister(SidebarInternal) - - serialize: -> @state diff --git a/internal_packages/sidebar-inbox-internal/lib/sidebar-internal.cjsx b/internal_packages/sidebar-inbox-internal/lib/sidebar-internal.cjsx deleted file mode 100644 index 7bbfcd709..000000000 --- a/internal_packages/sidebar-inbox-internal/lib/sidebar-internal.cjsx +++ /dev/null @@ -1,129 +0,0 @@ -_ = require 'underscore' -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" - "account_id": "Account 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 - -