rm(fullcontact): Deprecated in favor of new contact sidebar

This commit is contained in:
Ben Gotow 2016-05-04 14:41:13 -07:00
parent 66cb0a6a77
commit 34f1ca0ba8
6 changed files with 0 additions and 311 deletions

View file

@ -1,41 +0,0 @@
_ = require 'underscore'
Reflux = require 'reflux'
request = require 'request'
{Contact,
AccountStore
ContactStore,
DatabaseStore,
FocusedContactsStore} = require 'nylas-exports'
FullContactStore = Reflux.createStore
init: ->
dataForContact: (contact) ->
return {} unless contact
if contact.thirdPartyData["FullContact"]
return contact.thirdPartyData["FullContact"]
else
@_attachFullcontactDataToContact(contact)
return {}
_attachFullcontactDataToContact: (contact) ->
email = contact.email.toLowerCase().trim()
return if email.length is 0
url = "https://api.fullcontact.com/v2/person.json?email=#{email}&apiKey=eadcbaf0286562a"
request url, (err, resp, data) =>
return if err
return if resp.statusCode != 200
try
data = JSON.parse(data)
contact.title = data.organizations?[0]?["title"]
contact.company = data.organizations?[0]?["name"]
contact.thirdPartyData ?= {}
contact.thirdPartyData["FullContact"] = data
DatabaseStore.inTransaction (t) =>
t.persistModel(contact)
.then =>
@trigger()
module.exports = FullContactStore

View file

@ -1,16 +0,0 @@
_ = require 'underscore'
React = require "react"
SidebarFullContact = require "./sidebar-fullcontact"
{ComponentRegistry, WorkspaceStore} = require "nylas-exports"
module.exports =
item: null
activate: (@state={}) ->
# ComponentRegistry.register SidebarFullContact,
# role: "MessageListSidebar:ContactCard"
deactivate: ->
# ComponentRegistry.unregister(SidebarFullContact)
serialize: -> @state

View file

@ -1,132 +0,0 @@
_ = require 'underscore'
React = require "react"
{Actions} = require 'nylas-exports'
{RetinaImg} = require 'nylas-component-kit'
class SidebarFullContactDetails extends React.Component
@displayName: "SidebarFullContactDetails"
@propTypes:
contact: React.PropTypes.object
fullContactData: React.PropTypes.object
render: =>
<div className="contact-card-fullcontact">
<div className="header">
{@_profilePhoto()}
<h1 className="name">{@_name()}</h1>
<div className="email">{@_email()}</div>
</div>
<div className="subheader"
style={display: if @_showSubheader() then "block" else "none"}>
<div className="title">{@_title()}</div>
<div className="company">{@_company()}</div>
</div>
<div className="social-profiles"
style={display: if @_showSocialProfiles() then "block" else "none"}>
{@_socialProfiles()}
</div>
{@_noInfo()}
</div>
_socialProfiles: =>
profiles = @_profiles()
return profiles.map (profile) =>
<div className="social-profile">
<RetinaImg
className="social-icon"
name="#{profile.typeId}-icon.png"
mode={RetinaImg.Mode.ContentIsMask} />
<div className="social-link">
<a href={profile.url}>{@_username(profile)}</a>
{@_twitterBio(profile)}
</div>
</div>
_profiles: =>
profiles = @props.fullContactData.socialProfiles ? []
profiles = _.filter profiles, (p) => @_supportedProfileTypes[p.typeId]
_supportedProfileTypes:
twitter: true
linkedin: true
facebook: true
_showSocialProfiles: =>
@_profiles().length > 0
_username: (profile) =>
if (profile.username ? "").length > 0
if profile.typeId is "twitter"
return "@#{profile.username}"
else
return profile.username
else
return profile.typeName
_noInfo: =>
if not @_showSocialProfiles() and not @_showSubheader()
<div className="sidebar-no-info">No additional information available.</div>
else return ""
_twitterBio: (profile) =>
return "" unless profile.typeId is "twitter"
return "" unless profile.bio?.length > 0
# http://stackoverflow.com/a/13398311/793472
twitterRegex = /(^|[^@\w])@(\w{1,15})\b/g
replace = '$1<a href="https://twitter.com/$2">@$2</a>'
bio = profile.bio.replace(twitterRegex, replace)
<div className="bio sidebar-extra-info"
dangerouslySetInnerHTML={{__html: bio}}></div>
_showSubheader: =>
@_title().length > 0 or @_company().length > 0
_name: =>
(@props.fullContactData.contactInfo?.fullName) ? @props.contact?.name ? ""
_email: =>
email = @props.contact.email ? ""
if @_name().toLowerCase().trim() isnt email.toLowerCase().trim()
return email
else return ""
_title: =>
org = @_primaryOrg()
return "" unless org?
if org.current and org.title?
return org.title
else if not org.current and org.title?
return "Former #{org.title}"
else return ""
_company: =>
location = @props.fullContactData.demographics?.locationGeneral ? ""
name = @_primaryOrg()?.name ? ""
if name.length > 0 and location.length > 0
return "#{name} (#{location})"
else if name.length > 0
return name
else if location.length > 0
return "(#{location})"
else return ""
_primaryOrg: =>
orgs = @props.fullContactData.organizations ? []
org = _.findWhere orgs, isPrimary: true
if not org? then org = orgs[0]
return org
_profilePhoto: =>
photos = @props.fullContactData.photos ? []
photo = _.findWhere photo, isPrimary: true
if not photo? then photo = _.findWhere photo, typeId: "linkedin"
if not photo? then photo = photos[0]
if photo? and photo.url?
return <img src={photo.url} className="profile-photo" />
else return ""
module.exports = SidebarFullContactDetails

View file

@ -1,37 +0,0 @@
_ = require 'underscore'
React = require "react"
ReactCSSTransitionGroup = require 'react-addons-css-transition-group'
FullContactStore = require "./fullcontact-store"
{InjectedComponentSet} = require 'nylas-component-kit'
SidebarFullContactDetails = require "./sidebar-fullcontact-details"
class SidebarFullContact extends React.Component
@displayName: "SidebarFullContact"
@propTypes:
contact: React.PropTypes.object
constructor: (@props) ->
@state = @_getStateFromStores()
componentDidMount: =>
@unsubscribe = FullContactStore.listen(@_onChange)
componentWillUnmount: =>
@unsubscribe()
render: =>
<SidebarFullContactDetails
contact={@props.contact}
fullContactData={@state.focusedContactData} />
_onChange: =>
@setState(@_getStateFromStores())
_getStateFromStores: =>
focusedContactData: FullContactStore.dataForContact(@props.contact)
module.exports = SidebarFullContact

View file

@ -1,13 +0,0 @@
{
"name": "sidebar-fullcontact",
"version": "0.1.0",
"main": "./lib/main",
"description": "View user data on the sidebar via fullcontact",
"license": "GPL-3.0",
"private": true,
"engines": {
"nylas": "*"
},
"dependencies": {
}
}

View file

@ -1,72 +0,0 @@
@import "ui-variables";
.contact-card-fullcontact {
padding-bottom: 0;
order: 1;
flex-shrink: 0;
color: @text-color;
-webkit-user-select:text;
img.content-mask { background-color: @text-color; }
h1.name {
font-size: 20px;
font-weight: @font-weight-normal;
margin: 0;
padding: 0.6em 0 0.4em 0;
text-overflow: ellipsis;
overflow: hidden;
}
.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;
}
.email {
word-break: break-all;
}
}
.social-profiles {
border-top: 1px solid @border-color-divider;
padding-top: 7px;
}
.social-profile {
margin-top: 0.5em;
.social-icon {
margin-top: 6px;
float: left;
}
.social-link {
padding-left: @spacing-double;
font-size: @font-size-smaller;
a {
text-decoration: none;
}
}
}
.sidebar-extra-info {
font-size: 12px;
font-weight: @font-weight-medium;
color: @text-color-subtle;
}
.sidebar-no-info {
font-size: @font-size-smaller;
color: fade(@text-color, 30%);
}