mirror of
https://github.com/flarum/core.git
synced 2025-07-09 02:52:32 +02:00
Add required fields, incomplete configuration warning, and null transport
This commit is contained in:
committed by
Franz Liedke
parent
a330a8fa28
commit
8b70cec6a1
@ -15,6 +15,7 @@ export default class MailPage extends Page {
|
||||
|
||||
this.driverFields = {};
|
||||
this.fields = ['mail_driver', 'mail_from'];
|
||||
this.fieldsRequired = [];
|
||||
this.values = {};
|
||||
|
||||
const settings = app.data.settings;
|
||||
@ -36,6 +37,8 @@ export default class MailPage extends Page {
|
||||
}
|
||||
}
|
||||
|
||||
this.fieldsRequired = response['data'].map(driver => driver['attributes']['fieldsRequired']).flat();
|
||||
|
||||
this.loading = false;
|
||||
m.redraw();
|
||||
});
|
||||
@ -52,6 +55,8 @@ export default class MailPage extends Page {
|
||||
);
|
||||
}
|
||||
|
||||
const fields = this.driverFields[this.values.mail_driver()];
|
||||
|
||||
return (
|
||||
<div className="MailPage">
|
||||
<div className="container">
|
||||
@ -83,13 +88,18 @@ export default class MailPage extends Page {
|
||||
]
|
||||
})}
|
||||
|
||||
{Object.keys(this.driverFields[this.values.mail_driver()]).length > 0 && FieldSet.component({
|
||||
{Object.keys(fields).length > 0 && FieldSet.component({
|
||||
label: app.translator.trans(`core.admin.email.${this.values.mail_driver()}_heading`),
|
||||
className: 'MailPage-MailSettings',
|
||||
children: [
|
||||
fields.filter(field => this.fieldsRequired.includes(field) && !this.values[field]()).length > 0 && Alert.component({
|
||||
children: app.translator.trans('core.admin.email.incomplete_configuration_text'),
|
||||
dismissible: false,
|
||||
}),
|
||||
|
||||
<div className="MailPage-MailSettings-input">
|
||||
{Object.keys(this.driverFields[this.values.mail_driver()]).map(field => [
|
||||
<label>{app.translator.trans(`core.admin.email.${field}_label`)}</label>,
|
||||
{Object.keys(fields).map(field => [
|
||||
<label>{app.translator.trans(`core.admin.email.${field}_label`)} {this.fieldsRequired.includes(field) ? '*' : ''}</label>,
|
||||
this.renderField(field),
|
||||
])}
|
||||
</div>
|
||||
@ -115,7 +125,7 @@ export default class MailPage extends Page {
|
||||
const prop = this.values[name];
|
||||
|
||||
if (typeof field === 'string') {
|
||||
return <input className="FormControl" value={prop() || ''} oninput={m.withAttr('value', prop)}/>;
|
||||
return <input className="FormControl" value={prop() || ''} oninput={m.withAttr('value', prop)} required={this.fieldsRequired.includes(field)} />;
|
||||
} else {
|
||||
return <Select value={prop()} options={field} onchange={prop} />;
|
||||
}
|
||||
|
Reference in New Issue
Block a user