mirror of
https://github.com/flarum/framework.git
synced 2024-11-30 05:13:37 +08:00
parent
898ab9000e
commit
f7176cb076
|
@ -1,7 +1,9 @@
|
|||
import ItemList from './utils/ItemList';
|
||||
import Alert from './components/Alert';
|
||||
import Button from './components/Button';
|
||||
import ModalManager from './components/ModalManager';
|
||||
import AlertManager from './components/AlertManager';
|
||||
import RequestErrorModal from './components/RequestErrorModal';
|
||||
import Translator from './Translator';
|
||||
import Store from './Store';
|
||||
import Session from './Session';
|
||||
|
@ -330,7 +332,10 @@ export default class Application {
|
|||
|
||||
error.alert = new Alert({
|
||||
type: 'error',
|
||||
children
|
||||
children,
|
||||
controls: app.forum.attribute('debug') ? [
|
||||
<Button className="Button Button--link" onclick={this.showDebug.bind(this, error)}>Debug</Button>
|
||||
] : undefined
|
||||
});
|
||||
|
||||
try {
|
||||
|
@ -345,6 +350,16 @@ export default class Application {
|
|||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {RequestError} error
|
||||
* @private
|
||||
*/
|
||||
showDebug(error) {
|
||||
this.alerts.dismiss(this.requestErrorAlert);
|
||||
|
||||
this.modal.show(new RequestErrorModal({error}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a URL to the route with the given name.
|
||||
*
|
||||
|
|
|
@ -37,6 +37,7 @@ import Placeholder from './components/Placeholder';
|
|||
import Separator from './components/Separator';
|
||||
import Dropdown from './components/Dropdown';
|
||||
import SplitDropdown from './components/SplitDropdown';
|
||||
import RequestErrorModal from './components/RequestErrorModal';
|
||||
import FieldSet from './components/FieldSet';
|
||||
import Select from './components/Select';
|
||||
import Navigation from './components/Navigation';
|
||||
|
@ -100,6 +101,7 @@ export default {
|
|||
'components/Separator': Separator,
|
||||
'components/Dropdown': Dropdown,
|
||||
'components/SplitDropdown': SplitDropdown,
|
||||
'components/RequestErrorModal': RequestErrorModal,
|
||||
'components/FieldSet': FieldSet,
|
||||
'components/Select': Select,
|
||||
'components/Navigation': Navigation,
|
||||
|
|
30
framework/core/js/src/common/components/RequestErrorModal.js
Normal file
30
framework/core/js/src/common/components/RequestErrorModal.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
import Modal from './Modal';
|
||||
|
||||
export default class RequestErrorModal extends Modal {
|
||||
className() {
|
||||
return 'RequestErrorModal Modal--large';
|
||||
}
|
||||
|
||||
title() {
|
||||
return this.props.error.xhr
|
||||
? this.props.error.xhr.status+' '+this.props.error.xhr.statusText
|
||||
: '';
|
||||
}
|
||||
|
||||
content() {
|
||||
let responseText;
|
||||
|
||||
try {
|
||||
responseText = JSON.stringify(JSON.parse(this.props.error.responseText), null, 2);
|
||||
} catch (e) {
|
||||
responseText = this.props.error.responseText;
|
||||
}
|
||||
|
||||
return <div className="Modal-body">
|
||||
<pre>
|
||||
{this.props.error.options.method} {this.props.error.options.url}<br/><br/>
|
||||
{responseText}
|
||||
</pre>
|
||||
</div>;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user