Skip to content

Refinements in Summary2, adding component-level overrides #3344

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

Merged
merged 20 commits into from
May 14, 2025

Conversation

olemartinorg
Copy link
Contributor

@olemartinorg olemartinorg commented May 8, 2025

Description

When looking more closely at Summary2 I found some minor things I wanted to clean up, and I ended up adding a feature I think app developers will appreaciate.

List of changes here (trying to follow the order in the diff on github):

  • Using tsx to run code generation makes it slightly faster
  • Removing the forceShow override option, as it was never read/used, so it had no effect.
  • Instead of every config.ts file exporting their summary overrides, I baked this into the code generator so that you can use the new addSummaryOverrides() function instead. The Summary2 config itself will automatically get all the different override variants that are possible.
  • When adding summary overrides, we now check to make sure the component is marked as 'summarizable'. When making a component summarizable (default for fom components, not for presentation components) text resource bindings like summaryTitle are added. That binding doesn't work yet for Summary2, but there's a separate issue for that - Summary2 component does not support summaryTitle property #2872
  • Added a component-verification.test.ts. This tests that all summarizable components actually implement renderSummary2()....which they don't, so this test has to be skipped for now. 😢
  • Rendering of a specific Summary2 component was a bit convoluted. I removed isCompact and override as props, and created hooks for getting those properties from the context instead. Now every renderSummary2() gets Summary2Props that just contains the target node.
  • When refactoring these props, I found that the Group component override for isCompact was passed around, and in the end passed over to ComponentSummary, which never read it. Since it had no effect, I removed that override property for Group components. Now the isCompact property can only be set on the Summary2 component and is not an override.
  • Some components did not pass on isCompact and emptyFieldText, and it was hard to notice because the properties were optional. I made them required, and implemented them in the components that were not passing these on to the underlying dumb components.
  • Adding a Summary2LayoutValidator to make sure overrides are not specified twice for a given component or component type
  • Making types in Summary2/config.ts more clear to app developers. When specifying type: layoutSet it should not be valid to specify an id property. When that was possible it looked like you could specify which layout set you wanted to render a summary for (such as a sub form), but the actual layout-set we render a summary for is derived from taskId and id is ignored.
  • Summary2Store was rewritten to not use zustand (no need for that, as these overrides are entirely static). Adding hooks that are more specific and useful, such as a hook for getting component overrides. This now correctly gives you overrides for the component type you're working with, and will merge component type overrides with component-id specific overrides for you.
  • Removing some remnants of LayoutNode class overrides in the node generator (I thouhgt I removed all of that earlier, but I missed some parts).

The feature part of this lets you set overrides for all components of a given type in Summary2:

"overrides": [
  {
    "componentType": "RepeatingGroup",
    "display": "table"
  },
  {
    "componentId": "U-11-Group-LeggVed",
    "hidden": true
  }
]

Related Issue(s)

Verification/QA

  • Manual functionality testing
    • I have tested these changes manually
    • Creator of the original issue (or service owner) has been contacted for manual testing (or will be contacted when released in alpha)
    • No testing done/necessary
  • Automated tests
    • Unit test(s) have been added/updated
    • Cypress E2E test(s) have been added/updated
    • No automatic tests are needed here (no functional changes/additions)
    • I want someone to help me make some tests
  • UU/WCAG (follow these guidelines until we have our own)
    • I have tested with a screen reader/keyboard navigation/automated wcag validator
    • No testing done/necessary (no DOM/visual changes)
    • I want someone to help me perform accessibility testing
  • User documentation @ altinn-studio-docs
    • Has been added/updated
    • No functionality has been changed/added, so no documentation is needed
    • I will do that later/have created an issue
  • Support in Altinn Studio
    • Issue(s) created for support in Studio
    • This change/feature does not require any changes to Altinn Studio
  • Sprint board
    • The original issue (or this PR itself) has been added to the Team Apps project and to the current sprint board
    • I don't have permissions to do that, please help me out
  • Labels
    • I have added a kind/* and backport* label to this PR for proper release notes grouping
    • I don't have permissions to add labels, please help me out

Ole Martin Handeland added 20 commits May 8, 2025 13:35
…stand there), and trying to grok the code here.
…des for isCompact, as well as possibly being related to the root cause behind issues like #3234
… level. I want to structure this better, and verify that summarizable components all have the summarizable capability set up (indicating that they have summary-related props as well)
…em from the context directly to make it more clear where they are actually used.
…to common components (which now require these props)
…ng the 'forceShow' common prop that was never read.
…summary overrides. This isn't quite working yet because something is ruining the entire jsonschema. Committing now before merging from main and continuing debugging.
…of every common object, ruining the additionalProperties check so that it returned false in some cases.
@olemartinorg olemartinorg self-assigned this May 8, 2025
@olemartinorg olemartinorg added kind/product-feature Pull requests containing new features backport-ignore This PR is a new feature and should not be cherry-picked onto release branches labels May 8, 2025
Copy link

sonarqubecloud bot commented May 8, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
43.7% Coverage on New Code (required ≥ 45%)
8.6% Duplication on New Code (required ≤ 3%)
35.77% Condition Coverage on New Code (required ≥ 45%)

See analysis details on SonarQube Cloud

Copy link
Contributor

@adamhaeger adamhaeger left a comment

Choose a reason for hiding this comment

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

Some good changes, but not sure about added features.

@olemartinorg olemartinorg merged commit 33ebecc into main May 14, 2025
22 of 25 checks passed
@olemartinorg olemartinorg deleted the chore/summary2-cleanup branch May 14, 2025 09:10
@github-project-automation github-project-automation bot moved this to 🧪 Test in Team Apps May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-ignore This PR is a new feature and should not be cherry-picked onto release branches kind/product-feature Pull requests containing new features
Projects
Status: 🧪 Test
Development

Successfully merging this pull request may close these issues.

2 participants