From f2b44322a3883bdfef500e17ada7c2328d9915d4 Mon Sep 17 00:00:00 2001 From: Rishabh Garg Date: Fri, 9 Nov 2018 17:12:21 +0530 Subject: [PATCH] Enabled members lab setting for developer experiment flag (#10132) closes #10114 * Members lab enabled to be always true behind developer experiments flag * Members lab set to true for themes behind developer experiments flag Note: This change uses hard-coded labs value for members based on enableDeveloperExperiments flag, ideal implementation for later is to pick those value from settings. --- core/server/services/labs.js | 19 +++++++++++++------ core/server/services/themes/middleware.js | 9 +++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/core/server/services/labs.js b/core/server/services/labs.js index 260185d2e8..7391f0d974 100644 --- a/core/server/services/labs.js +++ b/core/server/services/labs.js @@ -1,11 +1,18 @@ -var settingsCache = require('./settings/cache'), - _ = require('lodash'), - Promise = require('bluebird'), - SafeString = require('./themes/engine').SafeString, - common = require('../lib/common'), - labs = module.exports = {}; +const settingsCache = require('./settings/cache'); +const _ = require('lodash'); +const Promise = require('bluebird'); +const SafeString = require('./themes/engine').SafeString; +const common = require('../lib/common'); +const config = require('../config'); +let labs = module.exports = {}; labs.isSet = function isSet(flag) { + /** + * TODO: Uses hard-check for members prototype, removed here when added to settings + */ + if (flag === 'members' && config.get('enableDeveloperExperiments')) { + return true; + } var labsConfig = settingsCache.get('labs'); return labsConfig && labsConfig[flag] && labsConfig[flag] === true; }; diff --git a/core/server/services/themes/middleware.js b/core/server/services/themes/middleware.js index ef385e73bb..01f09f9082 100644 --- a/core/server/services/themes/middleware.js +++ b/core/server/services/themes/middleware.js @@ -60,6 +60,15 @@ themeMiddleware.updateTemplateData = function updateTemplateData(req, res, next) labsData = _.cloneDeep(settingsCache.get('labs')), themeData = {}; + /** + * TODO: Uses hard-check for members prototype, removed here when added to settings + */ + if (config.get('enableDeveloperExperiments')) { + Object.assign(labsData, { + members: true + }); + } + if (activeTheme.get()) { themeData.posts_per_page = activeTheme.get().config('posts_per_page'); }