🏗 Removed labs from setting

refs https://github.com/TryGhost/Team/issues/332

- The last value that has been used in the code was "members"
- By default members will be always "on" starting Ghost 4.0, so there's no need for this flag anymore
- Therefore there's no real need to keep "labs" around
This commit is contained in:
Naz 2021-02-12 22:47:06 +13:00 committed by naz
parent 58be6d23db
commit ea6d656457
5 changed files with 15 additions and 27 deletions

View File

@ -4,11 +4,9 @@ const ObjectId = require('bson-objectid').default;
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 = ['slack_url', 'members_from_address', 'members_support_address'];
// NOTE: drop support in Ghost 5.0
@ -73,7 +71,6 @@ class SettingsImporter extends BaseImporter {
/**
* - 'core' and 'theme' are blacklisted
* - handle labs setting
*/
beforeImport() {
debug('beforeImport');
@ -183,12 +180,6 @@ class SettingsImporter extends BaseImporter {
}
_.each(this.dataToImport, (obj) => {
if (obj.key === 'labs' && obj.value) {
// Overwrite the labs setting with our current defaults
// Ensures things that are enabled in new versions, are turned on
obj.value = JSON.stringify(_.assign({}, JSON.parse(obj.value), labsDefaults));
}
// CASE: we do not import "from address" for members settings as that needs to go via validation with magic link
if ((obj.key === 'members_from_address') || (obj.key === 'members_support_address')) {
obj.value = null;

View File

@ -0,0 +1,10 @@
const logging = require('../../../../../shared/logging');
const {createIrreversibleMigration} = require('../../utils');
module.exports = createIrreversibleMigration(async (knex) => {
logging.info('Deleting labs from settings table');
await knex('settings')
.where('key', '=', 'labs')
.del();
});

View File

@ -394,12 +394,6 @@
"type": "string"
}
},
"labs": {
"labs": {
"defaultValue": "{}",
"type": "object"
}
},
"slack": {
"slack_url": {
"defaultValue": "",

View File

@ -138,10 +138,6 @@ describe('Settings API', function () {
key: 'twitter_description',
value: 'twitter description'
},
{
key: 'labs',
value: '{"subscribers":false,"members":true}'
},
{
key: 'lang',
value: 'ua'
@ -211,14 +207,11 @@ describe('Settings API', function () {
putBody.settings[12].key.should.eql('twitter_description');
should.equal(putBody.settings[12].value, 'twitter description');
putBody.settings[13].key.should.eql('labs');
should.equal(putBody.settings[13].value, '{"subscribers":false,"members":true}');
putBody.settings[13].key.should.eql('lang');
should.equal(putBody.settings[13].value, 'ua');
putBody.settings[14].key.should.eql('lang');
should.equal(putBody.settings[14].value, 'ua');
putBody.settings[15].key.should.eql('timezone');
should.equal(putBody.settings[15].value, 'Pacific/Auckland');
putBody.settings[14].key.should.eql('timezone');
should.equal(putBody.settings[14].value, 'Pacific/Auckland');
putBody.settings[16].key.should.eql('slack');
should.equal(putBody.settings[16].value, JSON.stringify([{

View File

@ -34,7 +34,7 @@ describe('DB version integrity', function () {
// Only these variables should need updating
const currentSchemaHash = '5861ed57418a0195ea01e431b8b55335';
const currentFixturesHash = '370d0da0ab7c45050b2ff30bce8896ba';
const currentSettingsHash = '24453dc02be9df7284acf1748862a545';
const currentSettingsHash = '6db8d92f1b76b43946bf75fbac78599d';
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
// If this test is failing, then it is likely a change has been made that requires a DB version bump,