2016-08-08 11:18:21 +09:00
|
|
|
import Telescope from 'meteor/nova:lib';
|
2016-04-13 12:34:41 +09:00
|
|
|
import React, { PropTypes, Component } from 'react';
|
2016-04-13 11:39:01 +09:00
|
|
|
import Actions from "../actions.js";
|
|
|
|
import { Button } from 'react-bootstrap';
|
2016-05-22 15:23:30 +09:00
|
|
|
import { Messages } from "meteor/nova:core";
|
2016-06-23 16:42:06 +09:00
|
|
|
import NovaEmail from 'meteor/nova:email';
|
2016-04-12 19:36:47 +09:00
|
|
|
|
2016-04-13 14:49:03 +09:00
|
|
|
const Loading = Telescope.components.Loading;
|
|
|
|
|
|
|
|
class Email extends Component {
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.sendTest = this.sendTest.bind(this);
|
|
|
|
this.state = {
|
|
|
|
loading: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sendTest() {
|
|
|
|
this.setState({loading: true});
|
|
|
|
|
2016-06-24 11:45:23 +09:00
|
|
|
Actions.call("email.test", this.props.name, (error, result) => {
|
2016-04-13 14:49:03 +09:00
|
|
|
this.setState({loading: false});
|
2016-04-13 12:34:41 +09:00
|
|
|
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() {
|
|
|
|
|
|
|
|
const {email, name} = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>{name}</td>
|
|
|
|
<td><a href={"/email/template/"+email.template} target="_blank">{email.template}</a></td>
|
|
|
|
<td>{email.subject({})}</td>
|
|
|
|
<td><a href={email.path.replace(":_id?", "")} target="_blank">{email.path}</a></td>
|
|
|
|
<td>
|
|
|
|
<div className={this.state.loading ? "test-email loading" : "test-email"}>
|
|
|
|
<Button disabled={this.state.loading} onClick={this.sendTest} bsStyle="primary">Send Test</Button>
|
|
|
|
{this.state.loading ? <Loading color="white"/> : null}
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Email.propTypes = {
|
|
|
|
email: React.PropTypes.object,
|
|
|
|
name: React.PropTypes.string
|
2016-04-12 19:36:47 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
const Emails = props => {
|
2016-04-12 20:09:08 +09:00
|
|
|
|
2016-06-23 16:42:06 +09:00
|
|
|
const emails = NovaEmail.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>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Emails
|
|
|
|
export default Emails
|