Skip to content

Conversation

@TomasEng
Copy link
Contributor

@TomasEng TomasEng commented Dec 31, 2025

Description

This pull request simplifies the usage of the content library component.

Current code:

{new ResourceContentLibraryImpl(props).getContentResourceLibrary()}

New code:

<ContentLibrary {...props}/>

The ResourceContentLibraryImpl does not provide anything useful to the code. The Impl suffix indicates a dependency inversion pattern, but this pattern is not applied here, since the class is not based on any abstract interface class, and it's defined within the package. I have therefore removed the class and exposed the component directly.

Verification

  • Related issues are connected (if applicable)
  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Not necessary to add new tests; refactoring only

Summary by CodeRabbit

  • New Features

    • Introduced a provider-wrapped content library component for consistent rendering.
  • Refactor

    • Replaced prior implementation with direct content library usage and simplified public exports.
    • Consolidated component patterns to reduce duplication and streamline integration.
  • Tests

    • Updated tests and mocks to align with the new component structure.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 31, 2025

📝 Walkthrough

Walkthrough

Refactors the content library from a class-based ResourceContentLibraryImpl to a component-based ContentLibraryWithProvider exported as ContentLibrary; updates all usages and tests to render/mock the new component directly.

Changes

Cohort / File(s) Summary
Core library removal
src/Designer/frontend/libs/studio-content-library/src/config/ContentResourceLibraryImpl.tsx
File removed; ResourceContentLibraryImpl class, its constructor, fields and getContentResourceLibrary() method deleted.
New component & barrel
src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.tsx, src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/index.ts
Adds ContentLibraryWithProvider component that wraps RouterContextProvider and renders ContentLibrary; new index re-exports it.
Library public exports
src/Designer/frontend/libs/studio-content-library/src/index.ts
Replaces export of ResourceContentLibraryImpl with ContentLibraryWithProvider aliased and exported as ContentLibrary.
Application usage updates
src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.tsx, src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx
Replace instantiation of ResourceContentLibraryImpl with direct JSX <ContentLibrary .../>, forwarding the same heading and pages props.
Tests — app content
src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsx
Test mock switched from ResourceContentLibraryImpl to mocked ContentLibrary; removed mockConstructor and helpers; tests read constructor args from MockContentLibrary.mock.calls.
Tests — dashboard page
src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
Jest shim updated to export ContentLibrary wrapper around MockContentLibrary; replaced helper mocks; use MockContentLibrary.mockClear() and read calls from MockContentLibrary.mock.calls.
Tests — library component
src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.test.tsx
Tests migrated to target ContentLibraryWithProvider; added renderContentLibrary helper and updated test names and invocations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped from class to JSX bright,
Wrapped in provider, snug and light,
Props passed on with nimble cheer,
Tests now mock the component here,
A rabbit's nod — the library's right.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main refactoring objective of removing the unnecessary ResourceContentLibraryImpl class and simplifying component usage.
Description check ✅ Passed The description provides clear rationale for the changes, specific before/after code examples, and confirms all verification steps including verification tasks, though the template structure is not strictly followed.

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

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf93f87 and 0a3c53d.

📒 Files selected for processing (4)
  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsx
  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.tsx
  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsx
🧰 Additional context used
🧠 Learnings (11)
📓 Common learnings
Learnt from: framitdavid
Repo: Altinn/altinn-studio PR: 16372
File: src/Designer/frontend/libs/studio-components/src/components/index.ts:34-34
Timestamp: 2025-09-23T08:53:19.508Z
Learning: In the Altinn Studio codebase, when moving components from studio-components-legacy to studio-components, the team prefers to handle the component migration and remaining import updates in separate PRs to maintain focused, atomic changes.
Learnt from: mirkoSekulic
Repo: Altinn/altinn-studio PR: 16095
File: src/App/app-template-dotnet/src/App/models/model.cs:10-29
Timestamp: 2025-08-15T05:53:32.529Z
Learning: When moving app templates in Altinn Studio, mirkoSekulic prefers to keep the PR scope strictly limited to the move operation itself, with all content changes (including code quality improvements, naming convention fixes, and attribute cleanup) deferred to separate PRs for better maintainability and atomic changes.
Learnt from: ErlingHauan
Repo: Altinn/altinn-studio PR: 15977
File: frontend/libs/studio-components-legacy/src/components/StudioCard/index.tsx:2-7
Timestamp: 2025-08-06T12:36:57.397Z
Learning: When a developer copies a component from `studio-components-legacy` to `studio-components` in the Altinn Studio repository and has not added a deprecation comment for the component in `studio-components-legacy`, suggest adding the deprecation comment in the PR review.
Learnt from: ErlingHauan
Repo: Altinn/altinn-studio PR: 15977
File: frontend/libs/studio-components-legacy/src/components/StudioCard/index.tsx:2-7
Timestamp: 2025-08-06T12:37:01.381Z
Learning: When reviewing PRs in the Altinn Studio repository where a developer copies a component from `studio-components-legacy` to `studio-components`, suggest adding a `deprecated` JSDoc comment to the component in `studio-components-legacy` if one hasn't been added. The deprecation comment should recommend using the component from `studio/components` instead.
Learnt from: HauklandJ
Repo: Altinn/altinn-studio PR: 16948
File: src/Designer/backend/src/Designer/Services/Implementation/SourceControlSI.cs:549-560
Timestamp: 2025-11-25T14:01:29.170Z
Learning: In PR #16948 (Altinn/altinn-studio), OrgCodeListService is being removed in its entirety as part of the migration to the new OrgLibraryService and updated org library endpoints. Any issues flagged in OrgCodeListService should be considered in the context of this planned removal.
Learnt from: mgunnerud
Repo: Altinn/altinn-studio PR: 16187
File: frontend/resourceadm/components/ResourcePageInputs/ResourceSwitchInput.tsx:3-3
Timestamp: 2025-08-25T13:55:27.042Z
Learning: In the Altinn Studio codebase, when migrating from studio/components-legacy to studio/components, PRs should focus only on components that have available replacements in the new package. Components without new implementations should remain in the legacy package until replacements are available, supporting an incremental migration approach.
Learnt from: TomasEng
Repo: Altinn/altinn-studio PR: 0
File: :0-0
Timestamp: 2025-09-10T12:02:06.348Z
Learning: In the Altinn Studio repository, the team convention is to remove irrelevant checkboxes from the PR template description rather than leaving them unmarked. This makes it clear that the author has intentionally considered each item and removed non-applicable ones, helping to avoid merging PRs with incomplete checklists.
Learnt from: TomasEng
Repo: Altinn/altinn-studio PR: 16064
File: frontend/libs/studio-components/src/components/StudioCheckboxGroup/StudioGetCheckboxProps.ts:1-1
Timestamp: 2025-08-12T05:59:20.146Z
Learning: In the Altinn Studio codebase, deep exports from digdir/designsystemet-react should be avoided. The team prefers using shared wrappers for design system imports to prevent breakage from upstream internal path changes, but such refactoring should be done in separate PRs to maintain focused scope.
Learnt from: TomasEng
Repo: Altinn/altinn-studio PR: 16064
File: frontend/libs/studio-components/src/components/StudioCheckboxGroup/StudioGetCheckboxProps.ts:1-1
Timestamp: 2025-08-12T06:09:55.275Z
Learning: In the Altinn Studio codebase, the preferred approach for eliminating dependencies on deep imports from digdir/designsystemet-react is to make the code completely independent of deep imports rather than using shared wrappers. This approach would eliminate the need for import path adjustments during future Design System package updates.
Learnt from: TomasEng
Repo: Altinn/altinn-studio PR: 16064
File: frontend/libs/studio-components/src/components/StudioCheckboxGroup/StudioGetCheckboxProps.ts:1-1
Timestamp: 2025-08-12T06:09:55.275Z
Learning: In the Altinn Studio codebase, the preferred approach for eliminating dependencies on deep imports from digdir/designsystemet-react is to make the code completely independent of deep imports rather than using shared wrappers. This approach would eliminate the need for import path adjustments during future Design System package updates.
📚 Learning: 2025-11-03T18:58:18.996Z
Learnt from: TomasEng
Repo: Altinn/altinn-studio PR: 16876
File: src/Designer/frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListsPage/CodeListsPage.tsx:17-23
Timestamp: 2025-11-03T18:58:18.996Z
Learning: In src/Designer/frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListsPage/CodeListsPage.tsx, the CodeListsPage component is intentionally an uncontrolled component where the codeLists prop only initializes state on mount and does not synchronize when the prop changes. This is because the createCodeListMap function generates random UUIDs for keys, making it impure. Re-calling it after the first render would reassign keys and significantly disrupt the UI (unmounting/remounting components). The component manages its own state for draft/editing purposes, and the prop is not expected to change to anything that doesn't correspond to the internal state.

Applied to files:

  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
📚 Learning: 2025-10-24T08:37:15.119Z
Learnt from: TomasEng
Repo: Altinn/altinn-studio PR: 0
File: :0-0
Timestamp: 2025-10-24T08:37:15.119Z
Learning: The `studio-content-library` package at `src/Designer/frontend/libs/studio-content-library` is a TypeScript library and does not require Python-style docstring coverage checks.

Applied to files:

  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
📚 Learning: 2025-11-25T14:01:29.170Z
Learnt from: HauklandJ
Repo: Altinn/altinn-studio PR: 16948
File: src/Designer/backend/src/Designer/Services/Implementation/SourceControlSI.cs:549-560
Timestamp: 2025-11-25T14:01:29.170Z
Learning: In PR #16948 (Altinn/altinn-studio), OrgCodeListService is being removed in its entirety as part of the migration to the new OrgLibraryService and updated org library endpoints. Any issues flagged in OrgCodeListService should be considered in the context of this planned removal.

Applied to files:

  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx
📚 Learning: 2025-10-06T17:51:23.307Z
Learnt from: JamalAlabdullah
Repo: Altinn/altinn-studio PR: 16518
File: src/Designer/frontend/libs/studio-components/src/components/StudioToggleableTextfieldSchema/StudioToggleableTextfieldSchema.stories.tsx:2-3
Timestamp: 2025-10-06T17:51:23.307Z
Learning: Altinn/altinn-studio: In Storybook stories (*.stories.tsx) under Designer/frontend libs, the project convention is to import types (Meta, StoryFn/StoryObj) from 'storybook/react-vite' rather than 'storybook/react'. Prefer 'storybook/react-vite' in future reviews for consistency.

Applied to files:

  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
📚 Learning: 2025-08-08T13:24:30.117Z
Learnt from: nkylstad
Repo: Altinn/altinn-studio PR: 0
File: :0-0
Timestamp: 2025-08-08T13:24:30.117Z
Learning: In Altinn/altinn-studio PR reviews, when unit tests need React Query/TanStack Query data, prefer seeding with QueryClient.setQueryData over rendering/mocking use…Query hooks and waiting for isSuccess. Flag patterns like renderHookWithMockStore(() => use…Query(...)) and waitFor(() => expect(result.current.isSuccess).toBe(true)) and recommend the simpler setQueryData approach. Cite the internal Confluence guideline on component tests and the best-practice example in useAddItemToLayoutMutation.test.ts (lines updated 08.08.2025).

Applied to files:

  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
📚 Learning: 2025-11-25T08:21:14.748Z
Learnt from: CR
Repo: Altinn/altinn-studio PR: 0
File: src/App/frontend/CLAUDE.md:0-0
Timestamp: 2025-11-25T08:21:14.748Z
Learning: Applies to src/App/frontend/src/__mocks__/** : Mock external dependencies in `src/__mocks__/` directory following the existing mock patterns

Applied to files:

  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
📚 Learning: 2025-01-30T12:02:25.392Z
Learnt from: mirkoSekulic
Repo: Altinn/altinn-studio PR: 14548
File: backend/tests/Designer.Tests/Hubs/EntityUpdated/EntityUpdatedHubConnectionTests.cs:19-29
Timestamp: 2025-01-30T12:02:25.392Z
Learning: Enhancement of EntityUpdatedHub test coverage requires changes in the test framework and should be implemented in a separate PR, rather than being added directly to existing tests.

Applied to files:

  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
📚 Learning: 2025-01-17T12:16:17.666Z
Learnt from: TomasEng
Repo: Altinn/altinn-studio PR: 14429
File: frontend/app-development/features/appContentLibrary/utils/mapToCodeListDataList.ts:4-5
Timestamp: 2025-01-17T12:16:17.666Z
Learning: The `mapToCodeListDataList` function in frontend/app-development/features/appContentLibrary/utils/mapToCodeListDataList.ts expects `optionListDataList` to be set when called. Query failure cases that could result in undefined input are handled at a higher level.

Applied to files:

  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
📚 Learning: 2025-11-03T19:01:47.721Z
Learnt from: cammiida
Repo: Altinn/altinn-studio PR: 16877
File: src/App/frontend/lighthouse-auth.mjs:62-64
Timestamp: 2025-11-03T19:01:47.721Z
Learning: In Altinn Studio's app-frontend testing setup, the component-library test app (located at src/test/apps/component-library/App) serves as the backend, while the frontend is served separately via webpack dev server (started with 'yarn run start' from src/App/frontend). These are two distinct layers that work together during Lighthouse CI testing.

Applied to files:

  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
📚 Learning: 2025-11-25T08:21:14.748Z
Learnt from: CR
Repo: Altinn/altinn-studio PR: 0
File: src/App/frontend/CLAUDE.md:0-0
Timestamp: 2025-11-25T08:21:14.748Z
Learning: Applies to src/App/frontend/**/*.test.{ts,tsx} : Use `renderWithProviders` utility from `src/test/renderWithProviders.tsx` when testing components that require form layout context

Applied to files:

  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
🧬 Code graph analysis (1)
src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx (1)
src/Designer/frontend/libs/studio-content-library/src/ContentLibrary/ContentLibrary.tsx (1)
  • ContentLibrary (13-16)
🔇 Additional comments (5)
src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx (2)

3-3: LGTM: Clean import simplification.

The import now references the component directly rather than the wrapper class, aligning with the PR's objective to simplify the API.


169-185: LGTM: Excellent refactoring to direct component usage.

The change from new ResourceContentLibraryImpl(props).getContentResourceLibrary() to <ContentLibrary {...props}/> is cleaner and more idiomatic. The props structure is preserved correctly, maintaining all callbacks and data.

src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx (3)

52-59: LGTM: Mock updated to match new component-based API.

The mock correctly shifts from class instantiation to functional component mocking, maintaining test coverage whilst aligning with the simplified implementation.


65-65: LGTM: Test lifecycle correctly updated.

The beforeEach hook now clears the MockContentLibrary mock, maintaining proper test isolation.


422-422: LGTM: Mock call retrieval correctly updated.

The test helper now retrieves props from MockContentLibrary.mock.calls, correctly adapting to the functional component mock pattern.


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.

@github-actions github-actions bot added area/dashboard Area: Related to the dashboard application skip-releasenotes Issues that do not make sense to list in our release notes frontend solution/studio/designer labels Dec 31, 2025
@TomasEng TomasEng force-pushed the remove-unnecessary-content-library-class branch from 91eb4fa to b9c540f Compare December 31, 2025 09:08
@TomasEng TomasEng linked an issue Dec 31, 2025 that may be closed by this pull request
6 tasks
@TomasEng TomasEng force-pushed the remove-unnecessary-content-library-class branch from b9c540f to d641ed7 Compare December 31, 2025 10:00
@codecov
Copy link

codecov bot commented Dec 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.27%. Comparing base (788c6d9) to head (73b8339).
⚠️ Report is 126 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17343      +/-   ##
==========================================
+ Coverage   96.26%   96.27%   +0.01%     
==========================================
  Files        2384     2399      +15     
  Lines       30282    30384     +102     
  Branches     3529     3537       +8     
==========================================
+ Hits        29150    29252     +102     
- Misses        820      824       +4     
+ Partials      312      308       -4     

☔ 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.

@TomasEng TomasEng force-pushed the remove-unnecessary-content-library-class branch from d641ed7 to 96d7443 Compare December 31, 2025 10:16
@TomasEng TomasEng force-pushed the remove-unnecessary-content-library-class branch from 96d7443 to cf93f87 Compare December 31, 2025 10:29
@TomasEng
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 31, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
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: 0

🧹 Nitpick comments (1)
src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.tsx (1)

153-158: Consider adding a TODO comment for the placeholder images page.

The images page has empty implementations (images: [], onUpdateImage: () => {}). If this is a placeholder for future work, adding a brief comment would aid maintainability.

🔎 Suggested improvement
          images: {
            props: {
+             // TODO: Implement image management functionality
              images: [],
              onUpdateImage: () => {},
            },
          },
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3820ed0 and cf93f87.

📒 Files selected for processing (9)
  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsx
  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx
  • src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.test.tsx
  • src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.tsx
  • src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/index.ts
  • src/Designer/frontend/libs/studio-content-library/src/config/ContentResourceLibraryImpl.tsx
  • src/Designer/frontend/libs/studio-content-library/src/index.ts
💤 Files with no reviewable changes (1)
  • src/Designer/frontend/libs/studio-content-library/src/config/ContentResourceLibraryImpl.tsx
🧰 Additional context used
🧠 Learnings (18)
📓 Common learnings
Learnt from: framitdavid
Repo: Altinn/altinn-studio PR: 16372
File: src/Designer/frontend/libs/studio-components/src/components/index.ts:34-34
Timestamp: 2025-09-23T08:53:19.508Z
Learning: In the Altinn Studio codebase, when moving components from studio-components-legacy to studio-components, the team prefers to handle the component migration and remaining import updates in separate PRs to maintain focused, atomic changes.
Learnt from: mirkoSekulic
Repo: Altinn/altinn-studio PR: 16095
File: src/App/app-template-dotnet/src/App/models/model.cs:10-29
Timestamp: 2025-08-15T05:53:32.529Z
Learning: When moving app templates in Altinn Studio, mirkoSekulic prefers to keep the PR scope strictly limited to the move operation itself, with all content changes (including code quality improvements, naming convention fixes, and attribute cleanup) deferred to separate PRs for better maintainability and atomic changes.
Learnt from: ErlingHauan
Repo: Altinn/altinn-studio PR: 15977
File: frontend/libs/studio-components-legacy/src/components/StudioCard/index.tsx:2-7
Timestamp: 2025-08-06T12:36:57.397Z
Learning: When a developer copies a component from `studio-components-legacy` to `studio-components` in the Altinn Studio repository and has not added a deprecation comment for the component in `studio-components-legacy`, suggest adding the deprecation comment in the PR review.
Learnt from: HauklandJ
Repo: Altinn/altinn-studio PR: 16948
File: src/Designer/backend/src/Designer/Services/Implementation/SourceControlSI.cs:549-560
Timestamp: 2025-11-25T14:01:29.170Z
Learning: In PR #16948 (Altinn/altinn-studio), OrgCodeListService is being removed in its entirety as part of the migration to the new OrgLibraryService and updated org library endpoints. Any issues flagged in OrgCodeListService should be considered in the context of this planned removal.
Learnt from: ErlingHauan
Repo: Altinn/altinn-studio PR: 15977
File: frontend/libs/studio-components-legacy/src/components/StudioCard/index.tsx:2-7
Timestamp: 2025-08-06T12:37:01.381Z
Learning: When reviewing PRs in the Altinn Studio repository where a developer copies a component from `studio-components-legacy` to `studio-components`, suggest adding a `deprecated` JSDoc comment to the component in `studio-components-legacy` if one hasn't been added. The deprecation comment should recommend using the component from `studio/components` instead.
Learnt from: TomasEng
Repo: Altinn/altinn-studio PR: 0
File: :0-0
Timestamp: 2025-09-10T12:02:06.348Z
Learning: In the Altinn Studio repository, the team convention is to remove irrelevant checkboxes from the PR template description rather than leaving them unmarked. This makes it clear that the author has intentionally considered each item and removed non-applicable ones, helping to avoid merging PRs with incomplete checklists.
Learnt from: mgunnerud
Repo: Altinn/altinn-studio PR: 16187
File: frontend/resourceadm/components/ResourcePageInputs/ResourceSwitchInput.tsx:3-3
Timestamp: 2025-08-25T13:55:27.042Z
Learning: In the Altinn Studio codebase, when migrating from studio/components-legacy to studio/components, PRs should focus only on components that have available replacements in the new package. Components without new implementations should remain in the legacy package until replacements are available, supporting an incremental migration approach.
Learnt from: TomasEng
Repo: Altinn/altinn-studio PR: 16064
File: frontend/libs/studio-components/src/components/StudioCheckboxGroup/StudioGetCheckboxProps.ts:1-1
Timestamp: 2025-08-12T05:59:20.146Z
Learning: In the Altinn Studio codebase, deep exports from digdir/designsystemet-react should be avoided. The team prefers using shared wrappers for design system imports to prevent breakage from upstream internal path changes, but such refactoring should be done in separate PRs to maintain focused scope.
Learnt from: TomasEng
Repo: Altinn/altinn-studio PR: 16064
File: frontend/libs/studio-components/src/components/StudioCheckboxGroup/StudioGetCheckboxProps.ts:1-1
Timestamp: 2025-08-12T06:09:55.275Z
Learning: In the Altinn Studio codebase, the preferred approach for eliminating dependencies on deep imports from digdir/designsystemet-react is to make the code completely independent of deep imports rather than using shared wrappers. This approach would eliminate the need for import path adjustments during future Design System package updates.
Learnt from: TomasEng
Repo: Altinn/altinn-studio PR: 16064
File: frontend/libs/studio-components/src/components/StudioCheckboxGroup/StudioGetCheckboxProps.ts:1-1
Timestamp: 2025-08-12T06:09:55.275Z
Learning: In the Altinn Studio codebase, the preferred approach for eliminating dependencies on deep imports from digdir/designsystemet-react is to make the code completely independent of deep imports rather than using shared wrappers. This approach would eliminate the need for import path adjustments during future Design System package updates.
📚 Learning: 2025-11-03T18:58:18.996Z
Learnt from: TomasEng
Repo: Altinn/altinn-studio PR: 16876
File: src/Designer/frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListsPage/CodeListsPage.tsx:17-23
Timestamp: 2025-11-03T18:58:18.996Z
Learning: In src/Designer/frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListsPage/CodeListsPage.tsx, the CodeListsPage component is intentionally an uncontrolled component where the codeLists prop only initializes state on mount and does not synchronize when the prop changes. This is because the createCodeListMap function generates random UUIDs for keys, making it impure. Re-calling it after the first render would reassign keys and significantly disrupt the UI (unmounting/remounting components). The component manages its own state for draft/editing purposes, and the prop is not expected to change to anything that doesn't correspond to the internal state.

Applied to files:

  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.tsx
  • src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx
  • src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.test.tsx
  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
📚 Learning: 2025-10-24T08:37:15.119Z
Learnt from: TomasEng
Repo: Altinn/altinn-studio PR: 0
File: :0-0
Timestamp: 2025-10-24T08:37:15.119Z
Learning: The `studio-content-library` package at `src/Designer/frontend/libs/studio-content-library` is a TypeScript library and does not require Python-style docstring coverage checks.

Applied to files:

  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.tsx
  • src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx
  • src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.test.tsx
  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
  • src/Designer/frontend/libs/studio-content-library/src/index.ts
  • src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/index.ts
📚 Learning: 2025-11-25T08:21:14.748Z
Learnt from: CR
Repo: Altinn/altinn-studio PR: 0
File: src/App/frontend/CLAUDE.md:0-0
Timestamp: 2025-11-25T08:21:14.748Z
Learning: Applies to src/App/frontend/**/*.{ts,tsx} : Leverage Digdir Design System components when possible instead of creating custom implementations

Applied to files:

  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.tsx
📚 Learning: 2025-10-06T17:51:23.307Z
Learnt from: JamalAlabdullah
Repo: Altinn/altinn-studio PR: 16518
File: src/Designer/frontend/libs/studio-components/src/components/StudioToggleableTextfieldSchema/StudioToggleableTextfieldSchema.stories.tsx:2-3
Timestamp: 2025-10-06T17:51:23.307Z
Learning: Altinn/altinn-studio: In Storybook stories (*.stories.tsx) under Designer/frontend libs, the project convention is to import types (Meta, StoryFn/StoryObj) from 'storybook/react-vite' rather than 'storybook/react'. Prefer 'storybook/react-vite' in future reviews for consistency.

Applied to files:

  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.tsx
  • src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx
  • src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.test.tsx
  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsx
  • src/Designer/frontend/libs/studio-content-library/src/index.ts
📚 Learning: 2025-01-17T12:16:17.666Z
Learnt from: TomasEng
Repo: Altinn/altinn-studio PR: 14429
File: frontend/app-development/features/appContentLibrary/utils/mapToCodeListDataList.ts:4-5
Timestamp: 2025-01-17T12:16:17.666Z
Learning: The `mapToCodeListDataList` function in frontend/app-development/features/appContentLibrary/utils/mapToCodeListDataList.ts expects `optionListDataList` to be set when called. Query failure cases that could result in undefined input are handled at a higher level.

Applied to files:

  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.tsx
  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
📚 Learning: 2025-12-18T12:57:40.385Z
Learnt from: TomasEng
Repo: Altinn/altinn-studio PR: 17285
File: src/Designer/frontend/libs/studio-content-library/src/pages/Page.tsx:25-29
Timestamp: 2025-12-18T12:57:40.385Z
Learning: In src/Designer/frontend/libs/studio-content-library/src/pages/Page.tsx, the extractProps method requires a type assertion `as PagePropsMap<Name>` on the return because TypeScript cannot narrow the indexed access `config.pages[this.name].props` to the specific generic type PagePropsMap<Name> even after Guard.againstMissingProperty. Removing this cast results in TS2322 error with a union type instead of the narrowed type. This is a known TypeScript limitation with generics and indexed access types.

Applied to files:

  • src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.tsx
📚 Learning: 2025-11-25T08:21:14.748Z
Learnt from: CR
Repo: Altinn/altinn-studio PR: 0
File: src/App/frontend/CLAUDE.md:0-0
Timestamp: 2025-11-25T08:21:14.748Z
Learning: Applies to src/App/frontend/**/*.{ts,tsx} : Use Zustand context wrapper from `src/core/contexts/zustandContext.tsx` when wrapping data in custom context providers to avoid rerenders

Applied to files:

  • src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.tsx
📚 Learning: 2025-11-25T08:21:14.748Z
Learnt from: CR
Repo: Altinn/altinn-studio PR: 0
File: src/App/frontend/CLAUDE.md:0-0
Timestamp: 2025-11-25T08:21:14.748Z
Learning: Applies to src/App/frontend/**/*.test.{ts,tsx} : Use `renderWithProviders` utility from `src/test/renderWithProviders.tsx` when testing components that require form layout context

Applied to files:

  • src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.tsx
  • src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.test.tsx
  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
📚 Learning: 2025-11-25T08:21:14.748Z
Learnt from: CR
Repo: Altinn/altinn-studio PR: 0
File: src/App/frontend/CLAUDE.md:0-0
Timestamp: 2025-11-25T08:21:14.748Z
Learning: Applies to src/App/frontend/src/layout/**/*.{ts,tsx} : Layout components must have standardized structure with `config.ts`, `Component.tsx`, `index.tsx`, and generated `config.generated.ts` files

Applied to files:

  • src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.tsx
📚 Learning: 2025-11-25T14:01:29.170Z
Learnt from: HauklandJ
Repo: Altinn/altinn-studio PR: 16948
File: src/Designer/backend/src/Designer/Services/Implementation/SourceControlSI.cs:549-560
Timestamp: 2025-11-25T14:01:29.170Z
Learning: In PR #16948 (Altinn/altinn-studio), OrgCodeListService is being removed in its entirety as part of the migration to the new OrgLibraryService and updated org library endpoints. Any issues flagged in OrgCodeListService should be considered in the context of this planned removal.

Applied to files:

  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx
📚 Learning: 2025-05-15T07:01:39.658Z
Learnt from: mgunnerud
Repo: Altinn/altinn-studio PR: 15448
File: frontend/resourceadm/utils/resourceUtils/resourceUtils.ts:632-650
Timestamp: 2025-05-15T07:01:39.658Z
Learning: The getResourceSubjects function in resourceUtils.ts already has corresponding tests in resourceUtils.test.tsx (lines 518-560) that verify its behavior for both consent and non-consent resources.

Applied to files:

  • src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.test.tsx
  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsx
📚 Learning: 2025-11-25T08:21:14.748Z
Learnt from: CR
Repo: Altinn/altinn-studio PR: 0
File: src/App/frontend/CLAUDE.md:0-0
Timestamp: 2025-11-25T08:21:14.748Z
Learning: Applies to src/App/frontend/src/__mocks__/** : Mock external dependencies in `src/__mocks__/` directory following the existing mock patterns

Applied to files:

  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
📚 Learning: 2025-11-03T19:01:47.721Z
Learnt from: cammiida
Repo: Altinn/altinn-studio PR: 16877
File: src/App/frontend/lighthouse-auth.mjs:62-64
Timestamp: 2025-11-03T19:01:47.721Z
Learning: In Altinn Studio's app-frontend testing setup, the component-library test app (located at src/test/apps/component-library/App) serves as the backend, while the frontend is served separately via webpack dev server (started with 'yarn run start' from src/App/frontend). These are two distinct layers that work together during Lighthouse CI testing.

Applied to files:

  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
📚 Learning: 2025-12-18T13:16:33.457Z
Learnt from: TomasEng
Repo: Altinn/altinn-studio PR: 0
File: :0-0
Timestamp: 2025-12-18T13:16:33.457Z
Learning: In the studio-content-library package with strict null checks enabled, Guard methods (like Guard.againstMissingProperty, Guard.againstUndefined, Guard.againstNull) are necessary in test files to make TypeScript type checking pass, even when the mock data structure is known at compile time, because the types don't provide sufficient information about their content for TypeScript to narrow them automatically.

Applied to files:

  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsx
📚 Learning: 2025-08-08T13:24:30.117Z
Learnt from: nkylstad
Repo: Altinn/altinn-studio PR: 0
File: :0-0
Timestamp: 2025-08-08T13:24:30.117Z
Learning: In Altinn/altinn-studio PR reviews, when unit tests need React Query/TanStack Query data, prefer seeding with QueryClient.setQueryData over rendering/mocking use…Query hooks and waiting for isSuccess. Flag patterns like renderHookWithMockStore(() => use…Query(...)) and waitFor(() => expect(result.current.isSuccess).toBe(true)) and recommend the simpler setQueryData approach. Cite the internal Confluence guideline on component tests and the best-practice example in useAddItemToLayoutMutation.test.ts (lines updated 08.08.2025).

Applied to files:

  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
📚 Learning: 2025-08-11T12:38:39.945Z
Learnt from: Konrad-Simso
Repo: Altinn/altinn-studio PR: 16063
File: backend/src/Designer/Services/Implementation/OptionsService.cs:200-204
Timestamp: 2025-08-11T12:38:39.945Z
Learning: In the Altinn Studio Designer codebase, when importing code lists from Gitea using IGiteaContentLibraryService, file existence validation is handled at the controller level rather than in the OptionsService. The controller checks if the file exists in Gitea before calling the service methods, preventing null reference issues.

Applied to files:

  • src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsx
📚 Learning: 2025-08-12T05:59:20.146Z
Learnt from: TomasEng
Repo: Altinn/altinn-studio PR: 16064
File: frontend/libs/studio-components/src/components/StudioCheckboxGroup/StudioGetCheckboxProps.ts:1-1
Timestamp: 2025-08-12T05:59:20.146Z
Learning: In the Altinn Studio codebase, deep exports from digdir/designsystemet-react should be avoided. The team prefers using shared wrappers for design system imports to prevent breakage from upstream internal path changes, but such refactoring should be done in separate PRs to maintain focused scope.

Applied to files:

  • src/Designer/frontend/libs/studio-content-library/src/index.ts
  • src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/index.ts
🧬 Code graph analysis (4)
src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.tsx (2)
src/Designer/frontend/libs/studio-content-library/src/ContentLibrary/ContentLibrary.tsx (1)
  • ContentLibrary (13-16)
src/Designer/frontend/packages/shared/src/api/mutations.ts (1)
  • deleteOptionList (116-116)
src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.tsx (3)
src/Designer/frontend/libs/studio-content-library/src/index.ts (2)
  • ContentLibraryConfig (2-2)
  • ContentLibraryWithProvider (1-1)
src/Designer/frontend/libs/studio-content-library/src/contexts/RouterContext.tsx (1)
  • RouterContextProvider (16-29)
src/Designer/frontend/libs/studio-content-library/src/ContentLibrary/ContentLibrary.tsx (1)
  • ContentLibrary (13-16)
src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx (1)
src/Designer/frontend/libs/studio-content-library/src/ContentLibrary/ContentLibrary.tsx (1)
  • ContentLibrary (13-16)
src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.test.tsx (3)
src/Designer/frontend/libs/studio-content-library/src/index.ts (2)
  • PagesConfig (11-11)
  • ContentLibraryWithProvider (1-1)
src/Designer/frontend/libs/studio-content-library/mocks/mockPagesConfig.ts (1)
  • mockPagesConfig (11-39)
src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.tsx (1)
  • ContentLibraryWithProvider (9-15)
🔇 Additional comments (15)
src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/index.ts (1)

1-1: LGTM!

Standard barrel export that correctly re-exports the ContentLibraryWithProvider component and its types.

src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx (2)

3-3: LGTM!

Import correctly updated to use the new ContentLibrary component from @studio/content-library.


169-187: Clean refactor from class instantiation to component usage.

The change from new ResourceContentLibraryImpl(props).getContentResourceLibrary() to <ContentLibrary {...props}/> is a straightforward improvement that aligns with idiomatic React patterns. The props structure is preserved correctly.

src/Designer/frontend/libs/studio-content-library/src/index.ts (1)

1-1: LGTM!

The export alias ContentLibraryWithProvider as ContentLibrary provides a clean public API. Consumers import ContentLibrary without needing to know about the provider wrapper implementation detail.

src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.tsx (2)

7-7: LGTM!

Import correctly updated to use the new ContentLibrary component.


132-162: Clean refactor to component-based usage.

The transition from class instantiation to JSX component is well executed. The props structure is preserved correctly.

src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.test.tsx (3)

3-4: LGTM!

Imports correctly updated to reference ContentLibraryWithProvider directly for testing.


10-11: Test suite correctly renamed.

The describe block and test descriptions now align with the ContentLibraryWithProvider component name.


51-53: LGTM!

The render helper correctly instantiates ContentLibraryWithProvider with the provided config.

src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsx (2)

25-33: LGTM!

The mock pattern is cleaner and more idiomatic for React component testing. MockContentLibrary as a jest function that renders a stub element is appropriate for verifying props are passed correctly without needing the full component tree.


245-247: LGTM!

Config retrieval correctly updated to access MockContentLibrary.mock.calls[0][0], matching the new mocking pattern.

src/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.tsx (1)

1-15: LGTM!

Clean wrapper component that encapsulates the RouterContextProvider requirement. The implementation follows single responsibility principle, making ContentLibrary easier to consume without requiring consumers to manage the router context themselves.

src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx (3)

52-60: LGTM!

Mock pattern consistent with AppContentLibrary.test.tsx. The approach of mocking ContentLibrary as a simple stub component is appropriate for testing the page component's integration logic.


65-65: LGTM!

beforeEach correctly clears mock state using MockContentLibrary.mockClear.


426-428: LGTM!

Config retrieval correctly updated to access MockContentLibrary.mock.calls[0][0].

@TomasEng TomasEng marked this pull request as ready for review December 31, 2025 10:54
@TomasEng TomasEng added the quality/code Violations from current rules for code, best practices, etc. Or just bad code. label Dec 31, 2025
@TomasEng TomasEng moved this to 🔎 In review in Team Altinn Studio Dec 31, 2025
@TomasEng TomasEng mentioned this pull request Dec 31, 2025
6 tasks
@TomasEng TomasEng added the skip-second-approval Pull requests that only need one approval from a reviewer. label Dec 31, 2025
@TomasEng TomasEng added the squad/data Issues that belongs to the named squad. label Dec 31, 2025
@Konrad-Simso Konrad-Simso merged commit 4b04334 into main Jan 9, 2026
10 checks passed
@Konrad-Simso Konrad-Simso deleted the remove-unnecessary-content-library-class branch January 9, 2026 13:57
@github-project-automation github-project-automation bot moved this from 🔎 In review to ✅ Done in Team Altinn Studio Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/dashboard Area: Related to the dashboard application frontend quality/code Violations from current rules for code, best practices, etc. Or just bad code. skip-releasenotes Issues that do not make sense to list in our release notes skip-second-approval Pull requests that only need one approval from a reviewer. solution/studio/designer squad/data Issues that belongs to the named squad.

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Content library refactorings

2 participants