friday(*): New "Internal" Nilas features in Sidebar

This commit is contained in:
Ben Gotow 2015-03-20 19:15:32 -07:00
parent 4bfcf625fa
commit 3ec0fccf4e
5 changed files with 256 additions and 0 deletions

View file

@ -0,0 +1,41 @@
_ = require 'underscore-plus'
Reflux = require 'reflux'
request = require 'request'
{FocusedContactsStore} = require 'inbox-exports'
module.exports =
FullContactStore = Reflux.createStore
init: ->
@_accountCache = null
@_applicationCache = null
@listenTo FocusedContactsStore, @_onFocusedContacts
setInterval(( => @_fetchAPIData()), 5 * 60 * 1000)
@_fetchAPIData()
dataForFocusedContact: ->
return {loading: true} if @_accountCache is null or @_applicationCache is null
contact = FocusedContactsStore.focusedContact()
account = _.find @_accountCache, (account) -> account.email is contact.email
apps = undefined
if account
apps = @_applicationCache.accounts["#{account.id}"]
{account, apps}
_onFocusedContacts: ->
@trigger(@)
_fetchAPIData: ->
console.log('Fetching Internal Admin Data')
# Swap the url's to see real data
request 'https://admin.inboxapp.com/api/status/accounts', (err, resp, data) =>
console.log(err) if err
@_accountCache = JSON.parse(data)
@trigger(@)
# Swap the url's to see real data
request 'https://admin.inboxapp.com/api/status/accounts/applications', (err, resp, data) =>
console.log(err) if err
@_applicationCache = JSON.parse(data)
@trigger(@)

View file

@ -0,0 +1,18 @@
_ = require 'underscore-plus'
React = require "react"
SidebarInternal = require "./sidebar-internal"
{ComponentRegistry, WorkspaceStore} = require "inbox-exports"
module.exports =
item: null
activate: (@state={}) ->
ComponentRegistry.register
name: 'SidebarInternal'
view: SidebarInternal
location: WorkspaceStore.Location.MessageListSidebar
deactivate: ->
ComponentRegistry.unregister('SidebarInternal')
serialize: -> @state

View file

@ -0,0 +1,110 @@
_ = 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"
module.exports =
SidebarInternal = React.createClass
getInitialState: ->
data: {}
componentDidMount: ->
@unsubscribe = InternalAdminStore.listen @_onChange
componentWillUnmount: ->
@unsubscribe()
render: ->
<div className="salesforce-sidebar">
<div className="salesforce-sidebar-sections">
<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>
_renderAccount: ->
if @state.data.loading
return <div>Loading...</div>
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>
_renderApplications: ->
if @state.data.loading
return <div>Loading...</div>
if @state.data.apps
@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>
_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 <div style={textAlign:'right'}><span style={float:'left'}>{displayName}:</span>{value}</div>
cjsx
_appUrl: (app) ->
"https://admin.inboxapp.com/apps/#{app.id}"
_appDetails: (app) ->
"No Extra Details"
_onChange: ->
@setState(@_getStateFromStores())
_getStateFromStores: ->
data: InternalAdminStore.dataForFocusedContact()
SidebarInternal.maxWidth = 300
SidebarInternal.minWidth = 200

View file

@ -0,0 +1,13 @@
{
"name": "sidebar-inbox-internal",
"version": "0.1.0",
"main": "./lib/main",
"description": "View user data on the sidebar from inbox internal systems",
"license": "Proprietary",
"private": true,
"engines": {
"atom": "*"
},
"dependencies": {
}
}

View file

@ -0,0 +1,74 @@
.full-contact-sidebar {
padding: @spacing-standard;
padding-bottom: 0;
order: 1;
flex-shrink: 0;
.full-contact {
h1.name {
font-size: 20px;
font-weight: @font-weight-normal;
margin: 0;
padding: 0.6em 0 0.4em 0;
}
.profile-photo {
max-width: 42px;
max-height: 42px;
display: block;
float: right;
margin-left: @spacing-standard;
}
.header {
&:before, &:after { content: " "; display: table; }
&:after { clear: both; }
}
.subheader {
color: @text-color-subtle;
padding: 0 0 @spacing-standard 0;
font-size: @font-size-smaller;
}
}
.social-profiles {
border-top: 1px solid @border-color-divider;
padding-top: 7px;
}
.social-profile {
margin-top: 0.5em;
.social-icon {
padding-top: 6px;
float: left;
}
.social-link {
padding-left: @spacing-double;
font-size: @font-size-smaller;
a {
text-decoration: none;
}
}
}
h2.sidebar-h2 {
font-size: 11px;
font-weight: @font-weight-semi-bold;
text-transform: uppercase;
color: @text-color-very-subtle;
border-bottom: 1px solid @border-color-divider;
margin: 2em 0 1em 0;
}
.sidebar-extra-info {
font-size: 10px;
font-weight: @font-weight-medium;
color: @text-color-subtle;
}
.sidebar-no-info {
font-size: @font-size-smaller;
color: fade(@text-color, 30%);
}
}