Skip to content

feat/18402 hide appName header in pdf#4173

Open
walldenfilippa wants to merge 7 commits into
mainfrom
feat/18402-hide-app-name-pdf
Open

feat/18402 hide appName header in pdf#4173
walldenfilippa wants to merge 7 commits into
mainfrom
feat/18402-hide-app-name-pdf

Conversation

@walldenfilippa
Copy link
Copy Markdown
Contributor

@walldenfilippa walldenfilippa commented May 6, 2026

Description

The hideAppNameInPdf property determines whether the app name is displayed in the PDF header.
Footer appName is handled in app-lib: Altinn/app-lib-dotnet#1753

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

Summary by CodeRabbit

  • New Features

    • Added a page-level setting to hide the application name in generated PDFs (defaults to shown).
  • Tests

    • Added tests verifying the app name is shown by default and can be hidden via the new setting.

Review Change Stack

@walldenfilippa walldenfilippa 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 squad/utforming Issues that belongs to the named squad. labels May 6, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

📝 Walkthrough

Walkthrough

Adds a boolean hideAppNameInPdf setting (default false) to global/page settings, includes it in merged page settings, reads and evaluates it in PDF rendering to conditionally hide the app-name heading, and adds tests for the behavior.

Changes

PDF App Name Hide Flag

Layer / File(s) Summary
Schema: add hideAppNameInPdf
src/codegen/Common.ts
Adds hideAppNameInPdf?: boolean (default false) to generated GlobalPageSettings and reorders validationOnNavigation after it.
Defaults: include hideAppNameInPdf
src/features/form/layoutSettings/LayoutSettingsContext.tsx
Adds hideAppNameInPdf: false to usePageSettings defaults so merged settings include the flag when not overridden.
PDF imports & eval wiring
src/features/pdf/PdfFromLayout.tsx
Imports usePageSettings and useEvalExpression, retrieves hideAppNameInPdf and evaluates it to a boolean.
PDF rendering conditional
src/features/pdf/PdfFromLayout.tsx
Conditionally renders the app-name Heading only when evaluated hideAppNameInPdf is false.
Tests: PDF wrapper hideAppNameInPdf
src/features/pdf/PDFWrapper.test.tsx
Adds getLayoutSetsMock import and tests asserting the app name is present by default / when uiSettings.hideAppNameInPdf is false, and absent when true.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main feature being added: the ability to hide the app name in the PDF header.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description includes a clear summary, related issue reference, and comprehensive verification/QA checklist with appropriate items checked.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/18402-hide-app-name-pdf

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@walldenfilippa walldenfilippa marked this pull request as draft May 13, 2026 08:08
…s prop hideAppNameInPdf from enum to ExprVal.Boolean
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/features/form/layoutSettings/LayoutSettingsContext.tsx (1)

65-75: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

hideAppNameInPdf is not propagated from settings.pages

You added a default at Line 133, but processData never copies settings.pages.hideAppNameInPdf into pageSettings. That means page-level configuration is ignored.

Suggested fix
   pageSettings: omitUndefined({
     autoSaveBehavior: settings.pages.autoSaveBehavior,
     expandedWidth: settings.pages.expandedWidth,
     hideCloseButton: settings.pages.hideCloseButton,
+    hideAppNameInPdf: settings.pages.hideAppNameInPdf,
     navigationTitle: settings.pages.navigationTitle,
     showExpandWidthButton: settings.pages.showExpandWidthButton,
     showLanguageSelector: settings.pages.showLanguageSelector,
     showProgress: settings.pages.showProgress,
     taskNavigation: settings.pages.taskNavigation?.map((g) => ({ ...g, id: uuidv4() })),
     validationOnNavigation: settings.pages.validationOnNavigation,
   }),

Also applies to: 133-133

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/features/form/layoutSettings/LayoutSettingsContext.tsx` around lines 65 -
75, processData currently fails to propagate the page-level hideAppNameInPdf
because pageSettings (in the object built for processData) omits that property;
update the pageSettings mapping inside processData to include hideAppNameInPdf:
settings.pages.hideAppNameInPdf so the page-level configuration is copied
through (reference: pageSettings, processData, settings.pages.hideAppNameInPdf).
🧹 Nitpick comments (1)
src/features/pdf/PDFWrapper.test.tsx (1)

101-129: ⚡ Quick win

Use renderWithProviders for these form-layout-context tests

These new cases exercise PdfWrapper with form layout context; please switch them to renderWithProviders instead of the custom render path for consistency with project test setup.

As per coding guidelines, "Use renderWithProviders from src/test/renderWithProviders.tsx when testing components that require form layout context".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/features/pdf/PDFWrapper.test.tsx` around lines 101 - 129, Replace the
custom render calls in PDFWrapper.test.tsx for the hideAppNameInPdf suite with
the project helper renderWithProviders (imported from
src/test/renderWithProviders.tsx) so the tests run with the form layout context;
specifically change uses of render(RenderAs.User, {...}) to
renderWithProviders(RenderAs.User, {...}) and update the test file imports to
import renderWithProviders and remove/replace the old render import, keeping the
same options (e.g., fetchLayoutSets) and assertions for `#readyForPrint` and the
heading checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/features/form/layoutSettings/LayoutSettingsContext.tsx`:
- Around line 65-75: processData currently fails to propagate the page-level
hideAppNameInPdf because pageSettings (in the object built for processData)
omits that property; update the pageSettings mapping inside processData to
include hideAppNameInPdf: settings.pages.hideAppNameInPdf so the page-level
configuration is copied through (reference: pageSettings, processData,
settings.pages.hideAppNameInPdf).

---

Nitpick comments:
In `@src/features/pdf/PDFWrapper.test.tsx`:
- Around line 101-129: Replace the custom render calls in PDFWrapper.test.tsx
for the hideAppNameInPdf suite with the project helper renderWithProviders
(imported from src/test/renderWithProviders.tsx) so the tests run with the form
layout context; specifically change uses of render(RenderAs.User, {...}) to
renderWithProviders(RenderAs.User, {...}) and update the test file imports to
import renderWithProviders and remove/replace the old render import, keeping the
same options (e.g., fetchLayoutSets) and assertions for `#readyForPrint` and the
heading checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f150a490-250c-4561-8bcd-fc2a1b290579

📥 Commits

Reviewing files that changed from the base of the PR and between 6ef2980 and e7af200.

📒 Files selected for processing (4)
  • src/codegen/Common.ts
  • src/features/form/layoutSettings/LayoutSettingsContext.tsx
  • src/features/pdf/PDFWrapper.test.tsx
  • src/features/pdf/PdfFromLayout.tsx

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@Magnusrm Magnusrm left a comment

Choose a reason for hiding this comment

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

Nice! 🥳

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 squad/utforming Issues that belongs to the named squad.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skjule appName på underskjemaene i pdf-visning

2 participants