0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Removed deprecated settings

refs #10318

- cheap and dirty way of removing settings we don't use
- rewritten the settingsFilter function as that was unnecessarily complex
- aslo fixed the require of default-settings in the importer
This commit is contained in:
Hannah Wolfe 2019-01-02 19:18:19 +00:00 committed by Hannah Wolfe
parent ef98c65040
commit 80f9765a35
4 changed files with 16 additions and 15 deletions

View file

@ -30,14 +30,14 @@ let settings,
* @returns {*}
*/
settingsFilter = (settings, filter) => {
return _.fromPairs(_.toPairs(settings).filter((setting) => {
if (filter) {
return _.some(filter.split(','), (f) => {
return setting[1].type === f;
});
let filteredTypes = filter ? filter.split(',') : false;
return _.filter(settings, (setting) => {
if (filteredTypes) {
return _.includes(filteredTypes, setting.type);
}
return true;
}));
});
};
/**

View file

@ -28,7 +28,7 @@ module.exports = {
// CASE: omit core settings unless internal request
if (!frame.options.context.internal) {
settings = _.filter(settings, (setting) => {
return setting.type !== 'core' && setting.key !== 'permalinks';
return setting.type !== 'core';
});
}

View file

@ -1,5 +1,6 @@
const _ = require('lodash');
const _private = {};
const deprecatedSettings = ['force_i18n', 'permalinks'];
/**
* ### Settings Filter
@ -10,14 +11,14 @@ const _private = {};
* @returns {*}
*/
_private.settingsFilter = (settings, filter) => {
return _.fromPairs(_.toPairs(settings).filter((setting) => {
if (filter) {
return _.some(filter.split(','), (f) => {
return setting[1].type === f;
});
let filteredTypes = filter ? filter.split(',') : false;
return _.filter(settings, (setting) => {
if (filteredTypes) {
return _.includes(filteredTypes, setting.type) && !_.includes(deprecatedSettings, setting.key);
}
return true;
}));
return !_.includes(deprecatedSettings, setting.key);
});
};
module.exports = {

View file

@ -3,7 +3,7 @@ const debug = require('ghost-ignition').debug('importer:settings'),
_ = require('lodash'),
BaseImporter = require('./base'),
models = require('../../../../models'),
defaultSettings = require('../../../schema/default-settings.json'),
defaultSettings = require('../../../schema').defaultSettings,
labsDefaults = JSON.parse(defaultSettings.blog.labs.defaultValue);
class SettingsImporter extends BaseImporter {