Skip to content

fix: add visible to appmetadata's access property#18066

Merged
Jondyr merged 2 commits intomainfrom
fix/appmetadata-visibility-to-access-object
Mar 9, 2026
Merged

fix: add visible to appmetadata's access property#18066
Jondyr merged 2 commits intomainfrom
fix/appmetadata-visibility-to-access-object

Conversation

@Jondyr
Copy link
Copy Markdown
Member

@Jondyr Jondyr commented Mar 6, 2026

Description

visible was not properly handled when publishing to resource registry.
This PR adds visible to applicationMetadata.access.visible and properly sets it on the ServiceResource when publishing to Resource Registry.

Verification

  • Related issues are connected (if applicable)
  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Summary by CodeRabbit

  • Refactor

    • Visibility settings moved into the access metadata to consolidate visibility and access controls.
  • UI

    • App settings UI now reads and defaults visibility from the nested access section.
  • Backend

    • Service resource output now includes visibility so it aligns with the relocated access metadata.
  • Tests

    • Updated tests to reflect visibility being nested under access.

@Jondyr Jondyr force-pushed the fix/appmetadata-visibility-to-access-object branch from 7e1d8c9 to fb019f6 Compare March 6, 2026 09:12
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 6, 2026

📝 Walkthrough

Walkthrough

Visibility was relocated from top-level application metadata into the nested access object. Backend model and mapper were updated to include/access the nested Visible property; frontend types, component logic, and tests were adjusted to read and default visibility from appConfig.access.visible.

Changes

Cohort / File(s) Summary
Backend Model
src/Designer/backend/src/Designer/Models/App/ApplicationMetadata.cs
Added nullable Visible property to AppMetadataAccess.
Backend Mapping
src/Designer/backend/src/Designer/Services/Implementation/Validation/AltinnAppServiceResourceService.cs
Mapped ServiceResource.Visible from applicationMetadata?.Access?.Visible ?? false.
Frontend Types
src/Designer/frontend/packages/shared/src/types/ApplicationMetadata.ts
Removed visible?: boolean from ApplicationMetadata; added visible?: boolean to ApplicationAccessMetadata.
Frontend Component & Tests
src/Designer/frontend/app-development/features/appSettings/components/.../AppConfigForm/AppConfigForm.tsx, .../AppConfigForm.test.tsx
Moved defaulting and usage of visibility into appConfig.access.visible; updated test fixtures to nest visible under access.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Once visible sat out in the sun,
Now it snuggles where access is spun,
A tiny hop, a tidy move,
Structure kept and logic smooth,
I nibble bugs and then I'm done. 🥕

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: relocating the visible property from the top-level ApplicationMetadata to the nested access object.
Description check ✅ Passed The description covers the main objective and verification checklist, though the automated test checkbox was not marked despite test file modifications.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/appmetadata-visibility-to-access-object

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

@Jondyr Jondyr added the squad/utforming Issues that belongs to the named squad. label Mar 6, 2026
@Jondyr Jondyr self-assigned this Mar 6, 2026
@Jondyr Jondyr moved this to 👷 In progress in Team Altinn Studio Mar 6, 2026
@Jondyr Jondyr marked this pull request as ready for review March 6, 2026 09:13
@github-actions github-actions Bot added skip-releasenotes Issues that do not make sense to list in our release notes backend frontend solution/studio/designer labels Mar 6, 2026
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.

Actionable comments posted: 2

Caution

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

⚠️ Outside diff range comments (1)
src/Designer/frontend/app-development/features/appSettings/components/TabsContent/Tabs/AboutTab/AppConfigForm/AppConfigForm.tsx (1)

127-133: ⚠️ Potential issue | 🔴 Critical

Write visibility back to access.visible.

Line 131 still updates a top-level visible, but the card now reads from access.visible on Line 176. Toggling the switch therefore leaves the UI state unchanged and drops the value from the payload that gets saved.

Suggested fix
   const onChangeVisible = (e: ChangeEvent<HTMLInputElement>): void => {
     const isVisible = e.target.checked;
     setUpdatedAppConfig((oldVal: ApplicationMetadata) => ({
       ...oldVal,
-      visible: isVisible,
-      access: { ...oldVal.access, ...(isVisible ? { delegable: true } : {}) },
+      access: {
+        ...oldVal.access,
+        visible: isVisible,
+        ...(isVisible ? { delegable: true } : {}),
+      },
     }));
   };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/Designer/frontend/app-development/features/appSettings/components/TabsContent/Tabs/AboutTab/AppConfigForm/AppConfigForm.tsx`
around lines 127 - 133, The onChangeVisible handler currently writes the
visibility to a top-level visible property but the UI reads from access.visible;
update the handler (onChangeVisible) to set updatedAppConfig.access.visible
instead of top-level visible (via setUpdatedAppConfig), preserving other access
fields (and keep delegable logic if isVisible) so the toggle updates the UI and
the saved payload correctly; ensure you update the ApplicationMetadata object
shape only under access.visible and not create a stray top-level visible.
🧹 Nitpick comments (1)
src/Designer/frontend/app-development/features/appSettings/components/TabsContent/Tabs/AboutTab/AppConfigForm/AppConfigForm.test.tsx (1)

138-153: Add a save-path regression test for access.visible.

This only verifies the initial hidden state. Please extend it, or add a neighbouring test, to toggle the visibility switch and assert saveAppConfig receives access.visible; that would catch the current handler bug in AppConfigForm.tsx.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/Designer/frontend/app-development/features/appSettings/components/TabsContent/Tabs/AboutTab/AppConfigForm/AppConfigForm.test.tsx`
around lines 138 - 153, Add a regression test that toggles the visibility switch
and verifies saveAppConfig receives the updated access.visible value: using the
same test harness helpers (renderAppConfigForm, getSwitch, userEvent.setup) find
the visibility switch (use the i18n key used in the form, e.g. the visibility
label textMock key), assert its initial state (visible: false), click it to
toggle, then trigger the form save (or submit action used in other tests) and
assert the mocked saveAppConfig was called with an appConfig whose
access.visible is true; this mirrors the existing delegation test pattern and
will catch the handler bug in AppConfigForm that fails to include access.visible
when saving.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/Designer/backend/src/Designer/Services/Implementation/Validation/AltinnAppServiceResourceService.cs`:
- Line 168: The assignment Visible = applicationmetadata?.Access?.Visible ??
false incorrectly defaults missing access.visible to false; change it so missing
metadata preserves ServiceResource's default-true behavior by using a true
default (e.g., set Visible to applicationmetadata?.Access?.Visible ?? true or
omit the coalescing so the ServiceResource.Visible default remains) — update the
expression in AltinnAppServiceResourceService where Visible is set from
applicationmetadata?.Access?.Visible to avoid defaulting to false.

In
`@src/Designer/frontend/app-development/features/appSettings/components/TabsContent/Tabs/AboutTab/AppConfigForm/AppConfigForm.tsx`:
- Around line 136-138: Remove the three debug console.log statements in
AppConfigForm (the lines logging 'updatedAppConfig', 'appConfigWithDefaults',
and 'equal' using ObjectUtils.areObjectsEqual) so sensitive config data is not
dumped to the browser console; if you still need diagnostics, replace them with
a guarded debug helper or use a dev-only logger that masks sensitive fields
before logging, but for this change simply delete those console.log calls from
the component.

---

Outside diff comments:
In
`@src/Designer/frontend/app-development/features/appSettings/components/TabsContent/Tabs/AboutTab/AppConfigForm/AppConfigForm.tsx`:
- Around line 127-133: The onChangeVisible handler currently writes the
visibility to a top-level visible property but the UI reads from access.visible;
update the handler (onChangeVisible) to set updatedAppConfig.access.visible
instead of top-level visible (via setUpdatedAppConfig), preserving other access
fields (and keep delegable logic if isVisible) so the toggle updates the UI and
the saved payload correctly; ensure you update the ApplicationMetadata object
shape only under access.visible and not create a stray top-level visible.

---

Nitpick comments:
In
`@src/Designer/frontend/app-development/features/appSettings/components/TabsContent/Tabs/AboutTab/AppConfigForm/AppConfigForm.test.tsx`:
- Around line 138-153: Add a regression test that toggles the visibility switch
and verifies saveAppConfig receives the updated access.visible value: using the
same test harness helpers (renderAppConfigForm, getSwitch, userEvent.setup) find
the visibility switch (use the i18n key used in the form, e.g. the visibility
label textMock key), assert its initial state (visible: false), click it to
toggle, then trigger the form save (or submit action used in other tests) and
assert the mocked saveAppConfig was called with an appConfig whose
access.visible is true; this mirrors the existing delegation test pattern and
will catch the handler bug in AppConfigForm that fails to include access.visible
when saving.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5cd4c3af-5427-40f6-9b2e-f1fe6de20c43

📥 Commits

Reviewing files that changed from the base of the PR and between c3c4158 and fb019f6.

📒 Files selected for processing (5)
  • src/Designer/backend/src/Designer/Models/App/ApplicationMetadata.cs
  • src/Designer/backend/src/Designer/Services/Implementation/Validation/AltinnAppServiceResourceService.cs
  • src/Designer/frontend/app-development/features/appSettings/components/TabsContent/Tabs/AboutTab/AppConfigForm/AppConfigForm.test.tsx
  • src/Designer/frontend/app-development/features/appSettings/components/TabsContent/Tabs/AboutTab/AppConfigForm/AppConfigForm.tsx
  • src/Designer/frontend/packages/shared/src/types/ApplicationMetadata.ts

@Jondyr Jondyr force-pushed the fix/appmetadata-visibility-to-access-object branch from fb019f6 to af2100a Compare March 6, 2026 09:27
@Jondyr Jondyr moved this from 👷 In progress to 🔎 In review in Team Altinn Studio Mar 6, 2026
@Jondyr Jondyr removed their assignment Mar 6, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.20%. Comparing base (eb9dd3d) to head (1a2816d).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...tent/Tabs/AboutTab/AppConfigForm/AppConfigForm.tsx 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #18066   +/-   ##
=======================================
  Coverage   95.20%   95.20%           
=======================================
  Files        2505     2505           
  Lines       32588    32588           
  Branches     3869     3869           
=======================================
  Hits        31025    31025           
  Misses       1218     1218           
  Partials      345      345           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Jondyr Jondyr added skip-manual-testing Deprecated: Use skip-second-approval instead. skip-second-approval Pull requests that only need one approval from a reviewer. approve You approve this PR. Use when: - Small changes - Already agreed upon - Async review and removed skip-manual-testing Deprecated: Use skip-second-approval instead. skip-second-approval Pull requests that only need one approval from a reviewer. labels Mar 9, 2026
@Jondyr Jondyr force-pushed the fix/appmetadata-visibility-to-access-object branch from af2100a to 1a2816d Compare March 9, 2026 07:36
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.

♻️ Duplicate comments (1)
src/Designer/backend/src/Designer/Services/Implementation/Validation/AltinnAppServiceResourceService.cs (1)

168-168: ⚠️ Potential issue | 🟠 Major

Do not default missing access.visible to hidden.

Line 168 turns an omitted Access.Visible into false, so older app metadata will be published as hidden. That also disagrees with the frontend, which defaults missing access.visible to true in AppConfigForm.tsx.

Suggested fix
-            Visible = applicationmetadata?.Access?.Visible ?? false,
+            Visible = applicationmetadata?.Access?.Visible ?? true,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/Designer/backend/src/Designer/Services/Implementation/Validation/AltinnAppServiceResourceService.cs`
at line 168, The mapper is defaulting a missing
applicationmetadata.Access.Visible to false, causing older apps to be treated as
hidden; in AltinnAppServiceResourceService (the code that sets Visible =
applicationmetadata?.Access?.Visible ?? false) change the behavior to either
preserve null or default to true so that omitted access.visible is considered
visible (align with AppConfigForm.tsx). Locate the assignment for Visible in
AltinnAppServiceResourceService and update it to not force false on missing
values (use a null-preserving or true-defaulting expression for
applicationmetadata?.Access?.Visible).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In
`@src/Designer/backend/src/Designer/Services/Implementation/Validation/AltinnAppServiceResourceService.cs`:
- Line 168: The mapper is defaulting a missing
applicationmetadata.Access.Visible to false, causing older apps to be treated as
hidden; in AltinnAppServiceResourceService (the code that sets Visible =
applicationmetadata?.Access?.Visible ?? false) change the behavior to either
preserve null or default to true so that omitted access.visible is considered
visible (align with AppConfigForm.tsx). Locate the assignment for Visible in
AltinnAppServiceResourceService and update it to not force false on missing
values (use a null-preserving or true-defaulting expression for
applicationmetadata?.Access?.Visible).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 34ee5a38-495c-44b3-aaaf-7e84449ea5fc

📥 Commits

Reviewing files that changed from the base of the PR and between fb019f6 and 1a2816d.

📒 Files selected for processing (5)
  • src/Designer/backend/src/Designer/Models/App/ApplicationMetadata.cs
  • src/Designer/backend/src/Designer/Services/Implementation/Validation/AltinnAppServiceResourceService.cs
  • src/Designer/frontend/app-development/features/appSettings/components/TabsContent/Tabs/AboutTab/AppConfigForm/AppConfigForm.test.tsx
  • src/Designer/frontend/app-development/features/appSettings/components/TabsContent/Tabs/AboutTab/AppConfigForm/AppConfigForm.tsx
  • src/Designer/frontend/packages/shared/src/types/ApplicationMetadata.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/Designer/backend/src/Designer/Models/App/ApplicationMetadata.cs
  • src/Designer/frontend/app-development/features/appSettings/components/TabsContent/Tabs/AboutTab/AppConfigForm/AppConfigForm.tsx

@Jondyr Jondyr merged commit a51c414 into main Mar 9, 2026
18 checks passed
@Jondyr Jondyr deleted the fix/appmetadata-visibility-to-access-object branch March 9, 2026 07:42
@github-project-automation github-project-automation Bot moved this from 🔎 In review to ✅ Done in Team Altinn Studio Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approve You approve this PR. Use when: - Small changes - Already agreed upon - Async review backend frontend skip-releasenotes Issues that do not make sense to list in our release notes solution/studio/designer squad/utforming Issues that belongs to the named squad.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant