fix(react): Fix several warnings in missing imports

This commit is contained in:
Juan Tejada 2016-04-05 14:49:03 -07:00
parent afd8304359
commit fc255873de
8 changed files with 50 additions and 32 deletions

View file

@ -38,17 +38,11 @@ export default class SidebarParticipantPicker extends React.Component {
}; };
} }
_renderSortedContacts() { _getKeyForContact(contact) {
return this.state.sortedContacts.map((contact) => { if (!contact) {
const selected = contact.email === (this.state.focusedContact || {}).email return null
const key = contact.email + SPLIT_KEY + contact.name; }
return contact.email + SPLIT_KEY + contact.name
return (
<option selected={selected} value={key} key={key}>
{contact.displayName({includeAccountLabel: true, forceAccountLabel: true})}
</option>
)
});
} }
_onSelectContact = (event) => { _onSelectContact = (event) => {
@ -59,10 +53,24 @@ export default class SidebarParticipantPicker extends React.Component {
return Actions.focusContact(contact); return Actions.focusContact(contact);
} }
_renderSortedContacts() {
return this.state.sortedContacts.map((contact) => {
const key = this._getKeyForContact(contact)
return (
<option value={key} key={key}>
{contact.displayName({includeAccountLabel: true, forceAccountLabel: true})}
</option>
)
});
}
render() { render() {
const {focusedContact} = this.state
const value = this._getKeyForContact(focusedContact)
return ( return (
<div className="sidebar-participant-picker"> <div className="sidebar-participant-picker">
<select tabIndex={-1} onChange={this._onSelectContact}> <select tabIndex={-1} value={value} onChange={this._onSelectContact}>
{this._renderSortedContacts()} {this._renderSortedContacts()}
</select> </select>
</div> </div>

View file

@ -718,6 +718,7 @@ body.platform-win32 {
text-align: right; text-align: right;
select { select {
max-width: 100%; max-width: 100%;
width: 100%;
} }
} }

View file

@ -7,7 +7,7 @@ class PackageSet extends React.Component {
static propTypes = { static propTypes = {
title: React.PropTypes.string.isRequired, title: React.PropTypes.string.isRequired,
packages: React.PropTypes.array.isRequired, packages: React.PropTypes.array,
emptyText: React.PropTypes.element, emptyText: React.PropTypes.element,
} }

View file

@ -55,21 +55,21 @@ class Package extends React.Component {
if (this.props.package.installed) { if (this.props.package.installed) {
if (['user', 'dev', 'example'].indexOf(this.props.package.category) !== -1 && !this.props.package.theme) { if (['user', 'dev', 'example'].indexOf(this.props.package.category) !== -1 && !this.props.package.theme) {
if (this.props.package.enabled) { if (this.props.package.enabled) {
actions.push(<Switch checked onChange={this._onDisablePackage}>Disable</Switch>); actions.push(<Switch key="disable" checked onChange={this._onDisablePackage}>Disable</Switch>);
} else { } else {
actions.push(<Switch onChange={this._onEnablePackage}>Enable</Switch>); actions.push(<Switch key="enable" onChange={this._onEnablePackage}>Enable</Switch>);
} }
} }
if (this.props.package.category === 'user') { if (this.props.package.category === 'user') {
uninstallButton = <div className="uninstall-plugin" onClick={this._onUninstallPackage}>Uninstall</div> uninstallButton = <div className="uninstall-plugin" onClick={this._onUninstallPackage}>Uninstall</div>
} }
if (this.props.package.category === 'dev') { if (this.props.package.category === 'dev') {
actions.push(<div className="btn" onClick={this._onShowPackage}>Show...</div>); actions.push(<div key="show-package" className="btn" onClick={this._onShowPackage}>Show...</div>);
} }
} else if (this.props.package.installing) { } else if (this.props.package.installing) {
actions.push(<div className="btn">Installing...</div>); actions.push(<div key="installing" className="btn">Installing...</div>);
} else { } else {
actions.push(<div className="btn" onClick={this._onInstallPackage}>Install</div>); actions.push(<div key="install" className="btn" onClick={this._onInstallPackage}>Install</div>);
} }
const {name, description, title} = this.props.package; const {name, description, title} = this.props.package;

View file

@ -65,7 +65,7 @@ class TabInstalled extends React.Component {
let devCTA = (<div className="btn btn-large" onClick={this._onEnableDevMode}>Enable Debug Flags</div>); let devCTA = (<div className="btn btn-large" onClick={this._onEnableDevMode}>Enable Debug Flags</div>);
if (NylasEnv.inDevMode()) { if (NylasEnv.inDevMode()) {
devPackages = this.state.packages.dev; devPackages = this.state.packages.dev || [];
devEmpty = (<span> devEmpty = (<span>
{`You don't have any packages installed in ~/.nylas/dev/packages. `} {`You don't have any packages installed in ~/.nylas/dev/packages. `}
These plugins are only loaded when you run the app with debug flags These plugins are only loaded when you run the app with debug flags

View file

@ -168,7 +168,7 @@ class PreferencesKeymaps extends React.Component {
_renderBindingsSection = (section) => { _renderBindingsSection = (section) => {
return ( return (
<section> <section key={`section-${section.title}`}>
<div className="shortcut-section-title">{section.title}</div> <div className="shortcut-section-title">{section.title}</div>
{section.items.map(this._renderBindingFor)} {section.items.map(this._renderBindingFor)}
</section> </section>
@ -196,14 +196,14 @@ class PreferencesKeymaps extends React.Component {
); );
} }
_renderKeystrokes = (keystrokes) => { _renderKeystrokes = (keystrokes, idx) => {
const elements = []; const elements = [];
const splitKeystrokes = keystrokes.split(' '); const splitKeystrokes = keystrokes.split(' ');
splitKeystrokes.forEach((keystroke) => { splitKeystrokes.forEach((keystroke) => {
elements.push(<span>{this._formatKeystrokes(keystroke)}</span>); elements.push(<span key={keystroke}>{this._formatKeystrokes(keystroke)}</span>);
}); });
return ( return (
<span className="shortcut-value">{elements}</span> <span key={`keystrokes-${idx}`} className="shortcut-value">{elements}</span>
); );
} }

View file

@ -1,5 +1,6 @@
_ = require 'underscore' _ = require 'underscore'
React = require 'react' React = require 'react'
ReactDOM = require 'react-dom'
classNames = require 'classnames' classNames = require 'classnames'
{Actions, {Actions,

View file

@ -17,10 +17,18 @@ class NewsletterSignup extends React.Component
@_onGetStatus(nextProps) if not _.isEqual(@props, nextProps) @_onGetStatus(nextProps) if not _.isEqual(@props, nextProps)
componentDidMount: => componentDidMount: =>
@_mounted = true
@_onGetStatus() @_onGetStatus()
componentWillUnmount: =>
@_mounted = false
_setState: (state) =>
return unless @_mounted
@setState(state)
_onGetStatus: (props = @props) => _onGetStatus: (props = @props) =>
@setState({status: 'Pending'}) @_setState({status: 'Pending'})
EdgehillAPI.request EdgehillAPI.request
method: 'GET' method: 'GET'
path: @_path(props) path: @_path(props)
@ -28,29 +36,29 @@ class NewsletterSignup extends React.Component
if status is 'Never Subscribed' if status is 'Never Subscribed'
@_onSubscribe() @_onSubscribe()
else else
@setState({status}) @_setState({status})
error: => error: =>
@setState({status: "Error"}) @_setState({status: "Error"})
_onSubscribe: => _onSubscribe: =>
@setState({status: 'Pending'}) @_setState({status: 'Pending'})
EdgehillAPI.request EdgehillAPI.request
method: 'POST' method: 'POST'
path: @_path() path: @_path()
success: (status) => success: (status) =>
@setState({status}) @_setState({status})
error: => error: =>
@setState({status: "Error"}) @_setState({status: "Error"})
_onUnsubscribe: => _onUnsubscribe: =>
@setState({status: 'Pending'}) @_setState({status: 'Pending'})
EdgehillAPI.request EdgehillAPI.request
method: 'DELETE' method: 'DELETE'
path: @_path() path: @_path()
success: (status) => success: (status) =>
@setState({status}) @_setState({status})
error: => error: =>
@setState({status: "Error"}) @_setState({status: "Error"})
_path: (props = @props) => _path: (props = @props) =>
"/newsletter-subscription/#{encodeURIComponent(props.emailAddress)}?name=#{encodeURIComponent(props.name)}" "/newsletter-subscription/#{encodeURIComponent(props.emailAddress)}?name=#{encodeURIComponent(props.name)}"