mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-09 12:51:50 +08:00
fix(lint): Fix new eslint rule introduced with babel-eslint upgrade.
See https://phabricator.babeljs.io/T6925
This commit is contained in:
parent
d9c4739f78
commit
6a14d5b561
8 changed files with 80 additions and 80 deletions
|
@ -7,7 +7,7 @@ class TemplatePicker extends React.Component {
|
|||
|
||||
static propTypes = {
|
||||
draftClientId: React.PropTypes.string,
|
||||
}
|
||||
};
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
@ -49,20 +49,20 @@ class TemplatePicker extends React.Component {
|
|||
searchValue: newSearch,
|
||||
templates: this._filteredTemplates(newSearch),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_onChooseTemplate = (template) => {
|
||||
Actions.insertTemplateId({templateId: template.id, draftClientId: this.props.draftClientId});
|
||||
return this.refs.popover.close();
|
||||
}
|
||||
};
|
||||
|
||||
_onManageTemplates = () => {
|
||||
return Actions.showTemplates();
|
||||
}
|
||||
};
|
||||
|
||||
_onNewTemplate = () => {
|
||||
return Actions.createTemplate({draftClientId: this.props.draftClientId});
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const button = (
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import {DraftStore, React} from 'nylas-exports';
|
||||
|
||||
class TemplateStatusBar extends React.Component {
|
||||
static displayName = 'TemplateStatusBar'
|
||||
static displayName = 'TemplateStatusBar';
|
||||
|
||||
static propTypes = {
|
||||
draftClientId: React.PropTypes.string,
|
||||
}
|
||||
};
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
@ -34,7 +34,7 @@ class TemplateStatusBar extends React.Component {
|
|||
textAlign: 'center',
|
||||
width: 580,
|
||||
margin: 'auto',
|
||||
}
|
||||
};
|
||||
|
||||
_onDraftChange() {
|
||||
this.setState({draft: this._proxy.draft()});
|
||||
|
|
|
@ -28,7 +28,7 @@ import {ScrollRegion, Contenteditable} from 'nylas-component-kit';
|
|||
*/
|
||||
|
||||
class ComposerEditor extends Component {
|
||||
static displayName = 'ComposerEditor'
|
||||
static displayName = 'ComposerEditor';
|
||||
|
||||
/**
|
||||
* This function will return the {DOMRect} for the parent component
|
||||
|
@ -78,7 +78,7 @@ class ComposerEditor extends Component {
|
|||
scrollTo: PropTypes.func,
|
||||
getComposerBoundingRect: PropTypes.func,
|
||||
}),
|
||||
}
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
@ -193,7 +193,7 @@ class ComposerEditor extends Component {
|
|||
clientId: this.props.draftClientId,
|
||||
position: ScrollRegion.ScrollPosition.Bottom,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
@ -208,7 +208,7 @@ class ComposerEditor extends Component {
|
|||
const parentRect = this.props.parentActions.getComposerBoundingRect();
|
||||
const selfRect = editableNode.getBoundingClientRect();
|
||||
return Math.abs(parentRect.bottom - selfRect.bottom) <= 250;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
@ -253,14 +253,14 @@ class ComposerEditor extends Component {
|
|||
this.props.parentActions.scrollTo({rect});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Handlers
|
||||
|
||||
_onExtensionsChanged = ()=> {
|
||||
this.setState({extensions: ExtensionRegistry.Composer.extensions()});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Renderers
|
||||
|
|
|
@ -8,7 +8,7 @@ class PreferencesAccountDetails extends Component {
|
|||
static propTypes = {
|
||||
account: PropTypes.object,
|
||||
onAccountUpdated: PropTypes.func.isRequired,
|
||||
}
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
@ -60,14 +60,14 @@ class PreferencesAccountDetails extends Component {
|
|||
|
||||
_saveChanges = ()=> {
|
||||
this.props.onAccountUpdated(this.props.account, this.state);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Handlers
|
||||
|
||||
_onAccountLabelUpdated = (event)=> {
|
||||
this.setState({label: event.target.value});
|
||||
}
|
||||
};
|
||||
|
||||
_onAccountAliasCreated = (newAlias)=> {
|
||||
const coercedAlias = this._makeAlias(newAlias);
|
||||
|
@ -75,7 +75,7 @@ class PreferencesAccountDetails extends Component {
|
|||
this.setState({aliases}, ()=> {
|
||||
this._saveChanges();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_onAccountAliasUpdated = (newAlias, alias, idx)=> {
|
||||
const coercedAlias = this._makeAlias(newAlias);
|
||||
|
@ -88,7 +88,7 @@ class PreferencesAccountDetails extends Component {
|
|||
this.setState({aliases, defaultAlias}, ()=> {
|
||||
this._saveChanges();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_onAccountAliasRemoved = (alias, idx)=> {
|
||||
const aliases = this.state.aliases.slice();
|
||||
|
@ -100,14 +100,14 @@ class PreferencesAccountDetails extends Component {
|
|||
this.setState({aliases, defaultAlias}, ()=> {
|
||||
this._saveChanges();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_onDefaultAliasSelected = (event)=> {
|
||||
const defaultAlias = event.target.value === 'None' ? null : event.target.value;
|
||||
this.setState({defaultAlias}, ()=> {
|
||||
this._saveChanges();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Renderers
|
||||
|
|
|
@ -10,7 +10,7 @@ class PreferencesAccountList extends Component {
|
|||
onReorderAccount: PropTypes.func.isRequired,
|
||||
onSelectAccount: PropTypes.func.isRequired,
|
||||
onRemoveAccount: PropTypes.func.isRequired,
|
||||
}
|
||||
};
|
||||
|
||||
_renderAccount = (account)=> {
|
||||
const label = account.label;
|
||||
|
@ -34,7 +34,7 @@ class PreferencesAccountList extends Component {
|
|||
</Flexbox>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
if (!this.props.accounts) {
|
||||
|
|
|
@ -40,7 +40,7 @@ import React, {Component, PropTypes} from 'react';
|
|||
* @class EditableList
|
||||
*/
|
||||
class EditableList extends Component {
|
||||
static displayName = 'EditableList'
|
||||
static displayName = 'EditableList';
|
||||
|
||||
/**
|
||||
* If provided, this function will be called when the add button is clicked,
|
||||
|
@ -102,7 +102,7 @@ class EditableList extends Component {
|
|||
/* Optional, if you choose to control selection externally */
|
||||
selected: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
||||
onSelectItem: PropTypes.func,
|
||||
}
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
items: [],
|
||||
|
@ -113,7 +113,7 @@ class EditableList extends Component {
|
|||
onDeleteItem: ()=> {},
|
||||
onItemEdited: ()=> {},
|
||||
onItemCreated: ()=> {},
|
||||
}
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
@ -132,20 +132,20 @@ class EditableList extends Component {
|
|||
this.props.onItemCreated(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_updateItem = (value, originalItem, idx)=> {
|
||||
this._clearEditingState(()=> {
|
||||
this.props.onItemEdited(value, originalItem, idx);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_getSelectedItem = ()=> {
|
||||
if (this.props.onSelectItem) {
|
||||
return this.props.selected;
|
||||
}
|
||||
return this.state.selected;
|
||||
}
|
||||
};
|
||||
|
||||
_selectItem = (item, idx)=> {
|
||||
if (this.props.onSelectItem) {
|
||||
|
@ -153,26 +153,26 @@ class EditableList extends Component {
|
|||
} else {
|
||||
this.setState({selected: item});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_clearEditingState = (callback)=> {
|
||||
this._setStateAndFocus({editingIndex: null}, callback);
|
||||
}
|
||||
};
|
||||
|
||||
_clearCreatingState = (callback)=> {
|
||||
this._setStateAndFocus({creatingItem: false}, callback);
|
||||
}
|
||||
};
|
||||
|
||||
_setStateAndFocus = (state, callback = ()=> {})=> {
|
||||
this.setState(state, ()=> {
|
||||
this._focusSelf();
|
||||
callback();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_focusSelf = ()=> {
|
||||
React.findDOMNode(this).focus();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @private Scrolls to the dom node of the item at the provided index
|
||||
|
@ -183,20 +183,20 @@ class EditableList extends Component {
|
|||
const list = this.refs.itemsWrapper;
|
||||
const nodes = React.findDOMNode(list).querySelectorAll('.list-item');
|
||||
list.scrollTo(nodes[idx]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Handlers
|
||||
|
||||
_onEditInputBlur = (event, item, idx)=> {
|
||||
this._updateItem(event.target.value, item, idx);
|
||||
}
|
||||
};
|
||||
|
||||
_onEditInputFocus = (event)=> {
|
||||
const input = event.target;
|
||||
// Move cursor to the end of the input
|
||||
input.selectionStart = input.selectionEnd = input.value.length;
|
||||
}
|
||||
};
|
||||
|
||||
_onEditInputKeyDown = (event, item, idx)=> {
|
||||
event.stopPropagation();
|
||||
|
@ -205,11 +205,11 @@ class EditableList extends Component {
|
|||
} else if (event.key === 'Escape') {
|
||||
this._clearEditingState();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_onCreateInputBlur = (event)=> {
|
||||
this._createItem(event.target.value);
|
||||
}
|
||||
};
|
||||
|
||||
_onCreateInputKeyDown = (event)=> {
|
||||
event.stopPropagation();
|
||||
|
@ -218,15 +218,15 @@ class EditableList extends Component {
|
|||
} else if (event.key === 'Escape') {
|
||||
this._clearCreatingState();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_onItemClick = (event, item, idx)=> {
|
||||
this._selectItem(item, idx);
|
||||
}
|
||||
};
|
||||
|
||||
_onItemEdit = (event, item, idx)=> {
|
||||
this.setState({editingIndex: idx});
|
||||
}
|
||||
};
|
||||
|
||||
_listKeymapHandlers = ()=> {
|
||||
const _shift = (dir) => {
|
||||
|
@ -249,7 +249,7 @@ class EditableList extends Component {
|
|||
_shift(1);
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
_onCreateItem = ()=> {
|
||||
if (this.props.onCreateItem) {
|
||||
|
@ -257,7 +257,7 @@ class EditableList extends Component {
|
|||
} else {
|
||||
this.setState({creatingItem: true});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_onDeleteItem = ()=> {
|
||||
const selectedItem = this._getSelectedItem();
|
||||
|
@ -273,7 +273,7 @@ class EditableList extends Component {
|
|||
this._selectItem(this.props.items[newIndex], newIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_onItemDragStart = (event)=> {
|
||||
if (!this.props.onReorderItem) {
|
||||
|
@ -291,7 +291,7 @@ class EditableList extends Component {
|
|||
event.dataTransfer.setData('editablelist-index', row.dataset.itemIdx);
|
||||
event.dataTransfer.setData('editablelist-reactid', wrapperId);
|
||||
event.dataTransfer.effectAllowed = "move";
|
||||
}
|
||||
};
|
||||
|
||||
_onDragOver = (event)=> {
|
||||
const wrapperNode = React.findDOMNode(this.refs.itemsWrapper);
|
||||
|
@ -317,11 +317,11 @@ class EditableList extends Component {
|
|||
if (this.state.dropInsertionIndex !== dropInsertionIndex) {
|
||||
this.setState({dropInsertionIndex: dropInsertionIndex});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_onDragLeave = ()=> {
|
||||
this.setState({dropInsertionIndex: -1});
|
||||
}
|
||||
};
|
||||
|
||||
_onDrop = (event)=> {
|
||||
if (this.state.dropInsertionIndex !== -1) {
|
||||
|
@ -338,7 +338,7 @@ class EditableList extends Component {
|
|||
this.setState({dropInsertionIndex: -1});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Renderers
|
||||
|
||||
|
@ -357,7 +357,7 @@ class EditableList extends Component {
|
|||
onFocus={onInputFocus}
|
||||
onKeyDown={_.partial(onInputKeyDown, _, item, idx)} />
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @private Will render the create input with the provided input props.
|
||||
|
@ -377,7 +377,7 @@ class EditableList extends Component {
|
|||
<input {...props}/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// handlers object for testing
|
||||
_renderItem = (item, idx, {editingIndex} = this.state, handlers = {})=> {
|
||||
|
@ -417,7 +417,7 @@ class EditableList extends Component {
|
|||
onClick={_.partial(onEdit, _, item, idx)} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
_renderButtons = ()=> {
|
||||
const deleteClasses = classNames({
|
||||
|
@ -434,13 +434,13 @@ class EditableList extends Component {
|
|||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
_renderDropInsertion = ()=> {
|
||||
return (
|
||||
<div className="insertion-point"><div></div></div>
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
let items = this.props.items.map( (item, idx)=> this._renderItem(item, idx));
|
||||
|
|
|
@ -61,7 +61,7 @@ const CounterStyles = {
|
|||
* @class OutlineViewItem
|
||||
*/
|
||||
class OutlineViewItem extends Component {
|
||||
static displayName = 'OutlineView'
|
||||
static displayName = 'OutlineView';
|
||||
|
||||
/**
|
||||
* If provided, this function will be called when receiving a drop. It must
|
||||
|
@ -129,7 +129,7 @@ class OutlineViewItem extends Component {
|
|||
onDelete: PropTypes.func,
|
||||
onEdited: PropTypes.func,
|
||||
}).isRequired,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
constructor(props) {
|
||||
|
@ -174,63 +174,63 @@ class OutlineViewItem extends Component {
|
|||
return item[method](item, ...args);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
_shouldShowContextMenu = ()=> {
|
||||
return this.props.item.onDelete != null || this.props.item.onEdited != null;
|
||||
}
|
||||
};
|
||||
|
||||
_shouldAcceptDrop = (event)=> {
|
||||
return this._runCallback('shouldAcceptDrop', event);
|
||||
}
|
||||
};
|
||||
|
||||
_clearEditingState = (event)=> {
|
||||
this.setState({editing: false});
|
||||
this._runCallback('onInputCleared', event);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Handlers
|
||||
|
||||
_onDragStateChange = ({isDropping})=> {
|
||||
this.setState({isDropping});
|
||||
}
|
||||
};
|
||||
|
||||
_onDrop = (event)=> {
|
||||
this._runCallback('onDrop', event);
|
||||
}
|
||||
};
|
||||
|
||||
_onCollapseToggled = ()=> {
|
||||
this._runCallback('onCollapseToggled');
|
||||
}
|
||||
};
|
||||
|
||||
_onClick = (event)=> {
|
||||
event.preventDefault();
|
||||
this._runCallback('onSelect');
|
||||
}
|
||||
};
|
||||
|
||||
_onDelete = ()=> {
|
||||
this._runCallback('onDelete');
|
||||
}
|
||||
};
|
||||
|
||||
_onEdited = (value)=> {
|
||||
this._runCallback('onEdited', value);
|
||||
}
|
||||
};
|
||||
|
||||
_onEdit = ()=> {
|
||||
if (this.props.item.onEdited) {
|
||||
this.setState({editing: true});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_onInputFocus = (event)=> {
|
||||
const input = event.target;
|
||||
input.selectionStart = input.selectionEnd = input.value.length;
|
||||
}
|
||||
};
|
||||
|
||||
_onInputBlur = (event)=> {
|
||||
this._clearEditingState(event);
|
||||
}
|
||||
};
|
||||
|
||||
_onInputKeyDown = (event)=> {
|
||||
if (event.key === 'Escape') {
|
||||
|
@ -240,7 +240,7 @@ class OutlineViewItem extends Component {
|
|||
this._onEdited(event.target.value);
|
||||
this._clearEditingState(event);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_onShowContextMenu = (event)=> {
|
||||
event.stopPropagation()
|
||||
|
@ -264,7 +264,7 @@ class OutlineViewItem extends Component {
|
|||
}));
|
||||
}
|
||||
menu.popup(remote.getCurrentWindow());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Renderers
|
||||
|
|
|
@ -29,7 +29,7 @@ import OutlineViewItem from './outline-view-item';
|
|||
* @class OutlineView
|
||||
*/
|
||||
class OutlineView extends Component {
|
||||
static displayName = 'OutlineView'
|
||||
static displayName = 'OutlineView';
|
||||
|
||||
/**
|
||||
* If provided, this function will be called when an item has been created.
|
||||
|
@ -49,45 +49,45 @@ class OutlineView extends Component {
|
|||
collapsed: PropTypes.bool,
|
||||
onItemCreated: PropTypes.func,
|
||||
onCollapseToggled: PropTypes.func,
|
||||
}
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
title: '',
|
||||
items: [],
|
||||
}
|
||||
};
|
||||
|
||||
state = {
|
||||
showCreateInput: false,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Handlers
|
||||
|
||||
_onCreateButtonMouseDown = ()=> {
|
||||
this._clickingCreateButton = true;
|
||||
}
|
||||
};
|
||||
|
||||
_onCreateButtonClicked = ()=> {
|
||||
this._clickingCreateButton = false;
|
||||
this.setState({showCreateInput: !this.state.showCreateInput});
|
||||
}
|
||||
};
|
||||
|
||||
_onCollapseToggled = ()=> {
|
||||
if (this.props.onCollapseToggled) {
|
||||
this.props.onCollapseToggled(this.props);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_onItemCreated = (item, value)=> {
|
||||
this.setState({showCreateInput: false});
|
||||
this.props.onItemCreated(value)
|
||||
}
|
||||
};
|
||||
|
||||
_onCreateInputCleared = ()=> {
|
||||
if (!this._clickingCreateButton) {
|
||||
this.setState({showCreateInput: false});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Renderers
|
||||
|
|
Loading…
Add table
Reference in a new issue