fix(settings): show correct space name and fix other small issues

This commit is contained in:
Benedikt Rötsch
2017-10-25 11:49:01 +02:00
committed by Benedikt Rötsch
parent bfd12a28e8
commit 5ddccf27d2
2 changed files with 8 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
const { createClient } = require('contentful') const { createClient } = require('contentful')
const { getSpace } = require('./../services/contentful') const { initClient, getSpace } = require('./../services/contentful')
async function renderSettings (res, opts) { async function renderSettings (res, opts) {
// Get connectred space to display the space name on top of the settings // Get connectred space to display the space name on top of the settings
@@ -77,7 +77,7 @@ exports.postSettings = async (req, res, next) => {
} else if (err.response.status === 404) { } else if (err.response.status === 404) {
errorList.push({ errorList.push({
field: 'space', field: 'space',
message: 'This space does not exist.' message: 'This space does not exist or your access token is not associated with your space.'
}) })
} else { } else {
errorList.push({ errorList.push({
@@ -113,8 +113,14 @@ exports.postSettings = async (req, res, next) => {
} }
} }
// When no errors occurred
if (!errorList.length) { if (!errorList.length) {
// Store new settings
res.cookie('theExampleAppSettings', settings, { maxAge: 31536000, httpOnly: true }) res.cookie('theExampleAppSettings', settings, { maxAge: 31536000, httpOnly: true })
res.locals.settings = settings
// Reinit clients
initClient(settings)
} }
// Generate error dictionary // Generate error dictionary

View File

@@ -66,8 +66,6 @@ block content
.form-item .form-item
input(type="checkbox" name="editorialFeatures" id="input-editorial-features" checked=settings.editorialFeatures) input(type="checkbox" name="editorialFeatures" id="input-editorial-features" checked=settings.editorialFeatures)
label(for="input-editorial-features") Enable editorial features label(for="input-editorial-features") Enable editorial features
if 'cpa' in errors
+renderErrors(errors.cpa)
.form-item__help-text Enable to display an edit link and other contextual helpers for authors. You need to have access to the connected space to make this work. .form-item__help-text Enable to display an edit link and other contextual helpers for authors. You need to have access to the connected space to make this work.
.form-item .form-item