mirror of
https://github.com/flarum/framework.git
synced 2025-04-02 23:19:04 +08:00
Fix issues with error alert and them being in modals
This commit is contained in:
parent
2fd3aa8c71
commit
654a0b5da1
2
js/dist/admin.js.map
vendored
2
js/dist/admin.js.map
vendored
File diff suppressed because one or more lines are too long
2
js/dist/forum.js
vendored
2
js/dist/forum.js
vendored
File diff suppressed because one or more lines are too long
2
js/dist/forum.js.map
vendored
2
js/dist/forum.js.map
vendored
File diff suppressed because one or more lines are too long
@ -247,7 +247,7 @@ export default abstract class Application {
|
||||
// return new Promise((resolve, reject) => )
|
||||
|
||||
return m.request(options)
|
||||
.catch(error => {
|
||||
.then(res => res, error => {
|
||||
this.requestError = error;
|
||||
|
||||
let children;
|
||||
@ -286,6 +286,7 @@ export default abstract class Application {
|
||||
try {
|
||||
options.errorHandler(error);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
// this.alerts.show(error.alert);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
import Component, {ComponentProps} from '../Component';
|
||||
import Alert from './Alert';
|
||||
import Button from './Button';
|
||||
import RequestError from "../utils/RequestError";
|
||||
|
||||
@ -11,13 +10,13 @@ export default abstract class Modal<T extends ComponentProps = ComponentProps> e
|
||||
/**
|
||||
* An alert component to show below the header.
|
||||
*/
|
||||
alert: Alert;
|
||||
alert: Mithril.Vnode;
|
||||
|
||||
loading: boolean;
|
||||
|
||||
view() {
|
||||
if (this.alert) {
|
||||
this.alert.props.dismissible = false;
|
||||
this.alert.attrs.dismissible = false;
|
||||
}
|
||||
|
||||
return (
|
||||
@ -38,7 +37,7 @@ export default abstract class Modal<T extends ComponentProps = ComponentProps> e
|
||||
<h3 className="App-titleControl App-titleControl--text">{this.title()}</h3>
|
||||
</div>
|
||||
|
||||
{alert && <div className="Modal-alert">{this.alert}</div>}
|
||||
{this.alert && <div className="Modal-alert">{this.alert}</div>}
|
||||
|
||||
{this.content()}
|
||||
</form>
|
||||
|
@ -1,7 +1,5 @@
|
||||
import Mithril from "mithril";
|
||||
|
||||
import Alert from "../components/Alert";
|
||||
|
||||
export interface RequestErrorResponse extends JSON {
|
||||
errors?: {
|
||||
code: string;
|
||||
@ -17,7 +15,7 @@ export default class RequestError {
|
||||
options: Mithril.RequestOptions;
|
||||
xhr: XMLHttpRequest;
|
||||
response?: RequestErrorResponse;
|
||||
alert?: Alert;
|
||||
alert?: Mithril.Vnode;
|
||||
|
||||
constructor(status, responseText, options, xhr) {
|
||||
this.status = status;
|
||||
|
@ -39,8 +39,6 @@ export default class LogInModal extends Modal<LogInModalProps> {
|
||||
oninit(vnode) {
|
||||
super.oninit(vnode);
|
||||
|
||||
console.log('#oninit');
|
||||
|
||||
this.identification = m.prop(this.props.identification || '');
|
||||
|
||||
this.password = m.prop(this.props.password || '');
|
||||
@ -178,7 +176,7 @@ export default class LogInModal extends Modal<LogInModalProps> {
|
||||
|
||||
onerror(error) {
|
||||
if (error.status === 401) {
|
||||
error.alert.props.children = app.translator.trans('core.forum.log_in.invalid_login_message');
|
||||
error.alert.attrs.children = app.translator.trans('core.forum.log_in.invalid_login_message');
|
||||
}
|
||||
|
||||
super.onerror(error);
|
||||
|
Loading…
x
Reference in New Issue
Block a user