mirror of
https://github.com/flarum/core.git
synced 2025-07-12 12:26:23 +02:00
Webpack (#1367)
* Replace gulp with webpack and npm scripts for JS compilation * Set up Travis CI to commit compiled JS * Restructure `js` directory; only one instance of npm, forum/admin are "submodules" * Refactor JS initializers into Application subclasses * Maintain partial compatibility API (importing from absolute paths) for extensions * Remove minification responsibility from PHP asset compiler * Restructure `less` directory
This commit is contained in:
55
js/src/forum/utils/alertEmailConfirmation.js
Normal file
55
js/src/forum/utils/alertEmailConfirmation.js
Normal file
@ -0,0 +1,55 @@
|
||||
import Alert from '../../common/components/Alert';
|
||||
import Button from '../../common/components/Button';
|
||||
import icon from '../../common/helpers/icon';
|
||||
|
||||
/**
|
||||
* Shows an alert if the user has not yet confirmed their email address.
|
||||
*
|
||||
* @param {ForumApp} app
|
||||
*/
|
||||
export default function alertEmailConfirmation(app) {
|
||||
const user = app.session.user;
|
||||
|
||||
if (!user || user.isActivated()) return;
|
||||
|
||||
const resendButton = Button.component({
|
||||
className: 'Button Button--link',
|
||||
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(() => {
|
||||
resendButton.props.loading = false;
|
||||
resendButton.props.children = [icon('fas fa-check'), ' ', app.translator.trans('core.forum.user_email_confirmation.sent_message')];
|
||||
resendButton.props.disabled = true;
|
||||
m.redraw();
|
||||
}).catch(() => {
|
||||
resendButton.props.loading = false;
|
||||
m.redraw();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
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_email_confirmation.alert_message', {email: <strong>{user.email()}</strong>}),
|
||||
controls: [resendButton]
|
||||
})
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user