mirror of
https://github.com/flarum/core.git
synced 2025-08-05 07:57:46 +02:00
Email confirmation alert: Simplify implementation
Now that we don't mess with component instances anymore, we can follow normal Mithril patterns.
This commit is contained in:
@@ -18,15 +18,15 @@ export default function alertEmailConfirmation(app) {
|
|||||||
super.oninit(vnode);
|
super.oninit(vnode);
|
||||||
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.disabled = false;
|
this.sent = false;
|
||||||
|
|
||||||
this.content = app.translator.trans('core.forum.user_email_confirmation.resend_button');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
view() {
|
view() {
|
||||||
return (
|
return (
|
||||||
<Button class="Button Button--link" onclick={this.onclick.bind(this)} loading={this.loading} disabled={this.disabled}>
|
<Button class="Button Button--link" onclick={this.onclick.bind(this)} loading={this.loading} disabled={this.sent}>
|
||||||
{this.content}
|
{this.sent
|
||||||
|
? [icon('fas fa-check'), ' ', app.translator.trans('core.forum.user_email_confirmation.sent_message')]
|
||||||
|
: app.translator.trans('core.forum.user_email_confirmation.resend_button')}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -42,8 +42,7 @@ export default function alertEmailConfirmation(app) {
|
|||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.content = [icon('fas fa-check'), ' ', app.translator.trans('core.forum.user_email_confirmation.sent_message')];
|
this.sent = true;
|
||||||
this.disabled = true;
|
|
||||||
m.redraw();
|
m.redraw();
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@@ -53,22 +52,13 @@ export default function alertEmailConfirmation(app) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ContainedAlert extends Alert {
|
|
||||||
view(vnode) {
|
|
||||||
const vdom = super.view(vnode);
|
|
||||||
|
|
||||||
return { ...vdom, children: [<div className="container">{vdom.children}</div>] };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m.mount($('<div/>').insertBefore('#content')[0], {
|
m.mount($('<div/>').insertBefore('#content')[0], {
|
||||||
view: () =>
|
view: () => (
|
||||||
ContainedAlert.component(
|
<Alert dismissible={false} controls={[<ResendButton />]}>
|
||||||
{
|
<div className="container">
|
||||||
dismissible: false,
|
{app.translator.trans('core.forum.user_email_confirmation.alert_message', { email: <strong>{user.email()}</strong> })}
|
||||||
controls: [ResendButton.component()],
|
</div>
|
||||||
},
|
</Alert>
|
||||||
app.translator.trans('core.forum.user_email_confirmation.alert_message', { email: <strong>{user.email()}</strong> })
|
),
|
||||||
),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user