Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: settings v2 (BREAKING CHANGE) #282

Merged
merged 30 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5a88b30
feat: add new file services for Settings
kwajiehao Aug 31, 2021
391b9bd
feat: add new Settings router
kwajiehao Aug 31, 2021
3f88e05
refactor: extract settings files retrieval to method
kwajiehao Aug 31, 2021
a701609
refactor: update settings page
kwajiehao Aug 31, 2021
26994af
chore: import v2 settings router
kwajiehao Aug 31, 2021
ff4c8de
refactor: add settings update schema
kwajiehao Aug 31, 2021
cf2e0b7
test: add sample data for tests
kwajiehao Sep 1, 2021
d49b690
refactor: readSettingsPage response schema
kwajiehao Sep 1, 2021
fc114a7
chore: add URL attribute back to settings response
kwajiehao Sep 1, 2021
b4f52c7
test: readSettingsPage
kwajiehao Sep 1, 2021
80bd36b
chore: update settings request schema, fix logic error in updateSetti…
kwajiehao Sep 1, 2021
d987c89
refactor: simplify footer update code
kwajiehao Sep 1, 2021
f11679a
test: updateSettingsPage
kwajiehao Sep 1, 2021
66d3ac3
test: HomepagePageService unit tests
kwajiehao Sep 1, 2021
0263f53
test: ConfigYmlService unit tests
kwajiehao Sep 1, 2021
619fcdd
test: FooterYmlService unit tests
kwajiehao Sep 1, 2021
ff0cd6c
test: NavYmlService unit tests
kwajiehao Sep 1, 2021
1ae3d0d
chore: add v2 settings route to auth middleware
kwajiehao Sep 15, 2021
d58511f
chore: add description to Settings v2
kwajiehao Sep 15, 2021
2ccffc2
refactor: create new configService category
kwajiehao Sep 16, 2021
db3bf57
chore: update config fixtures with description field
kwajiehao Sep 16, 2021
073c0b5
test: add tests for SettingsService
kwajiehao Sep 20, 2021
ea446c9
test: refactor Settings route tests
kwajiehao Sep 20, 2021
9b9a5f5
chore: typo
kwajiehao Sep 20, 2021
31f12ff
Fix: wait for expected method to fully resolve
alexanderleegs Oct 20, 2021
09ffc75
Fix: rebase errors
alexanderleegs Oct 20, 2021
1b8b60b
Fix: update schema to allow telegram and tiktok
alexanderleegs Oct 20, 2021
7d825b7
fix: rebase errors
alexanderleegs Nov 15, 2021
d001411
Refactor: change format of settings object
alexanderleegs Nov 17, 2021
fff8280
Fix: update test
alexanderleegs Nov 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 139 additions & 0 deletions fixtures/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
const rawConfigContent = `title: abcdefg
description: Brief site description here
url: https://abc.gov.sg
favicon: /images/isomer-logo.svg
colors:
primary-color: "#d10404"
secondary-color: "#09b709"
media-colors:
- title: media-color-one
color: "#162938"
- title: media-color-two
color: "#8a3ce0"
- title: media-color-three
color: "#18808d"
- title: media-color-four
color: "#22b0c3"
- title: media-color-five
color: "#0b3033"
permalink: none
baseurl: ""
exclude:
- travis-script.js
- .travis.yml
- README.md
- package.json
- package-lock.json
- node_modules
- vendor/bundle/
- vendor/cache/
- vendor/gems/
- vendor/ruby/
- Gemfile
- Gemfile.lock
include:
- _redirects
defaults:
- scope:
path: ""
values:
layout: page
custom_css_path: /misc/custom.css
custom_print_css_path: /assets/css/print.css
paginate: 12
remote_theme: isomerpages/isomerpages-template@next-gen
safe: false
plugins:
- jekyll-feed
- jekyll-assets
- jekyll-paginate
- jekyll-sitemap
- jekyll-remote-theme
staging: https://e2e-test-repo-staging.netlify.app
prod: https://e2e-test-repo-prod.netlify.app
resources_name: resources
is_government: false
shareicon: /images/isomer-logo.svg
facebook-pixel: "true"
google_analytics: UA-39345131-33
linkedin-insights: "12345"
`

const configContent = {
title: "abcdefg",
description: "Brief site description here",
url: "https://abc.gov.sg",
favicon: "/images/isomer-logo.svg",
colors: {
"primary-color": "#d10404",
"secondary-color": "#09b709",
"media-colors": [
{ title: "media-color-one", color: "#162938" },
{ title: "media-color-two", color: "#8a3ce0" },
{ title: "media-color-three", color: "#18808d" },
{ title: "media-color-four", color: "#22b0c3" },
{ title: "media-color-five", color: "#0b3033" },
],
},
permalink: "none",
baseurl: "",
exclude: [
"travis-script.js",
".travis.yml",
"README.md",
"package.json",
"package-lock.json",
"node_modules",
"vendor/bundle/",
"vendor/cache/",
"vendor/gems/",
"vendor/ruby/",
"Gemfile",
"Gemfile.lock",
],
include: ["_redirects"],
defaults: [{ scope: { path: "" }, values: { layout: "page" } }],
custom_css_path: "/misc/custom.css",
custom_print_css_path: "/assets/css/print.css",
paginate: 12,
remote_theme: "isomerpages/isomerpages-template@next-gen",
safe: false,
plugins: [
"jekyll-feed",
"jekyll-assets",
"jekyll-paginate",
"jekyll-sitemap",
"jekyll-remote-theme",
],
staging: "https://e2e-test-repo-staging.netlify.app",
prod: "https://e2e-test-repo-prod.netlify.app",
resources_name: "resources",
is_government: false,
shareicon: "/images/isomer-logo.svg",
"facebook-pixel": "true",
google_analytics: "UA-39345131-33",
"linkedin-insights": "12345",
}

const configSha = "configsha"

const configResponse = {
url: configContent.url,
title: configContent.title,
description: configContent.description,
favicon: configContent.favicon,
shareicon: configContent.shareicon,
is_government: configContent.is_government,
facebook_pixel: configContent["facebook-pixel"],
google_analytics: configContent.google_analytics,
linkedin_insights: configContent["linkedin-insights"],
resources_name: configContent.resources_name,
colors: configContent.colors,
}

module.exports = {
configContent,
configSha,
configResponse,
rawConfigContent,
}
38 changes: 38 additions & 0 deletions fixtures/footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const rawFooterContent = `show_reach: true
feedback: www.feedbacktest.com/hihi
faq: /faqpagetest/hihi
social_media:
facebook: https://www.facebook.com/testfbnow
twitter: https://www.twitter.com/testtwitternow
youtube: https://www.youtube.com/testyoutubenow
instagram: https://www.instagram.com/testinstanow
linkedin: https://www.linkedin.com/company/testagencynow
contact_us: astast
`

const footerContent = {
show_reach: true,
feedback: "www.feedbacktest.com/hihi",
faq: "/faqpagetest/hihi",
social_media: {
facebook: "https://www.facebook.com/testfbnow",
twitter: "https://www.twitter.com/testtwitternow",
youtube: "https://www.youtube.com/testyoutubenow",
instagram: "https://www.instagram.com/testinstanow",
linkedin: "https://www.linkedin.com/company/testagencynow",
},
contact_us: "astast",
}

const footerSha = "footerSha"

const footerResponse = {
...footerContent,
}

module.exports = {
footerContent,
footerSha,
footerResponse,
rawFooterContent,
}
89 changes: 89 additions & 0 deletions fixtures/homepage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
const rawHomepageContent = `---
layout: homepage
title: abcdefg
description: Brief site description here
image: /images/isomer-logo.svg
permalink: /
notification: Here's a notification bar you can use!
sections:
- hero:
title: Hero titlZZZZ
subtitle: Hero subtitle
background: /images/hero-banner.png
button: Contact Us
url: /contact-us/
key_highlights:
- title: Highlight A
description: Important highlight A is important
url: https://google.com
- title: Highlight B
description: Important highlight B is equally important
url: https://gmail.com
- title: Page A
description: Page A is important too
url: /privacy/
- infobar:
title: Infobar title
subtitle: Subtitle
description: About a sentence worth of description here
button: Button text
url: /faq/
---
`

const homepageContent = {
frontMatter: {
layout: "homepage",
title: "abcdefg",
description: "Brief site description here",
image: "/images/isomer-logo.svg",
permalink: "/",
notification: "Here's a notification bar you can use!",
sections: [
{
hero: {
title: "Hero titlZZZZ",
subtitle: "Hero subtitle",
background: "/images/hero-banner.png",
button: "Contact Us",
url: "/contact-us/",
key_highlights: [
{
title: "Highlight A",
description: "Important highlight A is important",
url: "https://google.com",
},
{
title: "Highlight B",
description: "Important highlight B is equally important",
url: "https://gmail.com",
},
{
title: "Page A",
description: "Page A is important too",
url: "/privacy/",
},
],
},
},
{
infobar: {
title: "Infobar title",
subtitle: "Subtitle",
description: "About a sentence worth of description here",
button: "Button text",
url: "/faq/",
},
},
],
},
pageBody: "\n",
}

const homepageSha = "homepageSha"

module.exports = {
homepageContent,
homepageSha,
rawHomepageContent,
}
37 changes: 37 additions & 0 deletions fixtures/navigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const rawNavigationContent = `logo: /images/favicon-isomer.ico
links:
- title: Contact Us
url: /contact-us/
- title: Test
url: /Test/
- title: Resources
resource_room: true
- title: Test Folder Title No Pages
collection: test-folder-title-no-pages
`

const navigationContent = {
logo: "/images/favicon-isomer.ico",
links: [
{ title: "Contact Us", url: "/contact-us/" },
{ title: "Test", url: "/Test/" },
{ title: "Resources", resource_room: true },
{
title: "Test Folder Title No Pages",
collection: "test-folder-title-no-pages",
},
],
}

const navigationSha = "navigationSha"

const navigationResponse = {
logo: navigationContent.logo,
}

module.exports = {
navigationContent,
navigationSha,
navigationResponse,
rawNavigationContent,
}
4 changes: 4 additions & 0 deletions middleware/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ auth.post(
auth.get("/v1/sites/:siteName/settings", verifyJwt)
auth.post("/v1/sites/:siteName/settings", verifyJwt)

// New settings
auth.get("/v2/sites/:siteName/settings", verifyJwt)
auth.post("/v2/sites/:siteName/settings", verifyJwt)

// Navigation
auth.get("/v1/sites/:siteName/navigation", verifyJwt)
auth.post("/v1/sites/:siteName/navigation", verifyJwt)
Expand Down
Loading