From e8a0a5d13c0610066c50c98d5e0d661ee8139217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 3 Aug 2021 20:05:05 +0200 Subject: [PATCH] Refactor pageParams, second step --- .../components/PageFooter/PageFooter.spec.js | 19 ++- webapp/components/PageFooter/PageFooter.vue | 9 +- .../features/InternalPage/InternalPage.vue | 65 ++--------- webapp/components/utils/InternalPages.js | 103 +++++++++------- webapp/constants/links.js | 110 ++++++++---------- webapp/layouts/basic.vue | 43 +------ webapp/locales/html/de/code-of-conduct.html | 1 - webapp/locales/html/de/data-privacy.html | 1 - webapp/locales/html/de/donate.html | 1 - webapp/locales/html/de/faq.html | 1 - webapp/locales/html/de/imprint.html | 1 - webapp/locales/html/de/support.html | 1 - .../locales/html/de/terms-and-conditions.html | 1 - webapp/locales/html/en/code-of-conduct.html | 1 - webapp/locales/html/en/data-privacy.html | 1 - webapp/locales/html/en/donate.html | 1 - webapp/locales/html/en/faq.html | 1 - webapp/locales/html/en/imprint.html | 1 - webapp/locales/html/en/support.html | 1 - .../locales/html/en/terms-and-conditions.html | 1 - webapp/pages/code-of-conduct.vue | 21 ++-- webapp/pages/data-privacy.vue | 21 ++-- webapp/pages/donate.vue | 21 ++-- webapp/pages/faq.vue | 21 ++-- webapp/pages/imprint.vue | 21 ++-- webapp/pages/organization.vue | 18 +-- webapp/pages/support.vue | 21 ++-- webapp/pages/terms-and-conditions.vue | 21 ++-- 28 files changed, 206 insertions(+), 322 deletions(-) diff --git a/webapp/components/PageFooter/PageFooter.spec.js b/webapp/components/PageFooter/PageFooter.spec.js index d82d03982..c0c32c4c4 100644 --- a/webapp/components/PageFooter/PageFooter.spec.js +++ b/webapp/components/PageFooter/PageFooter.spec.js @@ -77,7 +77,9 @@ describe('PageFooter.vue', () => { }) it('renders TERMS_AND_CONDITIONS as nuxt-link', () => { - expect(wrapper.find('span[data-test="terms-and-conditions-nuxt-link"]').exists()).toBeTruthy() + expect( + wrapper.find('span[data-test="terms-and-conditions-nuxt-link"]').exists(), + ).toBeTruthy() }) it('renders CODE_OF_CONDUCT as nuxt-link', () => { @@ -99,9 +101,18 @@ describe('PageFooter.vue', () => { ...linksDefault, ORGANIZATION: { ...linksDefault.ORGANIZATION, externalLink: 'https://ocelot.social' }, IMPRINT: { ...linksDefault.IMPRINT, externalLink: 'https://ocelot.social/IMPRINT' }, - TERMS_AND_CONDITIONS: { ...linksDefault.TERMS_AND_CONDITIONS, externalLink: 'https://ocelot.social/TERMS_AND_CONDITIONS' }, - CODE_OF_CONDUCT: { ...linksDefault.CODE_OF_CONDUCT, externalLink: 'https://ocelot.social/CODE_OF_CONDUCT' }, - DATA_PRIVACY: { ...linksDefault.DATA_PRIVACY, externalLink: 'https://ocelot.social/DATA_PRIVACY' }, + TERMS_AND_CONDITIONS: { + ...linksDefault.TERMS_AND_CONDITIONS, + externalLink: 'https://ocelot.social/TERMS_AND_CONDITIONS', + }, + CODE_OF_CONDUCT: { + ...linksDefault.CODE_OF_CONDUCT, + externalLink: 'https://ocelot.social/CODE_OF_CONDUCT', + }, + DATA_PRIVACY: { + ...linksDefault.DATA_PRIVACY, + externalLink: 'https://ocelot.social/DATA_PRIVACY', + }, FAQ: { ...linksDefault.FAQ, externalLink: 'https://ocelot.social/FAQ' }, } wrapper = Wrapper() diff --git a/webapp/components/PageFooter/PageFooter.vue b/webapp/components/PageFooter/PageFooter.vue index cb8c2a424..9aedaafec 100644 --- a/webapp/components/PageFooter/PageFooter.vue +++ b/webapp/components/PageFooter/PageFooter.vue @@ -7,11 +7,14 @@ :to="pageParams.internalLink" :data-test="pageParams.name + '-nuxt-link'" > - {{ pageParams.link }} {{ $t(pageParams.internalPage.footerIdent) }} - - {{ pageParams.link }} + {{ $t(pageParams.internalPage.footerIdent) }} - diff --git a/webapp/components/_new/features/InternalPage/InternalPage.vue b/webapp/components/_new/features/InternalPage/InternalPage.vue index ab47d90f7..397baeeb1 100644 --- a/webapp/components/_new/features/InternalPage/InternalPage.vue +++ b/webapp/components/_new/features/InternalPage/InternalPage.vue @@ -1,37 +1,36 @@ diff --git a/webapp/components/utils/InternalPages.js b/webapp/components/utils/InternalPages.js index e508d4af9..419578e1d 100644 --- a/webapp/components/utils/InternalPages.js +++ b/webapp/components/utils/InternalPages.js @@ -2,16 +2,39 @@ export function isInternalPage(pageParams) { return noStringDefined(pageParams.externalLink) } -export function noStringDefined(string) { +function noStringDefined(string) { return !string || string === 0 } -export function pageLink(pageParams) { +function pageLink(pageParams) { return isInternalPage(pageParams) ? pageParams.internalLink : pageParams.externalLink } -export const defaultInternalPagesSettings = { - ORGANIZATION: { +class PageParams { + constructor(pageParams) { + this.name = pageParams.name + this.externalLink = pageParams.externalLink + this.internalLink = pageParams.internalLink + this.internalPage = pageParams.internalPage + } + + assign(assignPageParams) { + let pageParams = this + pageParams = { + ...pageParams, + ...assignPageParams, + internalPage: { ...pageParams.internalPage, ...assignPageParams.internalPage }, + } + return pageParams + } + + get link() { + return pageLink(this) + } +} + +export const defaultPageParamsPages = { + ORGANIZATION: new PageParams({ name: 'organization', externalLink: null, // if string is defined and not empty it's dominating @@ -29,12 +52,8 @@ export const defaultInternalPagesSettings = { defaultHeadlineIdent: 'site.made', htmlIdent: 'html.organization', }, - - get link() { - return pageLink(this) - }, - }, - DONATE: { + }), + DONATE: new PageParams({ name: 'donate', externalLink: null, // if string is defined and not empty it's dominating @@ -52,12 +71,8 @@ export const defaultInternalPagesSettings = { defaultHeadlineIdent: 'site.donate', htmlIdent: 'html.donate', }, - - get link() { - return pageLink(this) - }, - }, - IMPRINT: { + }), + IMPRINT: new PageParams({ name: 'imprint', externalLink: null, // if string is defined and not empty it's dominating @@ -75,12 +90,8 @@ export const defaultInternalPagesSettings = { defaultHeadlineIdent: 'site.imprint', htmlIdent: 'html.imprint', }, - - get link() { - return pageLink(this) - }, - }, - TERMS_AND_CONDITIONS: { + }), + TERMS_AND_CONDITIONS: new PageParams({ name: 'terms-and-conditions', externalLink: null, // if string is defined and not empty it's dominating @@ -98,12 +109,8 @@ export const defaultInternalPagesSettings = { defaultHeadlineIdent: 'site.termsAndConditions', htmlIdent: 'html.termsAndConditions', }, - - get link() { - return pageLink(this) - }, - }, - CODE_OF_CONDUCT: { + }), + CODE_OF_CONDUCT: new PageParams({ name: 'code-of-conduct', externalLink: null, // if string is defined and not empty it's dominating @@ -121,12 +128,8 @@ export const defaultInternalPagesSettings = { defaultHeadlineIdent: 'site.code-of-conduct', htmlIdent: 'html.codeOfConduct', }, - - get link() { - return pageLink(this) - }, - }, - DATA_PRIVACY: { + }), + DATA_PRIVACY: new PageParams({ name: 'data-privacy', externalLink: null, // if string is defined and not empty it's dominating @@ -144,15 +147,10 @@ export const defaultInternalPagesSettings = { defaultHeadlineIdent: 'site.data-privacy', htmlIdent: 'html.dataPrivacy', }, - - get link() { - return pageLink(this) - }, - }, - FAQ: { + }), + FAQ: new PageParams({ name: 'faq', - // Wolle externalLink: 'https://ocelot.social', externalLink: null, // if string is defined and not empty it's dominating // in case internal page content is here 'webapp/locales/html/' @@ -168,9 +166,26 @@ export const defaultInternalPagesSettings = { defaultHeadlineIdent: 'site.faq', htmlIdent: 'html.faq', }, + }), + SUPPORT: new PageParams({ + name: 'support', - get link() { - return pageLink(this) + // ATTENTION: has to be defined even for internal page with full URL as example like 'https://staging.ocelot.social/support', because it is used in e-mails as well! + externalLink: 'https://ocelot.social', + + // in case internal page content is here 'webapp/locales/html/' + // ATTENTION: example for internal support page: 'https://staging.ocelot.social/support'. set a full URL please, because it is used in e-mails as well! + internalLink: '/support', // static, don't change '*/support'! internal page in case no external is defined + internalPage: { + footerIdent: 'site.support', // localized string identifier + headTitleIdent: 'site.support', // localized string identifier + headlineIdent: 'site.support', // localized string identifier. on null it's hidden, on empty string default is used + hasContainer: true, + hasBaseCard: true, + hasLoginInHeader: true, + + defaultHeadlineIdent: 'site.support', + htmlIdent: 'html.support', }, - }, + }), } diff --git a/webapp/constants/links.js b/webapp/constants/links.js index 32c6fc5e2..a26a0d52e 100644 --- a/webapp/constants/links.js +++ b/webapp/constants/links.js @@ -1,129 +1,121 @@ // this file is duplicated in `backend/src/config/links.js` and `webapp/constants/links.js` and replaced on rebranding by https://github.com/Ocelot-Social-Community/Ocelot-Social-Deploy-Rebranding/tree/master/branding/constants/ -import { defaultInternalPagesSettings } from '~/components/utils/InternalPages.js' +import { defaultPageParamsPages } from '~/components/utils/InternalPages.js' -const ORGANIZATION = { - ...defaultInternalPagesSettings.ORGANIZATION, - // Wolle name: 'organization', - - // Wolle - externalLink: 'https://ocelot.social', - // externalLink: null, // if string is defined and not empty it's dominating +const ORGANIZATION = defaultPageParamsPages.ORGANIZATION.assign({ + // Wolle externalLink: 'https://ocelot.social', + // + externalLink: null, // if string is defined and not empty it's dominating // in case internal page content is here 'webapp/locales/html/' - // Wolle internalLink: '/organization', // static, don't change! internal page in case no external is defined internalPage: { - ...defaultInternalPagesSettings.ORGANIZATION.internalPage, - footerIdent: 'site.made', // localized string identifier headTitleIdent: 'site.made', // localized string identifier - // Wolle headlineIdent: 'site.made', // localized string identifier. on null it's hidden, on empty string default is used + // Wolle headlineIdent: '', // localized string identifier. on null it's hidden, on empty string default is used headlineIdent: null, // localized string identifier. on null it's hidden, on empty string default is used hasContainer: true, hasBaseCard: true, hasLoginInHeader: true, }, -} -const DONATE = { - ...defaultInternalPagesSettings.DONATE, - // Wolle name: 'donate', - +}) +const DONATE = defaultPageParamsPages.DONATE.assign({ // Wolle externalLink: 'https://ocelot-social.herokuapp.com/donations', // we use 'ocelot-social.herokuapp.com' at the moment, because redirections of 'ocelot.social' subpages are not working correctly externalLink: '', // if string is defined and not empty it's dominating // in case internal page content is here 'webapp/locales/html/' - // Wolle internalLink: '/donate', // static, don't change! internal page in case no external is defined internalPage: { footerIdent: 'site.donate', // localized string identifier headTitleIdent: 'site.donate', // localized string identifier - headlineIdent: null, // localized string identifier. on null it's hidden, on empty string default is used + headlineIdent: '', // localized string identifier. on null it's hidden, on empty string default is used + hasContainer: true, hasBaseCard: true, hasLoginInHeader: true, }, -} -const IMPRINT = { - ...defaultInternalPagesSettings.IMPRINT, - // Wolle name: 'imprint', - +}) +const IMPRINT = defaultPageParamsPages.IMPRINT.assign({ // Wolle externalLink: 'https://ocelot-social.herokuapp.com/imprint', // we use 'ocelot-social.herokuapp.com' at the moment, because redirections of 'ocelot.social' subpages are not working correctly externalLink: '', // if string is defined and not empty it's dominating // in case internal page content is here 'webapp/locales/html/' - // Wolle internalLink: '/imprint', // static, don't change! internal page in case no external is defined internalPage: { footerIdent: 'site.imprint', // localized string identifier headTitleIdent: 'site.imprint', // localized string identifier - headlineIdent: null, // localized string identifier. on null it's hidden, on empty string default is used + headlineIdent: '', // localized string identifier. on null it's hidden, on empty string default is used + hasContainer: true, hasBaseCard: true, hasLoginInHeader: true, }, -} -const TERMS_AND_CONDITIONS = { - ...defaultInternalPagesSettings.TERMS_AND_CONDITIONS, - // Wolle name: 'terms-and-conditions', - +}) +const TERMS_AND_CONDITIONS = defaultPageParamsPages.TERMS_AND_CONDITIONS.assign({ externalLink: null, // if string is defined and not empty it's dominating // in case internal page content is here 'webapp/locales/html/' - // Wolle internalLink: '/terms-and-conditions', // static, don't change! internal page in case no external is defined internalPage: { footerIdent: 'site.termsAndConditions', // localized string identifier headTitleIdent: 'site.termsAndConditions', // localized string identifier - headlineIdent: null, // localized string identifier. on null it's hidden, on empty string default is used + headlineIdent: '', // localized string identifier. on null it's hidden, on empty string default is used + hasContainer: true, hasBaseCard: true, hasLoginInHeader: true, }, -} -const CODE_OF_CONDUCT = { - ...defaultInternalPagesSettings.CODE_OF_CONDUCT, - // Wolle name: 'code-of-conduct', - +}) +const CODE_OF_CONDUCT = defaultPageParamsPages.CODE_OF_CONDUCT.assign({ externalLink: null, // if string is defined and not empty it's dominating // in case internal page content is here 'webapp/locales/html/' - // Wolle internalLink: '/code-of-conduct', // static, don't change! internal page in case no external is defined internalPage: { footerIdent: 'site.code-of-conduct', // localized string identifier headTitleIdent: 'site.code-of-conduct', // localized string identifier - headlineIdent: null, // localized string identifier. on null it's hidden, on empty string default is used + headlineIdent: '', // localized string identifier. on null it's hidden, on empty string default is used + hasContainer: true, hasBaseCard: true, hasLoginInHeader: true, }, -} -const DATA_PRIVACY = { - ...defaultInternalPagesSettings.DATA_PRIVACY, - // Wolle name: 'data-privacy', - +}) +const DATA_PRIVACY = defaultPageParamsPages.DATA_PRIVACY.assign({ externalLink: null, // if string is defined and not empty it's dominating // in case internal page content is here 'webapp/locales/html/' - // Wolle internalLink: '/data-privacy', // static, don't change! internal page in case no external is defined internalPage: { footerIdent: 'site.data-privacy', // localized string identifier headTitleIdent: 'site.data-privacy', // localized string identifier - headlineIdent: null, // localized string identifier. on null it's hidden, on empty string default is used + headlineIdent: '', // localized string identifier. on null it's hidden, on empty string default is used + hasContainer: true, hasBaseCard: true, hasLoginInHeader: true, }, -} -const FAQ = { - ...defaultInternalPagesSettings.FAQ, - // Wolle name: 'faq', - +}) +const FAQ = defaultPageParamsPages.FAQ.assign({ // Wolle externalLink: 'https://ocelot.social', externalLink: null, // if string is defined and not empty it's dominating // in case internal page content is here 'webapp/locales/html/' - // Wolle internalLink: '/faq', // static, don't change! internal page in case no external is defined internalPage: { footerIdent: 'site.faq', // localized string identifier headTitleIdent: 'site.faq', // localized string identifier - // Wolle headlineIdent: null, // on null default is used, on empty string it's hidden - headlineIdent: null, // localized string identifier. on null it's hidden, on empty string default is used + // Wolle headlineIdent: '', // on null default is used, on empty string it's hidden + headlineIdent: '', // localized string identifier. on null it's hidden, on empty string default is used + hasContainer: true, hasBaseCard: true, hasLoginInHeader: true, }, -} +}) +const SUPPORT = defaultPageParamsPages.SUPPORT.assign({ + // ATTENTION: has to be defined even for internal page with full URL as example like 'https://staging.ocelot.social/support', because it is used in e-mails as well! + // Wolle externalLink: 'https://ocelot.social', + externalLink: 'http://localhost:3000/support', // if string is defined and not empty it's dominating + + // in case internal page content is here 'webapp/locales/html/' + internalPage: { + footerIdent: 'site.support', // localized string identifier + headTitleIdent: 'site.support', // localized string identifier + // Wolle headlineIdent: '', // on null default is used, on empty string it's hidden + headlineIdent: '', // localized string identifier. on null it's hidden, on empty string default is used + hasContainer: true, + hasBaseCard: true, + hasLoginInHeader: true, + }, +}) export default { // Wolle LANDING_PAGE: '/login', // examples: '/login', '/registration', '/organization', or external 'https://ocelot.social' @@ -131,8 +123,6 @@ export default { // you can find and store templates for 👇🏼 at https://github.com/Ocelot-Social-Community/Ocelot-Social-Deploy-Rebranding/tree/master/branding/templates/ - SUPPORT: 'https://ocelot.social', // example for internal support page: 'https://staging.ocelot.social/support'. set a full URL please, because it is used in e-mails as well! - ORGANIZATION, DONATE, IMPRINT, @@ -140,6 +130,7 @@ export default { CODE_OF_CONDUCT, DATA_PRIVACY, FAQ, + SUPPORT, FOOTER_LINK_LIST: [ ORGANIZATION, @@ -147,9 +138,8 @@ export default { CODE_OF_CONDUCT, DATA_PRIVACY, FAQ, - // DONATE, - // Wolle DONATE, IMPRINT, + // SUPPORT, ], } diff --git a/webapp/layouts/basic.vue b/webapp/layouts/basic.vue index a14ae4f3c..5eadb42af 100644 --- a/webapp/layouts/basic.vue +++ b/webapp/layouts/basic.vue @@ -10,10 +10,7 @@ -