diff --git a/app.js b/app.js index 2b66c72..0db24b3 100644 --- a/app.js +++ b/app.js @@ -56,18 +56,22 @@ app.use(catchErrors(async function (request, response, next) { const qs = querystring.stringify(request.query) // Creates a query string which adds the current credentials to links // To other implementations of this app in the about modal - let settingsQs = null + let settingsQuery = { + editorial_features: response.locals.settings.editorialFeatures ? 'enabled' : 'disabled' + } if ( response.locals.settings.spaceId !== process.env.CONTENTFUL_SPACE_ID || response.locals.settings.deliveryToken !== process.env.CONTENTFUL_DELIVERY_TOKEN || response.locals.settings.previewToken !== process.env.CONTENTFUL_PREVIEW_TOKEN ) { - settingsQs = querystring.stringify(Object.assign({}, request.query, { + settingsQuery = Object.assign({}, settingsQuery, request.query, { space_id: response.locals.settings.spaceId, delivery_token: response.locals.settings.deliveryToken, preview_token: response.locals.settings.previewToken - })) + }) } + + const settingsQs = querystring.stringify(settingsQuery) response.locals.queryString = qs ? `?${qs}` : '' response.locals.queryStringSettings = settingsQs ? `?${settingsQs}` : '' response.locals.query = request.query diff --git a/routes/settings.js b/routes/settings.js index c75937b..6c8d5a3 100644 --- a/routes/settings.js +++ b/routes/settings.js @@ -9,6 +9,8 @@ const { translate } = require('../i18n/i18n') const { uniqWith, isEqual } = require('lodash') const SETTINGS_NAME = 'theExampleAppSettings' +const querystring = require('querystring') + async function renderSettings (response, opts) { // Get connected space to display the space name on top of the settings let space = false @@ -162,6 +164,11 @@ module.exports.postSettings = async (request, response, next) => { updateCookie(response, SETTINGS_NAME, settings) response.locals.settings = settings + const settingsQuery = { + editorial_features: response.locals.settings.editorialFeatures ? 'enabled' : 'disabled' + } + const settingsQs = querystring.stringify(settingsQuery) + response.locals.queryStringSettings = settingsQs ? `?${settingsQs}` : '' // Reinit clients initClients(settings) }