1
0
mirror of https://github.com/flarum/core.git synced 2025-08-01 14:10:37 +02:00

Tweak user email confirmation alert

- Make sure is_activated is serialized to a bool (otherwise "0" will evaluate to true)
- Remove "error" class from message so it's more friendly
- Make the alert more prominent by mounting it into a new div at the top of the page
- Add loading UX to the resend button
This commit is contained in:
Toby Zerner
2016-03-23 22:17:42 +10:30
parent cb428f1e4a
commit a5c8ef0566
4 changed files with 78 additions and 22 deletions

View File

@@ -1,9 +1,9 @@
import Alert from 'flarum/components/Alert';
import Button from 'flarum/components/Button';
import icon from 'flarum/helpers/icon';
/**
* The `alertEmailConfirmation` initializer shows an Alert if loggend in
* user's email is not confirmed
* Shows an alert if the user has not yet confirmed their email address.
*
* @param {ForumApp} app
*/
@@ -12,24 +12,43 @@ export default function alertEmailConfirmation(app) {
if (!user || user.isActivated()) return;
let alert;
const resendButton = Button.component({
className: 'Button Button--link',
children: app.translator.trans('core.forum.user_confirmation.resend_button'),
onclick: () => {
children: app.translator.trans('core.forum.user_email_confirmation.resend_button'),
onclick: function() {
resendButton.props.loading = true;
m.redraw();
app.request({
method: 'POST',
url: app.forum.attribute('apiUrl') + '/users/' + user.id() + '/send-confirmation',
}).then(() => app.alerts.dismiss(alert));
}).then(() => {
resendButton.props.loading = false;
resendButton.props.children = [icon('check'), ' ', app.translator.trans('core.forum.user_email_confirmation.sent_message')];
resendButton.props.disabled = true;
m.redraw();
}).catch(() => {
resendButton.props.loading = false;
m.redraw();
});
}
});
app.alerts.show(
alert = new Alert({
type: 'error',
class ContainedAlert extends Alert {
view() {
const vdom = super.view();
vdom.children = [<div className="container">{vdom.children}</div>];
return vdom;
}
}
m.mount(
$('<div/>').insertBefore('#content')[0],
ContainedAlert.component({
dismissible: false,
children: app.translator.trans('core.forum.user_confirmation.alert_message'),
children: app.translator.trans('core.forum.user_email_confirmation.alert_message', {email: <strong>{user.email()}</strong>}),
controls: [resendButton]
})
);