mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Revert "Resolving unused settings bug when plugin is disabled"
This reverts commit c829139732
.
This commit is contained in:
parent
c829139732
commit
81538f444d
3 changed files with 35 additions and 0 deletions
|
@ -238,5 +238,24 @@ describe('lib/config/config', function () {
|
|||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#removeSchema(key)', function () {
|
||||
it('should completely remove the key', function () {
|
||||
const config = new Config(Joi.object().keys({
|
||||
a: Joi.number().default(1)
|
||||
}));
|
||||
|
||||
expect(config.get('a')).to.be(1);
|
||||
config.removeSchema('a');
|
||||
expect(() => config.get('a')).to.throwException('Unknown config key');
|
||||
});
|
||||
|
||||
it('only removes existing keys', function () {
|
||||
const config = new Config(Joi.object());
|
||||
|
||||
expect(() => config.removeSchema('b')).to.throwException('Unknown schema');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
@ -42,6 +42,16 @@ module.exports = class Config {
|
|||
this.set(key, settings);
|
||||
}
|
||||
|
||||
removeSchema(key) {
|
||||
if (!_.has(this[schemaExts], key)) {
|
||||
throw new TypeError(`Unknown schema key: ${key}`);
|
||||
}
|
||||
|
||||
this[schema] = null;
|
||||
unset(this[schemaExts], key);
|
||||
unset(this[vals], key);
|
||||
}
|
||||
|
||||
resetTo(obj) {
|
||||
this._commit(obj);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,11 @@ async function addPluginConfig(pluginCollection, plugin) {
|
|||
config.extendSchema(configSchema, transformedPluginSettings, plugin.configPrefix);
|
||||
}
|
||||
|
||||
function removePluginConfig(pluginCollection, plugin) {
|
||||
const { config } = pluginCollection.kbnServer;
|
||||
config.removeSchema(plugin.configPrefix);
|
||||
}
|
||||
|
||||
module.exports = class Plugins extends Collection {
|
||||
|
||||
constructor(kbnServer) {
|
||||
|
@ -55,6 +60,7 @@ module.exports = class Plugins extends Collection {
|
|||
}
|
||||
|
||||
async disable(plugin) {
|
||||
removePluginConfig(this, plugin);
|
||||
this.delete(plugin);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue