Skip to content

Commit

Permalink
chore: add description to Settings v2
Browse files Browse the repository at this point in the history
In PR 280, we added a description field to the Settings endpoints
(see #280). This
commit adds this field to the Settings V2 router as well.
  • Loading branch information
kwajiehao authored and alexanderleegs committed Nov 15, 2021
1 parent 1ae3d0d commit d58511f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
18 changes: 14 additions & 4 deletions newroutes/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,19 @@ const {

const { UpdateSettingsRequestSchema } = require("@validators/RequestSchema")

const shouldUpdateHomepage = (updatedConfigContent, configContent) => {
if (
(updatedConfigContent.title &&
configContent.title !== updatedConfigContent.title) ||
(updatedConfigContent.description &&
configContent.description !== updatedConfigContent.description)
)
return true
return false
}
const extractConfigFields = (config) => ({
url: config.content.url,
description: config.content.description,
title: config.content.title,
favicon: config.content.favicon,
shareicon: config.content.shareicon,
Expand Down Expand Up @@ -103,14 +114,13 @@ class SettingsRouter {
})

// update homepage title only if necessary
if (
updatedConfigContent.title &&
config.content.title !== updatedConfigContent.title
) {
if (shouldUpdateHomepage(updatedConfigContent, config.content)) {
const updatedHomepageFrontMatter = _.cloneDeep(
homepage.content.frontMatter
)
updatedHomepageFrontMatter.title = updatedConfigContent.title
updatedHomepageFrontMatter.description =
updatedConfigContent.description
await this.homepagePageService.update(reqDetails, {
content: homepage.content.pageBody,
frontMatter: updatedHomepageFrontMatter,
Expand Down
1 change: 1 addition & 0 deletions validators/RequestSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const UpdateSettingsRequestSchema = Joi.object().keys({
is_government: Joi.boolean(),
shareicon: Joi.string().allow(""),
title: Joi.string().allow(""),
description: Joi.string().allow(""),
})
.required(),
footerSettings: Joi.object()
Expand Down

0 comments on commit d58511f

Please sign in to comment.