0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Updated settings importer to handle new mapping

refs https://github.com/TryGhost/Ghost/issues/10318

- Skipped `members_subscription_settings` and `stripe_connect_integration` from settings import
- Fixed import data field filtering for core and theme groups
This commit is contained in:
Rish 2020-06-30 17:36:31 +05:30 committed by Rishabh Garg
parent d5f68dbbc5
commit 212e39f772

View file

@ -4,6 +4,8 @@ const _ = require('lodash');
const BaseImporter = require('./base');
const models = require('../../../../models');
const defaultSettings = require('../../../schema').defaultSettings;
const keyGroupMapper = require('../../../../api/shared/serializers/input/utils/settings-key-group-mapper');
const keyTypeMapper = require('../../../../api/shared/serializers/input/utils/settings-key-type-mapper');
const labsDefaults = JSON.parse(defaultSettings.labs.labs.defaultValue);
const ignoredSettings = ['active_apps', 'installed_apps'];
@ -87,9 +89,21 @@ class SettingsImporter extends BaseImporter {
return data;
});
// NOTE: keep back compatibility with settings object structure present before migration
// ref. https://github.com/TryGhost/Ghost/issues/10318
this.dataToImport = this.dataToImport.map((data) => {
// group property wasn't present in previous version of settings
if (!data.group && data.type) {
data.group = keyGroupMapper(data.key);
data.type = keyTypeMapper(data.key);
}
return data;
});
// Remove core and theme data types
this.dataToImport = _.filter(this.dataToImport, (data) => {
return ['core', 'theme'].indexOf(data.type) === -1;
return ['core', 'theme'].indexOf(data.group) === -1;
});
const newIsPrivate = _.find(this.dataToImport, {key: 'is_private'});
@ -103,6 +117,10 @@ class SettingsImporter extends BaseImporter {
return data.key !== 'password';
});
this.dataToImport = _.filter(this.dataToImport, (data) => {
return !(['members_subscription_settings', 'stripe_connect_integration'].includes(data.key));
});
// Only show warning if we are importing a private site into a non-private site.
if (oldIsPrivate && newIsPrivate && isFalse(oldIsPrivate.value) && isTrue(newIsPrivate.value)) {
this.problems.push({