Auto fix broken rules
This commit is contained in:
@@ -39,17 +39,22 @@ class ConfirmAlert extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { title, message, confirmLabel, cancelLabel } = this.props;
|
||||
const {
|
||||
title, message, confirmLabel, cancelLabel,
|
||||
} = this.props;
|
||||
|
||||
return (this.state.show &&
|
||||
return (this.state.show
|
||||
&& (
|
||||
<div className="mailpoet_modal_overlay">
|
||||
<div className="mailpoet_popup" tabIndex="-1">
|
||||
<div className="mailpoet_popup_wrapper">
|
||||
<button className="mailpoet_modal_close" onClick={this.onClose} />
|
||||
{title &&
|
||||
{title
|
||||
&& (
|
||||
<div className="mailpoet_popup_title">
|
||||
<h2>{title}</h2>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
<div className="mailpoet_popup_body clearfix">
|
||||
<p className="mailpoet_hp_email_label">{message}</p>
|
||||
@@ -63,6 +68,7 @@ class ConfirmAlert extends React.Component {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -2,11 +2,12 @@ import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
|
||||
const KeyValueTable = props => (
|
||||
<table className={'widefat fixed'} style={{ maxWidth: props.max_width }}>
|
||||
<table className="widefat fixed" style={{ maxWidth: props.max_width }}>
|
||||
<tbody>
|
||||
{props.rows.map(row => (
|
||||
<tr key={`row_${row.key}`}>
|
||||
<td className={'row-title'}>{ row.key }</td><td>{ row.value }</td>
|
||||
<td className="row-title">{ row.key }</td>
|
||||
<td>{ row.value }</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
|
@@ -5,9 +5,11 @@ class Loading extends React.Component {
|
||||
componentWillMount() {
|
||||
MailPoet.Modal.loading(true);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
MailPoet.Modal.loading(false);
|
||||
}
|
||||
|
||||
render() {
|
||||
return null;
|
||||
}
|
||||
|
@@ -4,9 +4,9 @@ import MailPoet from 'mailpoet';
|
||||
|
||||
const PrintBoolean = props => (
|
||||
<span>
|
||||
{(props.children === true && props.truthy) ||
|
||||
(props.children === false && props.falsy) ||
|
||||
(props.unknown)}
|
||||
{(props.children === true && props.truthy)
|
||||
|| (props.children === false && props.falsy)
|
||||
|| (props.unknown)}
|
||||
</span>
|
||||
);
|
||||
|
||||
|
@@ -8,10 +8,9 @@ import html2canvas from 'html2canvas';
|
||||
* @param {DOMElement} element
|
||||
* @return {Promise<String>} DataURL of the generated image.
|
||||
*/
|
||||
export const fromDom = element =>
|
||||
html2canvas(element, {
|
||||
logging: false,
|
||||
}).then(canvas => canvas.toDataURL('image/jpeg'));
|
||||
export const fromDom = element => html2canvas(element, {
|
||||
logging: false,
|
||||
}).then(canvas => canvas.toDataURL('image/jpeg'));
|
||||
|
||||
/**
|
||||
* Generates a thumbnail from an URL.
|
||||
@@ -19,37 +18,36 @@ export const fromDom = element =>
|
||||
* @param {String} url
|
||||
* @return {Promise<String>} DataURL of the generated image.
|
||||
*/
|
||||
export const fromUrl = url =>
|
||||
new Promise((resolve, reject) => {
|
||||
const iframe = document.createElement('iframe');
|
||||
const protocol = location.href.startsWith('https://') ? 'https:' : 'http:';
|
||||
iframe.src = protocol + url.replace(/^https?:/, '');
|
||||
iframe.style.opacity = 0;
|
||||
iframe.scrolling = 'no';
|
||||
iframe.onload = () => {
|
||||
fromDom(iframe.contentDocument.documentElement)
|
||||
.then((image) => {
|
||||
document.body.removeChild(iframe);
|
||||
resolve(image);
|
||||
})
|
||||
.catch(() => {
|
||||
document.body.removeChild(iframe);
|
||||
reject(MailPoet.I18n.t('errorWhileTakingScreenshot'));
|
||||
});
|
||||
};
|
||||
const onError = () => {
|
||||
document.body.removeChild(iframe);
|
||||
reject(MailPoet.I18n.t('errorWhileTakingScreenshot'));
|
||||
};
|
||||
iframe.onerror = onError;
|
||||
iframe.onError = onError;
|
||||
iframe.className = 'mailpoet_template_iframe';
|
||||
try {
|
||||
document.body.appendChild(iframe);
|
||||
} catch (err) {
|
||||
onError();
|
||||
}
|
||||
});
|
||||
export const fromUrl = url => new Promise((resolve, reject) => {
|
||||
const iframe = document.createElement('iframe');
|
||||
const protocol = location.href.startsWith('https://') ? 'https:' : 'http:';
|
||||
iframe.src = protocol + url.replace(/^https?:/, '');
|
||||
iframe.style.opacity = 0;
|
||||
iframe.scrolling = 'no';
|
||||
iframe.onload = () => {
|
||||
fromDom(iframe.contentDocument.documentElement)
|
||||
.then((image) => {
|
||||
document.body.removeChild(iframe);
|
||||
resolve(image);
|
||||
})
|
||||
.catch(() => {
|
||||
document.body.removeChild(iframe);
|
||||
reject(MailPoet.I18n.t('errorWhileTakingScreenshot'));
|
||||
});
|
||||
};
|
||||
const onError = () => {
|
||||
document.body.removeChild(iframe);
|
||||
reject(MailPoet.I18n.t('errorWhileTakingScreenshot'));
|
||||
};
|
||||
iframe.onerror = onError;
|
||||
iframe.onError = onError;
|
||||
iframe.className = 'mailpoet_template_iframe';
|
||||
try {
|
||||
document.body.appendChild(iframe);
|
||||
} catch (err) {
|
||||
onError();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Generates a thumbnail from a newsletter's data.
|
||||
@@ -57,20 +55,17 @@ export const fromUrl = url =>
|
||||
* @param {Object} data
|
||||
* @return {Promise<String>} DataURL of the generated image.
|
||||
*/
|
||||
export const fromNewsletter = data =>
|
||||
new Promise((resolve, reject) => {
|
||||
const json = data;
|
||||
if (!_.isUndefined(json.body)) {
|
||||
json.body = JSON.stringify(json.body);
|
||||
}
|
||||
MailPoet.Ajax.post({
|
||||
api_version: window.mailpoet_api_version,
|
||||
endpoint: 'newsletters',
|
||||
action: 'showPreview',
|
||||
data: json,
|
||||
}).done(response => fromUrl(response.meta.preview_url)
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
).fail(response => reject(response.errors));
|
||||
});
|
||||
|
||||
export const fromNewsletter = data => new Promise((resolve, reject) => {
|
||||
const json = data;
|
||||
if (!_.isUndefined(json.body)) {
|
||||
json.body = JSON.stringify(json.body);
|
||||
}
|
||||
MailPoet.Ajax.post({
|
||||
api_version: window.mailpoet_api_version,
|
||||
endpoint: 'newsletters',
|
||||
action: 'showPreview',
|
||||
data: json,
|
||||
}).done(response => fromUrl(response.meta.preview_url)
|
||||
.then(resolve)
|
||||
.catch(reject)).fail(response => reject(response.errors));
|
||||
});
|
||||
|
Reference in New Issue
Block a user