Add internal settings access to the plugin API
This commit is contained in:
parent
210d085caf
commit
9b9162346b
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
|
||||
import { ClientLogger as Logger } from 'common';
|
||||
import Settings from './settings';
|
||||
import PluginManager from './pluginmanager';
|
||||
import ThemeManager from './thememanager';
|
||||
import Events from './events';
|
||||
|
@ -66,6 +67,15 @@ export default class PluginApi {
|
|||
}
|
||||
}
|
||||
|
||||
getSetting(set, category, setting) {
|
||||
return Settings.get(set, category, setting);
|
||||
}
|
||||
get Settings() {
|
||||
return {
|
||||
get: this.getSetting.bind(this)
|
||||
};
|
||||
}
|
||||
|
||||
async getPlugin(plugin_id) {
|
||||
// This should require extra permissions
|
||||
return await PluginManager.waitForPlugin(plugin_id);
|
||||
|
|
|
@ -7,7 +7,12 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
onStart() {
|
||||
Events.subscribe('TEST_EVENT', this.eventTest);
|
||||
Logger.log('onStart');
|
||||
Logger.log(`Setting "default-0" value: ${this.getSetting('default-0')}`);
|
||||
Logger.log(`Plugin setting "default-0" value: ${this.getSetting('default-0')}`);
|
||||
Logger.log(`Internal setting "core/default/test-setting" value: ${Api.Settings.get('core', 'default', 'test-setting')}`);
|
||||
|
||||
Events.subscribe('setting-updated', setting => {
|
||||
console.log('Received internal setting update:', setting);
|
||||
});
|
||||
|
||||
const exampleModule = new (Api.import('Example Module'));
|
||||
Logger.log(`2+4=${exampleModule.add(2, 4)}`);
|
||||
|
|
Loading…
Reference in New Issue