mirror of
https://github.com/flarum/core.git
synced 2025-08-06 00:17:31 +02:00
Fix issues with error alert and them being in modals
This commit is contained in:
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 new Promise((resolve, reject) => )
|
||||||
|
|
||||||
return m.request(options)
|
return m.request(options)
|
||||||
.catch(error => {
|
.then(res => res, error => {
|
||||||
this.requestError = error;
|
this.requestError = error;
|
||||||
|
|
||||||
let children;
|
let children;
|
||||||
@@ -286,6 +286,7 @@ export default abstract class Application {
|
|||||||
try {
|
try {
|
||||||
options.errorHandler(error);
|
options.errorHandler(error);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
// this.alerts.show(error.alert);
|
// this.alerts.show(error.alert);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import Component, {ComponentProps} from '../Component';
|
import Component, {ComponentProps} from '../Component';
|
||||||
import Alert from './Alert';
|
|
||||||
import Button from './Button';
|
import Button from './Button';
|
||||||
import RequestError from "../utils/RequestError";
|
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.
|
* An alert component to show below the header.
|
||||||
*/
|
*/
|
||||||
alert: Alert;
|
alert: Mithril.Vnode;
|
||||||
|
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
|
|
||||||
view() {
|
view() {
|
||||||
if (this.alert) {
|
if (this.alert) {
|
||||||
this.alert.props.dismissible = false;
|
this.alert.attrs.dismissible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
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>
|
<h3 className="App-titleControl App-titleControl--text">{this.title()}</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{alert && <div className="Modal-alert">{this.alert}</div>}
|
{this.alert && <div className="Modal-alert">{this.alert}</div>}
|
||||||
|
|
||||||
{this.content()}
|
{this.content()}
|
||||||
</form>
|
</form>
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
import Mithril from "mithril";
|
import Mithril from "mithril";
|
||||||
|
|
||||||
import Alert from "../components/Alert";
|
|
||||||
|
|
||||||
export interface RequestErrorResponse extends JSON {
|
export interface RequestErrorResponse extends JSON {
|
||||||
errors?: {
|
errors?: {
|
||||||
code: string;
|
code: string;
|
||||||
@@ -17,7 +15,7 @@ export default class RequestError {
|
|||||||
options: Mithril.RequestOptions;
|
options: Mithril.RequestOptions;
|
||||||
xhr: XMLHttpRequest;
|
xhr: XMLHttpRequest;
|
||||||
response?: RequestErrorResponse;
|
response?: RequestErrorResponse;
|
||||||
alert?: Alert;
|
alert?: Mithril.Vnode;
|
||||||
|
|
||||||
constructor(status, responseText, options, xhr) {
|
constructor(status, responseText, options, xhr) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
|
@@ -39,8 +39,6 @@ export default class LogInModal extends Modal<LogInModalProps> {
|
|||||||
oninit(vnode) {
|
oninit(vnode) {
|
||||||
super.oninit(vnode);
|
super.oninit(vnode);
|
||||||
|
|
||||||
console.log('#oninit');
|
|
||||||
|
|
||||||
this.identification = m.prop(this.props.identification || '');
|
this.identification = m.prop(this.props.identification || '');
|
||||||
|
|
||||||
this.password = m.prop(this.props.password || '');
|
this.password = m.prop(this.props.password || '');
|
||||||
@@ -178,7 +176,7 @@ export default class LogInModal extends Modal<LogInModalProps> {
|
|||||||
|
|
||||||
onerror(error) {
|
onerror(error) {
|
||||||
if (error.status === 401) {
|
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);
|
super.onerror(error);
|
||||||
|
Reference in New Issue
Block a user