From 07ce42c1c2e2ebbd889fc38c4e8b4fdc098accd0 Mon Sep 17 00:00:00 2001 From: Hiroyasu OHYAMA Date: Mon, 18 Nov 2024 03:17:19 +0000 Subject: [PATCH 1/3] Enable to pass external parameters to React-UI implementation via Django template This commit introduced new parameter `extendedGeneralParameters` that is expected to be used for general use-cases especially for specifying some value to custom-view. --- CHANGELOG.md | 3 +++ frontend/src/services/ServerContext.ts | 2 ++ templates/frontend/index.html | 1 + 3 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ecd772ce2..92ee21c94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ## In development ### Added +* Enable to pass general external parameters(`extendedGeneralParameters`) to React-UI + implementation via Django template. + Contributed by @userlocalhost, @hinashi ### Changed diff --git a/frontend/src/services/ServerContext.ts b/frontend/src/services/ServerContext.ts index 4d1323484..ec195e835 100644 --- a/frontend/src/services/ServerContext.ts +++ b/frontend/src/services/ServerContext.ts @@ -33,6 +33,7 @@ export class ServerContext { passwordResetDisabled?: boolean; checkTermService?: boolean; termsOfServiceUrl?: string; + extendedGeneralParameters: { [key: string]: any }; extendedHeaderMenus: { name: string; children: { name: string; url: string }[]; @@ -55,6 +56,7 @@ export class ServerContext { this.passwordResetDisabled = context.password_reset_disabled; this.checkTermService = context.checkTermService; this.termsOfServiceUrl = context.termsOfServiceUrl; + this.extendedGeneralParameters = context.extendedGeneralParameters; this.extendedHeaderMenus = context.extendedHeaderMenus; this.headerColor = context.headerColor; this.flags = context.flags ?? { webhook: true }; diff --git a/templates/frontend/index.html b/templates/frontend/index.html index e2b30bf70..42fb5ed76 100644 --- a/templates/frontend/index.html +++ b/templates/frontend/index.html @@ -33,6 +33,7 @@ }, legacyUiDisabled: {{airone.LEGACY_UI_DISABLED|yesno:"true,false"}}, checkTermService: {{airone.CHECK_TERM_SERVICE|yesno:"true,false"}}, + extendedGeneralParameters: {{ airone.EXTENDED_GENERAL_PARAMETERS|safe }}, extendedHeaderMenus: {{ airone.EXTENDED_HEADER_MENUS|safe }}, headerColor: {% if airone.HEADER_COLOR %}"{{ airone.HEADER_COLOR|safe }}"{% else %}null{% endif %}, flags: { From 57def797befc13b297fd1dd2951a182b79db55d6 Mon Sep 17 00:00:00 2001 From: Hiroyasu OHYAMA Date: Mon, 18 Nov 2024 06:48:40 +0000 Subject: [PATCH 2/3] Declare parameter that would be passed to this system (e.g. custom-views) from external world --- airone/settings_common.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/airone/settings_common.py b/airone/settings_common.py index 7a3420c5e..7b19c35b4 100644 --- a/airone/settings_common.py +++ b/airone/settings_common.py @@ -242,6 +242,13 @@ class Common(Configuration): json.dumps([]), ) ), + # This is the general parameter that would be passed to custom-views from external world + "EXTENDED_GENERAL_PARAMETERS": json.loads( + env.str( + "EXTENDED_GENERAL_PARAMETERS", + json.dumps([]), + ) + ), # This is an example to set EXTENDED_HEADER_MENUS # "EXTENDED_HEADER_MENUS": json.loads(env.str( # "EXTENDED_HEADER_MENUS", From 4657033119511b91eb26655c6a298579c88d1b15 Mon Sep 17 00:00:00 2001 From: Hiroyasu OHYAMA Date: Mon, 18 Nov 2024 06:58:30 +0000 Subject: [PATCH 3/3] Fixed minor error --- airone/settings_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airone/settings_common.py b/airone/settings_common.py index 7b19c35b4..3359a6c9b 100644 --- a/airone/settings_common.py +++ b/airone/settings_common.py @@ -246,7 +246,7 @@ class Common(Configuration): "EXTENDED_GENERAL_PARAMETERS": json.loads( env.str( "EXTENDED_GENERAL_PARAMETERS", - json.dumps([]), + json.dumps({}), ) ), # This is an example to set EXTENDED_HEADER_MENUS