-
Notifications
You must be signed in to change notification settings - Fork 87
refactor: Remove unnecessary content library class #17343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughRefactors the content library from a class-based Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used🧠 Learnings (11)📓 Common learnings📚 Learning: 2025-11-03T18:58:18.996ZApplied to files:
📚 Learning: 2025-10-24T08:37:15.119ZApplied to files:
📚 Learning: 2025-11-25T14:01:29.170ZApplied to files:
📚 Learning: 2025-10-06T17:51:23.307ZApplied to files:
📚 Learning: 2025-08-08T13:24:30.117ZApplied to files:
📚 Learning: 2025-11-25T08:21:14.748ZApplied to files:
📚 Learning: 2025-01-30T12:02:25.392ZApplied to files:
📚 Learning: 2025-01-17T12:16:17.666ZApplied to files:
📚 Learning: 2025-11-03T19:01:47.721ZApplied to files:
📚 Learning: 2025-11-25T08:21:14.748ZApplied to files:
🧬 Code graph analysis (1)src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx (1)
🔇 Additional comments (5)
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 |
91eb4fa to
b9c540f
Compare
b9c540f to
d641ed7
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
d641ed7 to
96d7443
Compare
96d7443 to
cf93f87
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this 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
imagespage 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
📒 Files selected for processing (9)
src/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsxsrc/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.tsxsrc/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsxsrc/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsxsrc/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.test.tsxsrc/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.tsxsrc/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/index.tssrc/Designer/frontend/libs/studio-content-library/src/config/ContentResourceLibraryImpl.tsxsrc/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.tsxsrc/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.tsxsrc/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsxsrc/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.test.tsxsrc/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsxsrc/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.tsxsrc/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.tsxsrc/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsxsrc/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.test.tsxsrc/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsxsrc/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsxsrc/Designer/frontend/libs/studio-content-library/src/index.tssrc/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.tsxsrc/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.tsxsrc/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsxsrc/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.test.tsxsrc/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsxsrc/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.tsxsrc/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsxsrc/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.tsxsrc/Designer/frontend/libs/studio-content-library/src/ContentLibraryWithProvider/ContentLibraryWithProvider.test.tsxsrc/Designer/frontend/app-development/features/appContentLibrary/AppContentLibrary.test.tsxsrc/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.tsxsrc/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.tsxsrc/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.tsxsrc/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.tsxsrc/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.tssrc/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
ContentLibraryWithProvidercomponent and its types.src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx (2)
3-3: LGTM!Import correctly updated to use the new
ContentLibrarycomponent 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 ContentLibraryprovides a clean public API. Consumers importContentLibrarywithout 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
ContentLibrarycomponent.
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
ContentLibraryWithProviderdirectly for testing.
10-11: Test suite correctly renamed.The
describeblock and test descriptions now align with theContentLibraryWithProvidercomponent name.
51-53: LGTM!The render helper correctly instantiates
ContentLibraryWithProviderwith 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.
MockContentLibraryas 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
RouterContextProviderrequirement. The implementation follows single responsibility principle, makingContentLibraryeasier 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 mockingContentLibraryas a simple stub component is appropriate for testing the page component's integration logic.
65-65: LGTM!
beforeEachcorrectly clears mock state usingMockContentLibrary.mockClear.
426-428: LGTM!Config retrieval correctly updated to access
MockContentLibrary.mock.calls[0][0].
Description
This pull request simplifies the usage of the content library component.
Current code:
New code:
The
ResourceContentLibraryImpldoes not provide anything useful to the code. TheImplsuffix 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
Summary by CodeRabbit
New Features
Refactor
Tests
✏️ Tip: You can customize this high-level summary in your review settings.