fix: add visible to appmetadata's access property#18066
Conversation
7e1d8c9 to
fb019f6
Compare
📝 WalkthroughWalkthroughVisibility 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
There was a problem hiding this comment.
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 | 🔴 CriticalWrite visibility back to
access.visible.Line 131 still updates a top-level
visible, but the card now reads fromaccess.visibleon 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 foraccess.visible.This only verifies the initial hidden state. Please extend it, or add a neighbouring test, to toggle the visibility switch and assert
saveAppConfigreceivesaccess.visible; that would catch the current handler bug inAppConfigForm.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
📒 Files selected for processing (5)
src/Designer/backend/src/Designer/Models/App/ApplicationMetadata.cssrc/Designer/backend/src/Designer/Services/Implementation/Validation/AltinnAppServiceResourceService.cssrc/Designer/frontend/app-development/features/appSettings/components/TabsContent/Tabs/AboutTab/AppConfigForm/AppConfigForm.test.tsxsrc/Designer/frontend/app-development/features/appSettings/components/TabsContent/Tabs/AboutTab/AppConfigForm/AppConfigForm.tsxsrc/Designer/frontend/packages/shared/src/types/ApplicationMetadata.ts
fb019f6 to
af2100a
Compare
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
af2100a to
1a2816d
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/Designer/backend/src/Designer/Services/Implementation/Validation/AltinnAppServiceResourceService.cs (1)
168-168:⚠️ Potential issue | 🟠 MajorDo not default missing
access.visibleto hidden.Line 168 turns an omitted
Access.Visibleintofalse, so older app metadata will be published as hidden. That also disagrees with the frontend, which defaults missingaccess.visibletotrueinAppConfigForm.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
📒 Files selected for processing (5)
src/Designer/backend/src/Designer/Models/App/ApplicationMetadata.cssrc/Designer/backend/src/Designer/Services/Implementation/Validation/AltinnAppServiceResourceService.cssrc/Designer/frontend/app-development/features/appSettings/components/TabsContent/Tabs/AboutTab/AppConfigForm/AppConfigForm.test.tsxsrc/Designer/frontend/app-development/features/appSettings/components/TabsContent/Tabs/AboutTab/AppConfigForm/AppConfigForm.tsxsrc/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
Description
visiblewas not properly handled when publishing to resource registry.This PR adds
visibletoapplicationMetadata.access.visibleand properly sets it on the ServiceResource when publishing to Resource Registry.Verification
Summary by CodeRabbit
Refactor
UI
Backend
Tests