mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-29 20:04:59 +08:00
fix(react): Fix several warnings in missing imports
This commit is contained in:
parent
afd8304359
commit
fc255873de
8 changed files with 50 additions and 32 deletions
|
@ -38,17 +38,11 @@ export default class SidebarParticipantPicker extends React.Component {
|
|||
};
|
||||
}
|
||||
|
||||
_renderSortedContacts() {
|
||||
return this.state.sortedContacts.map((contact) => {
|
||||
const selected = contact.email === (this.state.focusedContact || {}).email
|
||||
const key = contact.email + SPLIT_KEY + contact.name;
|
||||
|
||||
return (
|
||||
<option selected={selected} value={key} key={key}>
|
||||
{contact.displayName({includeAccountLabel: true, forceAccountLabel: true})}
|
||||
</option>
|
||||
)
|
||||
});
|
||||
_getKeyForContact(contact) {
|
||||
if (!contact) {
|
||||
return null
|
||||
}
|
||||
return contact.email + SPLIT_KEY + contact.name
|
||||
}
|
||||
|
||||
_onSelectContact = (event) => {
|
||||
|
@ -59,10 +53,24 @@ export default class SidebarParticipantPicker extends React.Component {
|
|||
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() {
|
||||
const {focusedContact} = this.state
|
||||
const value = this._getKeyForContact(focusedContact)
|
||||
return (
|
||||
<div className="sidebar-participant-picker">
|
||||
<select tabIndex={-1} onChange={this._onSelectContact}>
|
||||
<select tabIndex={-1} value={value} onChange={this._onSelectContact}>
|
||||
{this._renderSortedContacts()}
|
||||
</select>
|
||||
</div>
|
||||
|
|
|
@ -718,6 +718,7 @@ body.platform-win32 {
|
|||
text-align: right;
|
||||
select {
|
||||
max-width: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ class PackageSet extends React.Component {
|
|||
|
||||
static propTypes = {
|
||||
title: React.PropTypes.string.isRequired,
|
||||
packages: React.PropTypes.array.isRequired,
|
||||
packages: React.PropTypes.array,
|
||||
emptyText: React.PropTypes.element,
|
||||
}
|
||||
|
||||
|
|
|
@ -55,21 +55,21 @@ class Package extends React.Component {
|
|||
if (this.props.package.installed) {
|
||||
if (['user', 'dev', 'example'].indexOf(this.props.package.category) !== -1 && !this.props.package.theme) {
|
||||
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 {
|
||||
actions.push(<Switch onChange={this._onEnablePackage}>Enable</Switch>);
|
||||
actions.push(<Switch key="enable" onChange={this._onEnablePackage}>Enable</Switch>);
|
||||
}
|
||||
}
|
||||
if (this.props.package.category === 'user') {
|
||||
uninstallButton = <div className="uninstall-plugin" onClick={this._onUninstallPackage}>Uninstall</div>
|
||||
}
|
||||
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) {
|
||||
actions.push(<div className="btn">Installing...</div>);
|
||||
actions.push(<div key="installing" className="btn">Installing...</div>);
|
||||
} 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;
|
||||
|
|
|
@ -65,7 +65,7 @@ class TabInstalled extends React.Component {
|
|||
let devCTA = (<div className="btn btn-large" onClick={this._onEnableDevMode}>Enable Debug Flags</div>);
|
||||
|
||||
if (NylasEnv.inDevMode()) {
|
||||
devPackages = this.state.packages.dev;
|
||||
devPackages = this.state.packages.dev || [];
|
||||
devEmpty = (<span>
|
||||
{`You don't have any packages installed in ~/.nylas/dev/packages. `}
|
||||
These plugins are only loaded when you run the app with debug flags
|
||||
|
|
|
@ -168,7 +168,7 @@ class PreferencesKeymaps extends React.Component {
|
|||
|
||||
_renderBindingsSection = (section) => {
|
||||
return (
|
||||
<section>
|
||||
<section key={`section-${section.title}`}>
|
||||
<div className="shortcut-section-title">{section.title}</div>
|
||||
{section.items.map(this._renderBindingFor)}
|
||||
</section>
|
||||
|
@ -196,14 +196,14 @@ class PreferencesKeymaps extends React.Component {
|
|||
);
|
||||
}
|
||||
|
||||
_renderKeystrokes = (keystrokes) => {
|
||||
_renderKeystrokes = (keystrokes, idx) => {
|
||||
const elements = [];
|
||||
const splitKeystrokes = keystrokes.split(' ');
|
||||
splitKeystrokes.forEach((keystroke) => {
|
||||
elements.push(<span>{this._formatKeystrokes(keystroke)}</span>);
|
||||
elements.push(<span key={keystroke}>{this._formatKeystrokes(keystroke)}</span>);
|
||||
});
|
||||
return (
|
||||
<span className="shortcut-value">{elements}</span>
|
||||
<span key={`keystrokes-${idx}`} className="shortcut-value">{elements}</span>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
_ = require 'underscore'
|
||||
React = require 'react'
|
||||
ReactDOM = require 'react-dom'
|
||||
classNames = require 'classnames'
|
||||
|
||||
{Actions,
|
||||
|
|
|
@ -17,10 +17,18 @@ class NewsletterSignup extends React.Component
|
|||
@_onGetStatus(nextProps) if not _.isEqual(@props, nextProps)
|
||||
|
||||
componentDidMount: =>
|
||||
@_mounted = true
|
||||
@_onGetStatus()
|
||||
|
||||
componentWillUnmount: =>
|
||||
@_mounted = false
|
||||
|
||||
_setState: (state) =>
|
||||
return unless @_mounted
|
||||
@setState(state)
|
||||
|
||||
_onGetStatus: (props = @props) =>
|
||||
@setState({status: 'Pending'})
|
||||
@_setState({status: 'Pending'})
|
||||
EdgehillAPI.request
|
||||
method: 'GET'
|
||||
path: @_path(props)
|
||||
|
@ -28,29 +36,29 @@ class NewsletterSignup extends React.Component
|
|||
if status is 'Never Subscribed'
|
||||
@_onSubscribe()
|
||||
else
|
||||
@setState({status})
|
||||
@_setState({status})
|
||||
error: =>
|
||||
@setState({status: "Error"})
|
||||
@_setState({status: "Error"})
|
||||
|
||||
_onSubscribe: =>
|
||||
@setState({status: 'Pending'})
|
||||
@_setState({status: 'Pending'})
|
||||
EdgehillAPI.request
|
||||
method: 'POST'
|
||||
path: @_path()
|
||||
success: (status) =>
|
||||
@setState({status})
|
||||
@_setState({status})
|
||||
error: =>
|
||||
@setState({status: "Error"})
|
||||
@_setState({status: "Error"})
|
||||
|
||||
_onUnsubscribe: =>
|
||||
@setState({status: 'Pending'})
|
||||
@_setState({status: 'Pending'})
|
||||
EdgehillAPI.request
|
||||
method: 'DELETE'
|
||||
path: @_path()
|
||||
success: (status) =>
|
||||
@setState({status})
|
||||
@_setState({status})
|
||||
error: =>
|
||||
@setState({status: "Error"})
|
||||
@_setState({status: "Error"})
|
||||
|
||||
_path: (props = @props) =>
|
||||
"/newsletter-subscription/#{encodeURIComponent(props.emailAddress)}?name=#{encodeURIComponent(props.name)}"
|
||||
|
|
Loading…
Reference in a new issue