1
0
mirror of https://github.com/flarum/core.git synced 2025-07-19 07:41:22 +02:00

Basic Extension Dependency Support (#2188)

- Don't enable an extension if its dependencies are not enabled
- Don't disable an extension if its dependencies are not disabled
This commit is contained in:
Alexander Skvortsov
2020-10-02 17:54:28 -04:00
committed by GitHub
parent 9251aa925f
commit eb717bb034
8 changed files with 279 additions and 13 deletions

View File

@@ -123,6 +123,7 @@ export default class ExtensionsPage extends Page {
url: app.forum.attribute('apiUrl') + '/extensions/' + id,
method: 'PATCH',
body: { enabled: !enabled },
errorHandler: this.onerror.bind(this),
})
.then(() => {
if (!enabled) localStorage.setItem('enabledExtension', id);
@@ -131,4 +132,23 @@ export default class ExtensionsPage extends Page {
app.modal.show(LoadingModal);
}
onerror(e) {
// We need to give the modal animation time to start; if we close the modal too early,
// it breaks the bootstrap modal library.
// TODO: This workaround should be removed when we move away from bootstrap JS for modals.
setTimeout(() => {
app.modal.close();
const error = JSON.parse(e.responseText).errors[0];
app.alerts.show(
{ type: 'error' },
app.translator.trans(`core.lib.error.${error.code}_message`, {
extension: error.extension,
extensions: error.extensions.join(', '),
})
);
}, 250);
}
}