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

feat!: template-level app config overrides #2531

Merged
merged 25 commits into from
Dec 2, 2024

Conversation

jfmcquade
Copy link
Collaborator

@jfmcquade jfmcquade commented Nov 18, 2024

PR Checklist

  • PR title descriptive (can be used in release notes)

Description

  • Enables authors to override app config values by setting them in a template's parameter list.
    • These overrides will apply as long as the template is the current top-level template (either navigated to directly or launched as fullscreen pop-up).
    • On navigating away from the template, the values are set to the deployment defaults, accounting for any active skin overrides (and any overrides set by the new top-level template)
    • The immediate use case is for setting custom header and footer for specific templates.
  • The header and footer app config properties (e.g. APP_FOOTER_DEFAULTS.templateName) are not restructured or renamed by this PR, nor are the new properties exposed that will be required for full header/footer customisation (e.g. for passing in a template to be displayed in the header, as we do for the footer).
    • Renaming the app config properties whilst retaining support for the legacy property names proved difficult, so I'm planning on making those changes in a separate follow-up PR. That PR will likely involve some breaking changes for deployment configs.

Breaking changes

There is an update to the way template parameter lists are parsed that has the potential for breaking changes, although none are expected. Previously, when a template parameter list was parsed from its string representation into a JSON object, only minimal further parsing was done on the values of any parameters. Specifically, the values of top-level parameters, e.g. the string "landscape" in my_param: true; would be checked to see if they were a string representation of a boolean value ("true" or "false"), and parsed to the corresponding value if so. Nested parameters, e.g. "my.nested.param = false" would be parsed into objects, but, inconsistently, the values themselves would receive no further parsing (i.e., the parsed parameter list would be { my: { nested: { param: "false" } } }.

As of this PR, the parser for template parameter lists attempts to interpret string values as native data types, such as numeric, boolean, null, or undefined string representations. I believe this is expected behaviour.

Comparing the parsed sheets for the debug deployment, the changes are minimal and only apply to the sheets introduced for this PR (as the latest content changes are in this open PR, I checked out the content/1.3.0 branch of the content repo and ran yarn workflow sync_sheets --skip-download to see the relevant diffs from parsing on this feature branch).

Screenshot 2024-11-25 at 16 01 55 Screenshot 2024-11-25 at 16 02 04

Git Issues

Closes #

Screenshots/Videos

feature_app_layout

Screenshot 2024-11-21 at 15 37 01

feat_app_layout_header_compact

Screenshot 2024-11-21 at 15 37 30

feat_app_layout_footer

Screenshot 2024-11-21 at 15 37 57

feat_custom_footer

Screenshot 2024-11-21 at 15 38 24

Demo with default skin active:

Default.skin.mov

Demo with debug skin active:

Debug.skin.mov

@github-actions github-actions bot added the scripts Work on backend scripts and devops label Nov 18, 2024
@github-actions github-actions bot added the feature Work on app features/modules label Nov 18, 2024
@@ -93,6 +97,12 @@ export class TemplateContainerComponent implements OnInit, OnDestroy, ITemplateC
await this.renderTemplate();
}

ngOnChanges(changes: SimpleChanges) {
if (changes.templatename) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dynamically updating the template name (for example, when changing the name of the template to display in the footer) would hitherto not trigger the component to display the content relating to the newly referenced template

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit(blocking): I'm pretty sure this fires on init as well, meaning every template gets rendered and immediately re-rendered (looking at console logs on debug site appears to be the case). Will need to rethink how best to manage

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot. I've implemented a signla based approach in f31e5d3. I would have liked to have defined template as a computed signal that evaluates when templatename updates, however I was a bit confused by some of the logic in renderTemplate() and forceRerender(), and decided it would be best not spend time trying to unpick this as part of this PR necessarily, so I've tried to leave that untouched as much as possible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah at this point I think probably best to leave loading the template as-is. I noticed that we were still getting a double render from the effect and ngOnInit, so I removed the onInit code with e0679c8 and also did some minor tidying to make more explicit that signal value passed to the render function (could see you had included a manual workaround to call the signal value in the effect anyways).

@jfmcquade jfmcquade changed the title feat(wip): template-level layout properties feat: template-level app config overrides Nov 21, 2024
@jfmcquade jfmcquade marked this pull request as ready for review November 21, 2024 15:40
@github-actions github-actions bot added feature Work on app features/modules and removed feature Work on app features/modules labels Nov 21, 2024
Copy link
Collaborator

@esmeetewinkel esmeetewinkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I've not read the full thread, so I might be missing something, but)

When testing on the preview link I'm seeing a footer (with no content) on the template feat_app_layout_header_compact

image

@jfmcquade
Copy link
Collaborator Author

jfmcquade commented Nov 29, 2024

When testing on the preview link I'm seeing a footer (with no content) on the template feat_app_layout_header_compact

Thanks @esmeetewinkel, you're right to flag this as an issue. This was present on the PR preview but not when running locally because the debug content hadn't been updated to reflect the minor change to the sheet parser (which now parses nested boolean values within a template-level parameter_list), so the version on the web preview link was trying to set the footer to display a template named "false" rather than interpreting the value as false and hiding the footer.

I have now updated the debug content repo with the latest changes (see IDEMSInternational/app-debug-content#120), so the functionality on the latest web preview should work as expected (I triggered the web preview action to re-run by removing and adding the test - preview flag).

The template on the web preview link does appear to be working now: https://plh-teens-app1--pr2531-feat-template-level-5141d3ic.web.app/template/feat_app_layout_header_compact
I think I had to "Empty cache and hard reload" to see the changes (or open the link in an incognito window to circumvent any caching).

@esmeetewinkel esmeetewinkel self-requested a review November 29, 2024 17:09
Copy link
Collaborator

@esmeetewinkel esmeetewinkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional test passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Work on app features/modules scripts Work on backend scripts and devops test - preview Create a preview deployment of the PR test - visual Run visual regression tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants