0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Updated import to only show warning when apps exist

no-issue

This is so that someone with empty defaults for installed_apps and
active_apps, or someone without the defaults at all, will not see the
warning message when importing.
This commit is contained in:
Fabien O'Carroll 2019-04-15 16:02:54 +02:00
parent a947947ebd
commit 7461869f13
2 changed files with 10 additions and 2 deletions

View file

@ -41,7 +41,15 @@ class SettingsImporter extends BaseImporter {
const activeApps = _.find(this.dataToImport, {key: 'active_apps'});
const installedApps = _.find(this.dataToImport, {key: 'installed_apps'});
if (activeApps || installedApps) {
const hasValueEntries = (setting = {}) => {
try {
return JSON.parse(setting.value || '[]').length !== 0;
} catch (e) {
return false;
}
};
if (hasValueEntries(activeApps) || hasValueEntries(installedApps)) {
this.problems.push({
message: 'Old settings for apps were not imported',
help: this.modelName,

View file

@ -89,7 +89,7 @@ describe('DB API', () => {
const jsonResponse = res.body;
should.exist(jsonResponse.db);
should.exist(jsonResponse.problems);
jsonResponse.problems.should.have.length(4);
jsonResponse.problems.should.have.length(3);
});
})
.then(() => {