mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 12:43:52 +08:00
Set this.changingState back to false in ExtensionPage if an error occurs (#2558)
This commit is contained in:
parent
54d78f4630
commit
eedb6d3752
|
@ -59,6 +59,8 @@ export default class ExtensionPage extends Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
header() {
|
header() {
|
||||||
|
const isEnabled = this.isEnabled();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
<div className="ExtensionPage-header">
|
<div className="ExtensionPage-header">
|
||||||
<div className="container">
|
<div className="container">
|
||||||
|
@ -75,10 +77,12 @@ export default class ExtensionPage extends Page {
|
||||||
</div>
|
</div>
|
||||||
<div className="helpText">{this.extension.description}</div>
|
<div className="helpText">{this.extension.description}</div>
|
||||||
<div className="ExtensionPage-headerItems">
|
<div className="ExtensionPage-headerItems">
|
||||||
<Switch state={this.isEnabled()} onchange={this.toggle.bind(this, this.extension.id)}>
|
<Switch
|
||||||
{this.isEnabled(this.extension.id)
|
state={this.changingState ? !isEnabled : isEnabled}
|
||||||
? app.translator.trans('core.admin.extension.enabled')
|
loading={this.changingState}
|
||||||
: app.translator.trans('core.admin.extension.disabled')}
|
onchange={this.toggle.bind(this, this.extension.id)}
|
||||||
|
>
|
||||||
|
{isEnabled ? app.translator.trans('core.admin.extension.enabled') : app.translator.trans('core.admin.extension.disabled')}
|
||||||
</Switch>
|
</Switch>
|
||||||
<aside className="ExtensionInfo">
|
<aside className="ExtensionInfo">
|
||||||
<ul>{listItems(this.infoItems().toArray())}</ul>
|
<ul>{listItems(this.infoItems().toArray())}</ul>
|
||||||
|
@ -333,9 +337,7 @@ export default class ExtensionPage extends Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
isEnabled() {
|
isEnabled() {
|
||||||
let isEnabled = isExtensionEnabled(this.extension.id);
|
return isExtensionEnabled(this.extension.id);
|
||||||
|
|
||||||
return this.changingState ? !isEnabled : isEnabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onerror(e) {
|
onerror(e) {
|
||||||
|
@ -346,6 +348,8 @@ export default class ExtensionPage extends Page {
|
||||||
app.modal.close();
|
app.modal.close();
|
||||||
}, 300); // Bootstrap's Modal.TRANSITION_DURATION is 300 ms.
|
}, 300); // Bootstrap's Modal.TRANSITION_DURATION is 300 ms.
|
||||||
|
|
||||||
|
this.changingState = false;
|
||||||
|
|
||||||
if (e.status !== 409) {
|
if (e.status !== 409) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user