Skip to content

Commit

Permalink
Merge pull request #1327 from userlocalhost/feature/new-ui/extendedGe…
Browse files Browse the repository at this point in the history
…neralParameters

Enable to pass external parameters to React-UI implementation via Django template
  • Loading branch information
hinashi authored Nov 18, 2024
2 parents 4410672 + 4657033 commit e9362ae
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions airone/settings_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/services/ServerContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class ServerContext {
passwordResetDisabled?: boolean;
checkTermService?: boolean;
termsOfServiceUrl?: string;
extendedGeneralParameters: { [key: string]: any };

Check warning on line 36 in frontend/src/services/ServerContext.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
extendedHeaderMenus: {
name: string;
children: { name: string; url: string }[];
Expand All @@ -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 };
Expand Down
1 change: 1 addition & 0 deletions templates/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit e9362ae

Please sign in to comment.