2017-03-23 16:27:59 +09:00
|
|
|
import { Components, registerComponent } from 'meteor/vulcan:core';
|
2017-05-19 14:42:43 -06:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-06-02 07:19:39 +09:00
|
|
|
import Button from 'react-bootstrap/lib/Button';
|
2017-03-24 10:35:19 +09:00
|
|
|
import VulcanEmail from 'meteor/vulcan:email';
|
2016-04-12 19:36:47 +09:00
|
|
|
|
2017-05-19 14:42:43 -06:00
|
|
|
class Email extends PureComponent {
|
2016-04-13 14:49:03 +09:00
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.sendTest = this.sendTest.bind(this);
|
|
|
|
this.state = {
|
|
|
|
loading: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sendTest() {
|
|
|
|
this.setState({loading: true});
|
|
|
|
|
2016-12-06 18:06:29 +01:00
|
|
|
// TODO fix this
|
|
|
|
// Actions.call("email.test", this.props.name, (error, result) => {
|
|
|
|
// this.setState({loading: false});
|
|
|
|
// if (error) {
|
|
|
|
// Messages.flash(error.message, "error");
|
|
|
|
// } else {
|
|
|
|
// Messages.flash(`Test email sent (“${result}”).`, "success");
|
|
|
|
// }
|
|
|
|
// });
|
2016-04-13 14:49:03 +09:00
|
|
|
}
|
2016-04-13 12:34:41 +09:00
|
|
|
|
2016-04-13 14:49:03 +09:00
|
|
|
render() {
|
|
|
|
|
2017-05-19 14:42:43 -06:00
|
|
|
const { email, name } = this.props;
|
2016-04-13 14:49:03 +09:00
|
|
|
|
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>{name}</td>
|
|
|
|
<td><a href={"/email/template/"+email.template} target="_blank">{email.template}</a></td>
|
2017-06-04 13:56:40 +09:00
|
|
|
<td>{typeof email.subject === 'function' ? email.subject({}) : email.subject}</td>
|
2017-05-19 14:42:43 -06:00
|
|
|
<td><a href={email.path.replace(':_id?', '')} target="_blank">{email.path}</a></td>
|
2016-04-13 14:49:03 +09:00
|
|
|
<td>
|
|
|
|
<div className={this.state.loading ? "test-email loading" : "test-email"}>
|
|
|
|
<Button disabled={this.state.loading} onClick={this.sendTest} bsStyle="primary">Send Test</Button>
|
2016-12-06 18:06:29 +01:00
|
|
|
{this.state.loading ? <Components.Loading color="white"/> : null}
|
2016-04-13 14:49:03 +09:00
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Email.propTypes = {
|
2017-05-19 14:42:43 -06:00
|
|
|
email: PropTypes.object,
|
|
|
|
name: PropTypes.string
|
|
|
|
};
|
2016-04-12 19:36:47 +09:00
|
|
|
|
2017-05-19 14:42:43 -06:00
|
|
|
const Emails = (/* props*/) => {
|
2016-04-12 20:09:08 +09:00
|
|
|
|
2017-03-24 10:35:19 +09:00
|
|
|
const emails = VulcanEmail.emails;
|
2016-04-12 20:09:08 +09:00
|
|
|
|
2016-04-12 19:36:47 +09:00
|
|
|
return (
|
|
|
|
<div className="emails">
|
|
|
|
<h1>Emails</h1>
|
|
|
|
|
|
|
|
<div className="emails-wrapper">
|
|
|
|
|
|
|
|
<table className="table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<td>Name</td>
|
2016-04-13 11:39:01 +09:00
|
|
|
<td>Template</td>
|
|
|
|
<td>Subject</td>
|
|
|
|
<td>HTML Preview</td>
|
2016-04-12 19:36:47 +09:00
|
|
|
<td>Send Test</td>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2016-04-13 14:49:03 +09:00
|
|
|
{_.map(emails, (email, key) => <Email key={key} email={email} name={key}/>)}
|
2016-04-12 19:36:47 +09:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
)
|
2017-05-19 14:42:43 -06:00
|
|
|
};
|
2016-04-12 19:36:47 +09:00
|
|
|
|
2017-01-18 12:51:10 +01:00
|
|
|
registerComponent('Emails', Emails);
|