ES6 rules
This commit is contained in:
@@ -12,7 +12,7 @@ function printData(data) {
|
||||
const printableData = Object.keys(data).map(key => `${key}: ${data[key]}`);
|
||||
|
||||
return (<textarea
|
||||
readOnly={true}
|
||||
readOnly
|
||||
onFocus={handleFocus}
|
||||
value={printableData.join('\n')}
|
||||
style={{
|
||||
|
@@ -22,7 +22,7 @@ const tabs = [
|
||||
];
|
||||
|
||||
function Tabs(props) {
|
||||
const tabLinks = tabs.map((tab, index) => {
|
||||
const tabLinks = tabs.map((tab) => {
|
||||
const tabClasses = classNames(
|
||||
'nav-tab',
|
||||
{ 'nav-tab-active': (props.tab === tab.name) }
|
||||
@@ -30,7 +30,7 @@ function Tabs(props) {
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={`tab-${index}`}
|
||||
key={`tab-${tab.name}`}
|
||||
className={tabClasses}
|
||||
to={tab.link}
|
||||
>{ tab.label }</Link>
|
||||
|
@@ -1,120 +1,114 @@
|
||||
define([
|
||||
'react',
|
||||
'mailpoet',
|
||||
],
|
||||
(
|
||||
React,
|
||||
MailPoet
|
||||
) => {
|
||||
const ListingBulkActions = React.createClass({
|
||||
getInitialState: function getInitialState() {
|
||||
return {
|
||||
action: false,
|
||||
extra: false,
|
||||
};
|
||||
},
|
||||
handleChangeAction: function handleChangeAction(e) {
|
||||
this.setState({
|
||||
action: e.target.value,
|
||||
extra: false,
|
||||
}, () => {
|
||||
const action = this.getSelectedAction();
|
||||
|
||||
// action on select callback
|
||||
if (action !== null && action.onSelect !== undefined) {
|
||||
this.setState({
|
||||
extra: action.onSelect(e),
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
handleApplyAction: function handleApplyAction(e) {
|
||||
e.preventDefault();
|
||||
import React from 'react';
|
||||
import MailPoet from 'mailpoet';
|
||||
|
||||
const ListingBulkActions = React.createClass({
|
||||
getInitialState: function getInitialState() {
|
||||
return {
|
||||
action: false,
|
||||
extra: false,
|
||||
};
|
||||
},
|
||||
handleChangeAction: function handleChangeAction(e) {
|
||||
this.setState({
|
||||
action: e.target.value,
|
||||
extra: false,
|
||||
}, () => {
|
||||
const action = this.getSelectedAction();
|
||||
|
||||
if (action === null) {
|
||||
return;
|
||||
// action on select callback
|
||||
if (action !== null && action.onSelect !== undefined) {
|
||||
this.setState({
|
||||
extra: action.onSelect(e),
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
handleApplyAction: function handleApplyAction(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const selectedIds = (this.props.selection !== 'all')
|
||||
? this.props.selected_ids
|
||||
: [];
|
||||
const action = this.getSelectedAction();
|
||||
|
||||
const data = (action.getData !== undefined)
|
||||
? action.getData()
|
||||
: {};
|
||||
if (action === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
data.action = this.state.action;
|
||||
const selectedIds = (this.props.selection !== 'all')
|
||||
? this.props.selected_ids
|
||||
: [];
|
||||
|
||||
let onSuccess = () => {};
|
||||
if (action.onSuccess !== undefined) {
|
||||
onSuccess = action.onSuccess;
|
||||
const data = (action.getData !== undefined)
|
||||
? action.getData()
|
||||
: {};
|
||||
|
||||
data.action = this.state.action;
|
||||
|
||||
let onSuccess = () => {};
|
||||
if (action.onSuccess !== undefined) {
|
||||
onSuccess = action.onSuccess;
|
||||
}
|
||||
|
||||
if (data.action) {
|
||||
const promise = this.props.onBulkAction(selectedIds, data);
|
||||
if (promise !== false) {
|
||||
promise.then(onSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.action) {
|
||||
const promise = this.props.onBulkAction(selectedIds, data);
|
||||
if (promise !== false) {
|
||||
promise.then(onSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
this.setState({
|
||||
action: false,
|
||||
extra: false,
|
||||
});
|
||||
},
|
||||
getSelectedAction: function getSelectedAction() {
|
||||
const selectedAction = this.action.value;
|
||||
if (selectedAction.length > 0) {
|
||||
const action = this.props.bulk_actions.filter(act => (act.name === selectedAction));
|
||||
|
||||
if (action.length > 0) {
|
||||
return action[0];
|
||||
}
|
||||
this.setState({
|
||||
action: false,
|
||||
extra: false,
|
||||
});
|
||||
},
|
||||
getSelectedAction: function getSelectedAction() {
|
||||
const selectedAction = this.action.value;
|
||||
if (selectedAction.length > 0) {
|
||||
const action = this.props.bulk_actions.filter(act => (act.name === selectedAction));
|
||||
|
||||
if (action.length > 0) {
|
||||
return action[0];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
render: function render() {
|
||||
if (this.props.bulk_actions.length === 0) {
|
||||
return null;
|
||||
},
|
||||
render: function render() {
|
||||
if (this.props.bulk_actions.length === 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="alignleft actions bulkactions">
|
||||
<label
|
||||
className="screen-reader-text"
|
||||
htmlFor="bulk-action-selector-top"
|
||||
>
|
||||
{MailPoet.I18n.t('selectBulkAction')}
|
||||
</label>
|
||||
return (
|
||||
<div className="alignleft actions bulkactions">
|
||||
<label
|
||||
className="screen-reader-text"
|
||||
htmlFor="bulk-action-selector-top"
|
||||
>
|
||||
{MailPoet.I18n.t('selectBulkAction')}
|
||||
</label>
|
||||
|
||||
<select
|
||||
name="bulk_actions"
|
||||
ref={(c) => { this.action = c; }}
|
||||
value={this.state.action}
|
||||
onChange={this.handleChangeAction}
|
||||
>
|
||||
<option value="">{MailPoet.I18n.t('bulkActions')}</option>
|
||||
{ this.props.bulk_actions.map((action, index) => (
|
||||
<option
|
||||
value={action.name}
|
||||
key={`action-${index}`}
|
||||
>{ action.label }</option>
|
||||
)) }
|
||||
</select>
|
||||
<input
|
||||
onClick={this.handleApplyAction}
|
||||
type="submit"
|
||||
defaultValue={MailPoet.I18n.t('apply')}
|
||||
className="button action"
|
||||
/>
|
||||
<select
|
||||
name="bulk_actions"
|
||||
ref={(c) => { this.action = c; }}
|
||||
value={this.state.action}
|
||||
onChange={this.handleChangeAction}
|
||||
>
|
||||
<option value="">{MailPoet.I18n.t('bulkActions')}</option>
|
||||
{ this.props.bulk_actions.map(action => (
|
||||
<option
|
||||
value={action.name}
|
||||
key={`action-${action.name}`}
|
||||
>{ action.label }</option>
|
||||
)) }
|
||||
</select>
|
||||
<input
|
||||
onClick={this.handleApplyAction}
|
||||
type="submit"
|
||||
defaultValue={MailPoet.I18n.t('apply')}
|
||||
className="button action"
|
||||
/>
|
||||
|
||||
{ this.state.extra }
|
||||
</div>
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
return ListingBulkActions;
|
||||
{ this.state.extra }
|
||||
</div>
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
export default ListingBulkActions;
|
||||
|
Reference in New Issue
Block a user