From f10006563ea2ea7f41ffad36f81de27190abf3e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 20 Dec 2023 17:10:58 +0100 Subject: [PATCH] Refactor groups configs in webapp and backend to new structure --- backend/src/branding/groupsBranding.ts | 5 +++++ backend/src/constants/groups.ts | 13 ++++++++++--- backend/src/constants/groupsDefault.ts | 6 ++++++ webapp/branding/groupsBranding.js | 5 +++++ webapp/constants/groups.js | 17 ++++++++++++----- webapp/constants/groupsDefault.js | 8 ++++++++ 6 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 backend/src/branding/groupsBranding.ts create mode 100644 backend/src/constants/groupsDefault.ts create mode 100644 webapp/branding/groupsBranding.js create mode 100644 webapp/constants/groupsDefault.js diff --git a/backend/src/branding/groupsBranding.ts b/backend/src/branding/groupsBranding.ts new file mode 100644 index 000000000..a6e16d743 --- /dev/null +++ b/backend/src/branding/groupsBranding.ts @@ -0,0 +1,5 @@ +// this file is duplicated in backend/src/branding/groupsBranding' and 'webapp/branding/groupsBranding' +// configurable values see: 'backend/src/constants/groupsDefault', 'webapp/constants/groupsDefault' +// configurable values see: 'backend/src/constants/groups', 'webapp/constants/groups' + +export const DUMMY = '' // to avoid import error ts(2306): File X is not a module. diff --git a/backend/src/constants/groups.ts b/backend/src/constants/groups.ts index b1c305add..ac6fed698 100644 --- a/backend/src/constants/groups.ts +++ b/backend/src/constants/groups.ts @@ -1,3 +1,10 @@ -// this file is duplicated in `backend/src/constants/group` and `webapp/constants/group.js` -export const DESCRIPTION_WITHOUT_HTML_LENGTH_MIN = 50 // with removed HTML tags -export const DESCRIPTION_EXCERPT_HTML_LENGTH = 250 // with removed HTML tags +// configurable values see: 'backend/src/constants/groupsDefault', 'webapp/constants/groupsDefault' +// configurable values see: 'backend/src/constants/groups', 'webapp/constants/groups' + +import * as groupsDefault from './groupsDefault' +import * as groupsBranding from '../branding/groupsBranding' + +export const { DESCRIPTION_WITHOUT_HTML_LENGTH_MIN, DESCRIPTION_EXCERPT_HTML_LENGTH } = { + ...groupsDefault, + ...groupsBranding, +} diff --git a/backend/src/constants/groupsDefault.ts b/backend/src/constants/groupsDefault.ts new file mode 100644 index 000000000..6b42fb24e --- /dev/null +++ b/backend/src/constants/groupsDefault.ts @@ -0,0 +1,6 @@ +// this file is duplicated in 'backend/src/constants/groupsDefault' and 'webapp/constants/groupsDefault' +// configurable values see: 'backend/src/constants/groupsDefault', 'webapp/constants/groupsDefault' +// configurable values see: 'backend/src/constants/groups', 'webapp/constants/groups' + +export const DESCRIPTION_WITHOUT_HTML_LENGTH_MIN = 50 // with removed HTML tags +export const DESCRIPTION_EXCERPT_HTML_LENGTH = 250 // with removed HTML tags diff --git a/webapp/branding/groupsBranding.js b/webapp/branding/groupsBranding.js new file mode 100644 index 000000000..a6e16d743 --- /dev/null +++ b/webapp/branding/groupsBranding.js @@ -0,0 +1,5 @@ +// this file is duplicated in backend/src/branding/groupsBranding' and 'webapp/branding/groupsBranding' +// configurable values see: 'backend/src/constants/groupsDefault', 'webapp/constants/groupsDefault' +// configurable values see: 'backend/src/constants/groups', 'webapp/constants/groups' + +export const DUMMY = '' // to avoid import error ts(2306): File X is not a module. diff --git a/webapp/constants/groups.js b/webapp/constants/groups.js index a634425a4..ff2c0b470 100644 --- a/webapp/constants/groups.js +++ b/webapp/constants/groups.js @@ -1,5 +1,12 @@ -// this file is duplicated in `backend/src/constants/group.js` and `webapp/constants/group.js` -export const NAME_LENGTH_MIN = 3 -export const NAME_LENGTH_MAX = 50 -export const DESCRIPTION_WITHOUT_HTML_LENGTH_MIN = 50 // with removed HTML tags -export const SHOW_GROUP_BUTTON_IN_HEADER = true +// configurable values see: 'backend/src/constants/groupsDefault', 'webapp/constants/groupsDefault' +// configurable values see: 'backend/src/constants/groups', 'webapp/constants/groups' + +import * as groupsDefault from './groupsDefault' +import * as groupsBranding from '../branding/groupsBranding' + +export const { + NAME_LENGTH_MIN, + NAME_LENGTH_MAX, + DESCRIPTION_WITHOUT_HTML_LENGTH_MIN, + SHOW_GROUP_BUTTON_IN_HEADER, +} = {...groupsDefault, ...groupsBranding} diff --git a/webapp/constants/groupsDefault.js b/webapp/constants/groupsDefault.js new file mode 100644 index 000000000..1a563f5ff --- /dev/null +++ b/webapp/constants/groupsDefault.js @@ -0,0 +1,8 @@ +// this file is duplicated in 'backend/src/constants/groupsDefault' and 'webapp/constants/groupsDefault' +// configurable values see: 'backend/src/constants/groupsDefault', 'webapp/constants/groupsDefault' +// configurable values see: 'backend/src/constants/groups', 'webapp/constants/groups' + +export const NAME_LENGTH_MIN = 3 +export const NAME_LENGTH_MAX = 50 +export const DESCRIPTION_WITHOUT_HTML_LENGTH_MIN = 50 // with removed HTML tags +export const SHOW_GROUP_BUTTON_IN_HEADER = true