feat: instance contextual layout fetching#1544
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis pull request introduces support for instance-specific custom layouts. It adds a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
03c5d90 to
1f10c35
Compare
e8df578 to
e56150a
Compare
21399d0 to
3dffd17
Compare
ivarne
left a comment
There was a problem hiding this comment.
Siden dette er en applikasjons konfigurasjon for frontend, så ville jeg droppet FeatureManager og heller bare bedt brukerene gå direkte til appsettings.json og legge til "FrontendSettings": {"AddInstanceIdentifierToLayoutRequests": true} uten at det krever noe videre konfigurasjon i backend.
3dffd17 to
271ca38
Compare
f307242 to
301807c
Compare
69d0c68 to
733ec02
Compare
1b4246a to
9fb5195
Compare
9fb5195 to
0bfe1ba
Compare
b443d20 to
668ffdc
Compare
|
/publish |
ca5dfe8 to
33b9d3f
Compare
|
/publish |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/Altinn.App.Core/Features/FeatureFlags.cs`:
- Around line 16-21: The XML summary for the public constant
AddInstanceIdentifierToLayoutRequests contains a TODO; replace it with a
concise, concrete summary describing the flag's behavior (e.g., that enabling
this feature changes the backend layout endpoint to include the instance
identifier in requests), update the <summary> tag text accordingly so generated
API docs are complete, and ensure wording is clear and present-tense without
TODO markers.
🧹 Nitpick comments (2)
src/Altinn.App.Api/Controllers/ResourceController.cs (2)
22-25: Consider injectingAppImplementationFactorydirectly.Using
IServiceProvider.GetRequiredService<T>()in the constructor is a service locator pattern. Prefer direct constructor injection for better testability and clearer dependencies.♻️ Proposed refactor
- /// <param name="serviceProvider">The service provider</param> - public ResourceController(IAppResources appResourcesService, IServiceProvider serviceProvider) + /// <param name="appImplementationFactory">The app implementation factory</param> + public ResourceController(IAppResources appResourcesService, AppImplementationFactory appImplementationFactory) { _appResourceService = appResourcesService; - _appImplementationFactory = serviceProvider.GetRequiredService<AppImplementationFactory>(); + _appImplementationFactory = appImplementationFactory; }
90-90: Consider adding GUID route constraint for consistency and early validation.The route uses
{instanceId}as a string, but existing instance endpoints in this codebase use{instanceGuid:guid}with a GUID constraint. Adding the constraint would reject invalid GUIDs at the routing level (returning 404) and maintain consistency with other instance-scoped endpoints.♻️ Proposed change
- [Route("{org}/{app}/instances/{instanceOwnerPartyId:int}/{instanceId}/layouts/{layoutSetId}")] + [Route("{org}/{app}/instances/{instanceOwnerPartyId:int}/{instanceGuid:guid}/layouts/{layoutSetId}")]Note: This would also require renaming the parameter in the method signature from
instanceIdtoinstanceGuidand updating the XML documentation accordingly.
| // TODO: write a better summary here | ||
| /// <summary> | ||
| /// Enabling this feature changes backend endpoint used for layouts to | ||
| /// add instance identifier. | ||
| /// </summary> | ||
| public const string AddInstanceIdentifierToLayoutRequests = "AddInstanceIdentifierToLayoutRequests"; |
There was a problem hiding this comment.
Replace the TODO with a concrete summary before release.
Leaving a TODO in a public API constant’s XML doc makes the documentation incomplete and leaks into generated docs.
📝 Suggested update
- // TODO: write a better summary here
- /// <summary>
- /// Enabling this feature changes backend endpoint used for layouts to
- /// add instance identifier.
- /// </summary>
+ /// <summary>
+ /// When enabled, layout fetches use instance-scoped endpoints so layout requests
+ /// include the instance identifier.
+ /// </summary>
public const string AddInstanceIdentifierToLayoutRequests = "AddInstanceIdentifierToLayoutRequests";📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // TODO: write a better summary here | |
| /// <summary> | |
| /// Enabling this feature changes backend endpoint used for layouts to | |
| /// add instance identifier. | |
| /// </summary> | |
| public const string AddInstanceIdentifierToLayoutRequests = "AddInstanceIdentifierToLayoutRequests"; | |
| /// <summary> | |
| /// When enabled, layout fetches use instance-scoped endpoints so layout requests | |
| /// include the instance identifier. | |
| /// </summary> | |
| public const string AddInstanceIdentifierToLayoutRequests = "AddInstanceIdentifierToLayoutRequests"; |
🤖 Prompt for AI Agents
In `@src/Altinn.App.Core/Features/FeatureFlags.cs` around lines 16 - 21, The XML
summary for the public constant AddInstanceIdentifierToLayoutRequests contains a
TODO; replace it with a concise, concrete summary describing the flag's behavior
(e.g., that enabling this feature changes the backend layout endpoint to include
the instance identifier in requests), update the <summary> tag text accordingly
so generated API docs are complete, and ensure wording is clear and
present-tense without TODO markers.
|
/publish |
(cherry picked from commit cea36ab)
|
|



Description
Related PR: Altinn/app-frontend-react#3818
Adds new service
ICustomLayoutForInstance, and endpoint inResourcesController.When used together with the featureFlag
AddInstanceIdentifierToLayoutRequests, the frontend uses this new endpoint to fetch layouts. If the app implementsICustomLayoutForInstancethis service is called instead ofIAppResources, giving access to instance information when returning layouts.Related Issue(s)
Verification
Documentation
Summary by CodeRabbit
New Features
Improvements