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

Enable to pass external parameters to React-UI implementation via Django template #1327

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@ -3,7 +3,7 @@
username: string;
isSuperuser: boolean;

constructor(user: any) {

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

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
this.id = user.id;
this.username = user.username;
this.isSuperuser = user.isSuperuser;
Expand Down Expand Up @@ -33,6 +33,7 @@
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 @@
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
Loading