mirror of
https://github.com/flarum/framework.git
synced 2024-11-28 11:34:36 +08:00
parent
63801484fa
commit
0560238945
|
@ -29,12 +29,13 @@ export default class MailPage extends Page {
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
|
||||||
Object.keys(this.driverFields).flatMap(key => this.driverFields[key]).forEach(
|
for (const driver in this.driverFields) {
|
||||||
key => {
|
for (const field in this.driverFields[driver]) {
|
||||||
this.fields.push(key);
|
this.fields.push(field);
|
||||||
this.values[key] = m.prop(settings[key]);
|
this.values[field] = m.prop(settings[field]);
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
m.redraw();
|
m.redraw();
|
||||||
});
|
});
|
||||||
|
@ -87,9 +88,9 @@ export default class MailPage extends Page {
|
||||||
className: 'MailPage-MailSettings',
|
className: 'MailPage-MailSettings',
|
||||||
children: [
|
children: [
|
||||||
<div className="MailPage-MailSettings-input">
|
<div className="MailPage-MailSettings-input">
|
||||||
{this.driverFields[this.values.mail_driver()].flatMap(field => [
|
{Object.keys(this.driverFields[this.values.mail_driver()]).map(field => [
|
||||||
<label>{app.translator.trans(`core.admin.email.${field}_label`)}</label>,
|
<label>{app.translator.trans(`core.admin.email.${field}_label`)}</label>,
|
||||||
<input className="FormControl" value={this.values[field]() || ''} oninput={m.withAttr('value', this.values[field])} />
|
this.renderField(field),
|
||||||
])}
|
])}
|
||||||
</div>
|
</div>
|
||||||
]
|
]
|
||||||
|
@ -108,6 +109,18 @@ export default class MailPage extends Page {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderField(name) {
|
||||||
|
const driver = this.values.mail_driver();
|
||||||
|
const field = this.driverFields[driver][name];
|
||||||
|
const prop = this.values[name];
|
||||||
|
|
||||||
|
if (typeof field === 'string') {
|
||||||
|
return <input className="FormControl" value={prop() || ''} oninput={m.withAttr('value', prop)}/>;
|
||||||
|
} else {
|
||||||
|
return <Select value={prop()} options={field} onchange={prop} />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
changed() {
|
changed() {
|
||||||
return this.fields.some(key => this.values[key]() !== app.data.settings[key]);
|
return this.fields.some(key => this.values[key]() !== app.data.settings[key]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,12 @@ class MailgunDriver implements DriverInterface
|
||||||
public function availableSettings(): array
|
public function availableSettings(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'mail_mailgun_secret', // the secret key
|
'mail_mailgun_secret' => '', // the secret key
|
||||||
'mail_mailgun_domain', // the API base URL
|
'mail_mailgun_domain' => '', // the API base URL
|
||||||
|
'mail_mailgun_region' => [ // region's endpoint
|
||||||
|
'api.mailgun.net' => 'US',
|
||||||
|
'api.eu.mailgun.net' => 'EU',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +33,8 @@ class MailgunDriver implements DriverInterface
|
||||||
return new MailgunTransport(
|
return new MailgunTransport(
|
||||||
new Client(['connect_timeout' => 60]),
|
new Client(['connect_timeout' => 60]),
|
||||||
$settings->get('mail_mailgun_secret'),
|
$settings->get('mail_mailgun_secret'),
|
||||||
$settings->get('mail_mailgun_domain')
|
$settings->get('mail_mailgun_domain'),
|
||||||
|
$settings->get('mail_mailgun_region')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ class MandrillDriver implements DriverInterface
|
||||||
public function availableSettings(): array
|
public function availableSettings(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'mail_mandrill_secret',
|
'mail_mandrill_secret' => '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,9 @@ class SesDriver implements DriverInterface
|
||||||
public function availableSettings(): array
|
public function availableSettings(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'mail_ses_key',
|
'mail_ses_key' => '',
|
||||||
'mail_ses_secret',
|
'mail_ses_secret' => '',
|
||||||
'mail_ses_region',
|
'mail_ses_region' => '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,11 @@ class SmtpDriver implements DriverInterface
|
||||||
public function availableSettings(): array
|
public function availableSettings(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'mail_host', // a hostname, IPv4 address or IPv6 wrapped in []
|
'mail_host' => '', // a hostname, IPv4 address or IPv6 wrapped in []
|
||||||
'mail_port', // a number, defaults to 25
|
'mail_port' => '', // a number, defaults to 25
|
||||||
'mail_encryption', // "tls" or "ssl"
|
'mail_encryption' => '', // "tls" or "ssl"
|
||||||
'mail_username', // required
|
'mail_username' => '', // required
|
||||||
'mail_password', // required
|
'mail_password' => '', // required
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user