-
Notifications
You must be signed in to change notification settings - Fork 86
feat: Add publish button in code list library #17060
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughAdds a publish workflow for code lists: new UI publish button and prop, transformer to backend payload, React Query mutation hook and API path, types and mocks, and tests wiring publish from editor through pages to the publish API. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant User
participant Editor as CodeListDataEditor
participant Page as CodeListsPage
participant OrgPage as OrgContentLibraryPage
participant Hook as usePublishCodeListMutation
participant API
User->>Editor: Click "Publish"
Editor->>Editor: handlePublish(data)
Editor->>Page: onPublish(data)
Page->>OrgPage: onPublish(data)
OrgPage->>OrgPage: transform to PublishCodeListPayload
OrgPage->>Hook: mutateAsync(payload)
Hook->>API: POST /orgs/{org}/code-lists/new/publish (payload)
API-->>Hook: 200 OK
Hook-->>OrgPage: resolved
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ 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. Comment |
34fd0df to
f7d7ebd
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #17060 +/- ##
==========================================
+ Coverage 96.19% 96.29% +0.09%
==========================================
Files 2447 2378 -69
Lines 30790 30140 -650
Branches 3544 3482 -62
==========================================
- Hits 29618 29022 -596
+ Misses 864 811 -53
+ Partials 308 307 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@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: 1
🧹 Nitpick comments (5)
src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.test.tsx (1)
12-18: Also resetonPublishbetween testsYou already clear
onSaveinbeforeEach; it would be slightly safer to also clearonPublishso future tests that assert on publish behaviour don’t see cross‑test leakage:-beforeEach(onSave.mockClear); +beforeEach(() => { + onSave.mockClear(); + onPublish.mockClear(); +});src/Designer/frontend/packages/shared/src/api/mutations.ts (1)
63-64: NewpublishCodeListmutation aligns with existing API style
publishCodeListfollows the same pattern as other org‑scoped mutations, usingorgCodeListPublishPathand thePublishCodeListPayloadtype, so the wiring from hook → services context → HTTP call is coherent. If you want slightly stronger typing, you could mirror some other calls and writepost<void, PublishCodeListPayload>(...), but the current form is consistent with most of this file.Also applies to: 98-99, 133-133
src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.tsx (1)
17-22: Publish action wiring in editor looks correct
onPublishis threaded intoCodeListDataEditor, andhandlePublishcorrectly captures the currentdataviauseCallback, with the button hooked up using the shared translations and CSS. The implementation is straightforward and keeps responsibility for what “publish” means at the caller level.If you later find that publishing invalid or incomplete lists is noisy (e.g. frequent backend errors), you could consider disabling the publish button based on the same validation rules used for saving.
Also applies to: 24-29, 50-50, 67-69
src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx (2)
28-34: MakePublishCodeListPayloadthe single source of truth for the publish payload shapeYou now use
libraryCodeListDataToBackendCodeListDatato build aPublishCodeListPayload, and both are defined asRequired<Pick<CodeListDataNew, 'title' | 'codeList'>>in different places. To keep things DRY and avoid the two drifting, consider changing the utility to returnPublishCodeListPayloaddirectly and, if applicable, align its input type with whatCodeListsPageactually passes in.For example in
utils.ts:import type { PublishCodeListPayload } from 'app-shared/types/api/PublishCodeListPayload'; export function libraryCodeListDataToBackendCodeListData( { name, codes }: LibraryCodeListData, ): PublishCodeListPayload { return { title: name, codeList: { codes }, }; }This makes the relationship between the transform and the API contract explicit and keeps future changes to the payload shape centralised.
Also applies to: 53-55
207-236: Publish hook wiring looks correct; consider surfacing status and feedbackThe new publish flow in
useCodeListsPropsis nicely scoped:
usePublishCodeListMutation(orgName)is used inside the hook, keeping the org context local.handlePublishis memoised and passed asonPublish, which matches howonSaveis handled and keeps the props stable.Two follow-up improvements you might want to consider:
- User feedback / error handling: At the moment,
publish(payload)runs silently. If publish can fail (as it does locally when the external service is missing), callers get no feedback. MirroringuseUploadCodeList, you could either handleonSuccess/onErrorhere (with toasts, logging, etc.) or thread callbacks/status up throughonPublish.- Query invalidation (if needed): If publishing changes anything visible in
useOrgCodeListsNewQuery’s data (e.g. a “published” flag), it may be worth invalidating/refetching that query on success so the UI reflects the new state.These are not blockers, but they would make the publish action more transparent and robust for users.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (17)
src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx(1 hunks)src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx(4 hunks)src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.test.ts(3 hunks)src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.ts(1 hunks)src/Designer/frontend/language/src/nb.json(1 hunks)src/Designer/frontend/libs/studio-content-library/mocks/mockPagesConfig.ts(1 hunks)src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.module.css(2 hunks)src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.test.tsx(2 hunks)src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.tsx(4 hunks)src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.test.tsx(1 hunks)src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.tsx(4 hunks)src/Designer/frontend/packages/shared/src/api/mutations.ts(3 hunks)src/Designer/frontend/packages/shared/src/api/paths.js(1 hunks)src/Designer/frontend/packages/shared/src/hooks/mutations/usePublishCodeListMutation.test.ts(1 hunks)src/Designer/frontend/packages/shared/src/hooks/mutations/usePublishCodeListMutation.ts(1 hunks)src/Designer/frontend/packages/shared/src/mocks/queriesMock.ts(1 hunks)src/Designer/frontend/packages/shared/src/types/api/PublishCodeListPayload.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (22)
📓 Common learnings
Learnt from: HauklandJ
Repo: Altinn/altinn-studio PR: 16716
File: src/Designer/backend/src/Designer/Controllers/Organisation/OrgCodeListController.cs:126-126
Timestamp: 2025-10-30T09:38:46.365Z
Learning: In Altinn Studio Designer, the PublishCodeList endpoint in OrgCodeListController uses MustBelongToOrganization authorization policy (not MustHaveGiteaPublishResourcePermission) because it publishes code lists to Azure Blob Storage (shared storage account), not to Gitea. Any Gitea user with Designer access and organization membership should be able to publish code lists for their org. The stricter MustHaveGiteaPublishResourcePermission policy is reserved for Gitea-specific publishing operations that require environment-scoped team membership.
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: 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: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: 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.
📚 Learning: 2025-10-21T13:30:27.128Z
Learnt from: Konrad-Simso
Repo: Altinn/altinn-studio PR: 16477
File: src/Designer/backend/src/Designer/Infrastructure/GitRepository/AltinnOrgGitRepository.cs:207-228
Timestamp: 2025-10-21T13:30:27.128Z
Learning: In the AltinnOrgGitRepository class (src/Designer/backend/src/Designer/Infrastructure/GitRepository/AltinnOrgGitRepository.cs), the UpdateCodeListNew method intentionally writes to the CodeLists/ folder (via CodeListFilePath), while older methods use CodeListsWithTextResources/. This separation is correct because GET operations now use Gitea API directly (bypassing local file reads), while POST operations use git operations via LibGit2Sharp writing to CodeLists/.
Applied to files:
src/Designer/frontend/packages/shared/src/api/paths.jssrc/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.tssrc/Designer/frontend/packages/shared/src/api/mutations.tssrc/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx
📚 Learning: 2025-10-30T09:38:46.365Z
Learnt from: HauklandJ
Repo: Altinn/altinn-studio PR: 16716
File: src/Designer/backend/src/Designer/Controllers/Organisation/OrgCodeListController.cs:126-126
Timestamp: 2025-10-30T09:38:46.365Z
Learning: In Altinn Studio Designer, the PublishCodeList endpoint in OrgCodeListController uses MustBelongToOrganization authorization policy (not MustHaveGiteaPublishResourcePermission) because it publishes code lists to Azure Blob Storage (shared storage account), not to Gitea. Any Gitea user with Designer access and organization membership should be able to publish code lists for their org. The stricter MustHaveGiteaPublishResourcePermission policy is reserved for Gitea-specific publishing operations that require environment-scoped team membership.
Applied to files:
src/Designer/frontend/packages/shared/src/api/paths.jssrc/Designer/frontend/packages/shared/src/api/mutations.ts
📚 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/libs/studio-content-library/mocks/mockPagesConfig.tssrc/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsxsrc/Designer/frontend/packages/shared/src/hooks/mutations/usePublishCodeListMutation.tssrc/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.test.tssrc/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.tssrc/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.test.tsxsrc/Designer/frontend/packages/shared/src/mocks/queriesMock.tssrc/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.tsxsrc/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.test.tsxsrc/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsxsrc/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.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.tsxsrc/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.test.tssrc/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.tssrc/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.test.tsxsrc/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.tsxsrc/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx
📚 Learning: 2025-06-02T08:50:48.884Z
Learnt from: Jondyr
Repo: Altinn/altinn-studio PR: 15537
File: frontend/language/src/nb.json:1932-1932
Timestamp: 2025-06-02T08:50:48.884Z
Learning: In frontend/language/src/nb.json, the localization keys use hierarchical dot notation with multiple segments after the namespace (e.g., ux_editor.add_item.add_component, ux_editor.component_category.advanced). Keys with 2-3 segments after ux_editor are both common and accepted patterns.
Applied to files:
src/Designer/frontend/language/src/nb.json
📚 Learning: 2025-01-20T10:00:55.997Z
Learnt from: standeren
Repo: Altinn/altinn-studio PR: 14449
File: frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/EditTaskId/EditTaskId.tsx:47-55
Timestamp: 2025-01-20T10:00:55.997Z
Learning: The project only supports Norwegian translations in the solution. English translation files are not maintained.
Applied to files:
src/Designer/frontend/language/src/nb.json
📚 Learning: 2025-06-03T10:54:59.508Z
Learnt from: wrt95
Repo: Altinn/altinn-studio PR: 15542
File: frontend/app-development/features/appSettings/components/TabsContent/Tabs/AboutTab/utils/appResourceValidationUtils.ts:64-95
Timestamp: 2025-06-03T10:54:59.508Z
Learning: In the app settings validation logic for appResourceValidationUtils.ts, the Norwegian Bokmål ('nb') language uses a comprehensive error message via getMissingInputLanguageString that can describe multiple missing languages, while Norwegian Nynorsk ('nn') and English ('en') use simpler, direct translation keys for missing translations. This pattern should be preserved when refactoring validation logic.
Applied to files:
src/Designer/frontend/language/src/nb.json
📚 Learning: 2025-01-30T08:18:42.814Z
Learnt from: Jondyr
Repo: Altinn/altinn-studio PR: 14517
File: frontend/language/src/nb.json:1385-1385
Timestamp: 2025-01-30T08:18:42.814Z
Learning: English translations (en.json) are not currently used in the Altinn Studio project. Comments about missing English translations should be ignored.
Applied to files:
src/Designer/frontend/language/src/nb.json
📚 Learning: 2025-08-11T12:46:41.401Z
Learnt from: Konrad-Simso
Repo: Altinn/altinn-studio PR: 16063
File: backend/tests/Designer.Tests/Controllers/OptionsController/ImportOptionsListFromOrgTests.cs:238-269
Timestamp: 2025-08-11T12:46:41.401Z
Learning: In the Altinn Studio Designer codebase, text resource files only support ISO 639 standard parts 1 and 3 language codes (2-3 letter codes like "nb", "en", "nno"). Extended language variants with region codes (like "nb_NO" or "en-GB") are not supported.
Applied to files:
src/Designer/frontend/language/src/nb.json
📚 Learning: 2025-01-16T11:22:57.791Z
Learnt from: ErlingHauan
Repo: Altinn/altinn-studio PR: 14434
File: frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/hooks/useUploadCodeListNameErrorMessage.ts:9-9
Timestamp: 2025-01-16T11:22:57.791Z
Learning: In the Altinn Studio codebase, the error message key 'validation_errors.file_name_invalid' should be used when validating actual filenames (e.g., in file upload scenarios like UseUploadCodeListNameErrorMessage), while 'validation_errors.name_invalid' is used for non-file name validations.
Applied to files:
src/Designer/frontend/language/src/nb.json
📚 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/dashboard/pages/OrgContentLibraryPage/utils.test.ts
📚 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/utils.tssrc/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.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/pages/CodeLists/CodeListsPage/CodeListsPage.test.tsxsrc/Designer/frontend/packages/shared/src/hooks/mutations/usePublishCodeListMutation.test.ts
📚 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/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.test.tsxsrc/Designer/frontend/packages/shared/src/mocks/queriesMock.tssrc/Designer/frontend/packages/shared/src/hooks/mutations/usePublishCodeListMutation.test.tssrc/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.test.tsx
📚 Learning: 2025-10-26T21:09:38.402Z
Learnt from: JamalAlabdullah
Repo: Altinn/altinn-studio PR: 16742
File: src/Designer/frontend/packages/schema-editor/src/components/SchemaInspector/ItemDataComponent.module.css:23-25
Timestamp: 2025-10-26T21:09:38.402Z
Learning: In the Altinn Studio codebase, the design system is migrating from `--fds-*` prefixed CSS variables to `--ds-*` prefixed variables. The `--fds-*` prefix will be removed in the future, so usage of `--ds-*` variables (like `--ds-size-4`) alongside existing `--fds-*` variables (like `--fds-spacing-4`) in the same file is intentional during this transition period.
<!--
Applied to files:
src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.module.css
📚 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/packages/shared/src/mocks/queriesMock.ts
📚 Learning: 2025-02-10T11:28:12.444Z
Learnt from: ErlingHauan
Repo: Altinn/altinn-studio PR: 14398
File: frontend/libs/studio-components/src/components/StudioCodelistEditor/StudioCodeListEditorRow/StudioCodeListEditorRow.tsx:128-136
Timestamp: 2025-02-10T11:28:12.444Z
Learning: The StudioCodeListEditor component's handling of undefined values (when StudioDecimalField is cleared) is verified through the test case that checks if a numberfield is rendered with inputMode='decimal'.
Applied to files:
src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.test.tsx
📚 Learning: 2025-08-12T13:45:39.680Z
Learnt from: ErlingHauan
Repo: Altinn/altinn-studio PR: 16081
File: frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditTab/OptionListSelector/OptionListSelector.tsx:108-115
Timestamp: 2025-08-12T13:45:39.680Z
Learning: The StudioButton component from studio/components-legacy defaults to type="button", so explicit type attributes are not needed to prevent form submission behavior.
Applied to files:
src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.tsx
📚 Learning: 2025-09-26T12:03:56.908Z
Learnt from: TomasEng
Repo: Altinn/altinn-studio PR: 0
File: :0-0
Timestamp: 2025-09-26T12:03:56.908Z
Learning: In the Altinn Studio codebase, when reviewing migration from studio/components-legacy to studio/components for the StudioExpression component, the ExpressionTexts type interface does not require additional keys like `dataModel`, `resource`, or `missingDataModelLabel`. TypeScript compilation will catch any missing required properties, so successful builds indicate proper type compliance.
Applied to files:
src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.tsx
📚 Learning: 2025-07-03T14:54:51.389Z
Learnt from: mgunnerud
Repo: Altinn/altinn-studio PR: 15826
File: frontend/resourceadm/components/ResourcePageInputs/ResourceLanguageTextField.tsx:95-95
Timestamp: 2025-07-03T14:54:51.389Z
Learning: The StudioTextfield component at frontend/libs/studio-components/src/components/StudioTextfield/StudioTextfield.tsx accepts only HTMLInputElement as ref type, even when the component renders an HTMLTextAreaElement (when multiline is true). This is a typing constraint of the component library.
Applied to files:
src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.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/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.tsx
🧬 Code graph analysis (11)
src/Designer/frontend/packages/shared/src/types/api/PublishCodeListPayload.ts (1)
src/Designer/frontend/packages/shared/src/types/CodeListDataNew.ts (1)
CodeListDataNew(3-11)
src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx (3)
src/Designer/frontend/packages/shared/src/api/mutations.ts (1)
publishCodeList(133-133)src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/test-data/codeListsNewResponse.ts (1)
codeListsNewResponse(23-26)src/Designer/development/setup.js (1)
waitFor(2-2)
src/Designer/frontend/packages/shared/src/hooks/mutations/usePublishCodeListMutation.ts (3)
src/Designer/frontend/packages/shared/src/types/api/PublishCodeListPayload.ts (1)
PublishCodeListPayload(3-3)src/Designer/frontend/packages/shared/src/contexts/ServicesContext.tsx (1)
useServicesContext(134-140)src/Designer/frontend/packages/shared/src/api/mutations.ts (1)
publishCodeList(133-133)
src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.test.ts (4)
src/Designer/frontend/libs/studio-content-library/src/index.ts (1)
CodeListData(14-14)src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/test-data/codeLists.ts (1)
codeLists(33-33)src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.ts (1)
libraryCodeListDataToBackendCodeListData(62-70)src/Designer/frontend/packages/shared/src/types/CodeListDataNew.ts (1)
CodeListDataNew(3-11)
src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.ts (1)
src/Designer/frontend/packages/shared/src/types/CodeListDataNew.ts (1)
CodeListDataNew(3-11)
src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.test.tsx (1)
src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.tsx (1)
CodeListsPageProps(20-24)
src/Designer/frontend/packages/shared/src/hooks/mutations/usePublishCodeListMutation.test.ts (3)
src/Designer/frontend/packages/shared/src/api/mutations.ts (1)
publishCodeList(133-133)src/Designer/frontend/packages/shared/src/hooks/mutations/usePublishCodeListMutation.ts (1)
usePublishCodeListMutation(6-13)src/Designer/frontend/packages/shared/src/types/api/PublishCodeListPayload.ts (1)
PublishCodeListPayload(3-3)
src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.tsx (1)
src/Designer/frontend/libs/studio-content-library/src/index.ts (1)
CodeListData(14-14)
src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.test.tsx (1)
src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.tsx (1)
CodeListDataEditorProps(17-22)
src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx (3)
src/Designer/frontend/packages/shared/src/hooks/mutations/usePublishCodeListMutation.ts (1)
usePublishCodeListMutation(6-13)src/Designer/frontend/packages/shared/src/types/api/PublishCodeListPayload.ts (1)
PublishCodeListPayload(3-3)src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.ts (1)
libraryCodeListDataToBackendCodeListData(62-70)
src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.tsx (2)
src/Designer/frontend/libs/studio-content-library/src/index.ts (1)
CodeListData(14-14)src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/index.ts (1)
CodeListDataEditor(1-1)
🔇 Additional comments (12)
src/Designer/frontend/packages/shared/src/api/paths.js (1)
95-101: New org code list publish path fits existing API conventionsThe new
orgCodeListPublishPathmirrors the other org-level code list paths and keeps the org as the only route parameter, with details in the POST body. Looks good.src/Designer/frontend/libs/studio-content-library/mocks/mockPagesConfig.ts (1)
24-29: Mock updated to expose onPublish correctlyAdding
onPublish: () => {}to thecodeListsmock keeps the mock API in sync with the real component props and avoids undefined handlers in tests.src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx (1)
339-359: Publish flow test covers the critical wiringThe new test exercises the
onPublishcallback end‑to‑end for the new code list page and asserts thatpublishCodeListis called once with the org and a payload containing the expected title. This is an appropriate, focused check for the wiring.src/Designer/frontend/language/src/nb.json (1)
26-33: New publish translation key is consistent
app_content_library.code_lists.publishfollows the existing key structure and uses appropriate Norwegian wording. Matches how it’s used in tests and UI.src/Designer/frontend/packages/shared/src/hooks/mutations/usePublishCodeListMutation.test.ts (1)
1-29: Hook test correctly validates publish mutation integrationThe test cleanly verifies that
usePublishCodeListMutationdelegates topublishCodeListwith the provided org andPublishCodeListPayload. UsingrenderHookWithProvidersand a simple jest mock keeps it aligned with existing mutation tests.src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.test.tsx (1)
14-15: CodeListDataEditor publish behaviour is well coveredWiring
onPublishintodefaultPropsand asserting it’s called once with the currentdatawhen the publish button (labelled viaapp_content_library.code_lists.publish) is clicked gives good coverage of the new action.Also applies to: 73-80
src/Designer/frontend/packages/shared/src/mocks/queriesMock.ts (1)
232-266: ServicesContext mock extended with publishCodeListAdding
publishCodeListtoqueriesMockkeeps the ServicesContext contract complete for tests that exercise the new publish mutation and matches the style of existing mutation mocks.src/Designer/frontend/packages/shared/src/types/api/PublishCodeListPayload.ts (1)
1-3: PublishCodeListPayload type is concise and future‑proofDeriving
PublishCodeListPayloadasRequired<Pick<CodeListDataNew, 'codeList' | 'title'>>reuses the existing domain model and guarantees the publish endpoint always receives the required fields without leaking editor‑only flags likehasError.src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.test.ts (1)
1-7: Converter test matches implementation and payload shapeThe new test correctly verifies that
nameandcodesfromCodeListDatabecometitleandcodeList.codeson the backend type, aligned withlibraryCodeListDataToBackendCodeListDataandCodeListDataNew. Looks good and gives nice regression coverage.Also applies to: 20-20, 144-157
src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.module.css (1)
1-8: Grid extension for publish button looks coherentThe added
publish-buttonarea and thirdautocolumn integrate cleanly with the existing grid, and the.publishButtonrule mirrors the delete button alignment. No layout issues spotted.Also applies to: 20-23
src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.ts (1)
58-70: Good extraction of shared mapping logicRefactoring
mapUpdatedListsto uselibraryCodeListDataToBackendCodeListDataremoves duplication and guarantees the update and publish flows share the same{ title, codeList: { codes } }shape. The narrowing viaCodeListDataNewstill lines up withDeletableCodeListData, so behaviour is unchanged.src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.tsx (1)
20-24:onPublishis cleanly threaded through the page hierarchyExtending
CodeListsPagePropswithonPublishand passing it unchanged viaListOfCodeListsdown to eachCodeListDataEditorkeeps the component tree simple and respects the existing uncontrolledcodeListMapmodel. Each publish action gets the currentCodeListDatafor the chosen entry, which is exactly what the backend mapping utilities expect.Also applies to: 26-27, 74-79, 88-93, 95-116
src/Designer/frontend/packages/shared/src/hooks/mutations/usePublishCodeListMutation.ts
Show resolved
Hide resolved
Konrad-Simso
left a comment
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.
✅
Description
This pull request adds a mutation hook that calls the code list publishing endpoint and a button that triggers it from the Studio library.
I have testet this both locally and in the
devenvironment. Locally, the endpoint responds with an error because it depends on an external service that is not available locally, but indevit works as expected.Verification
Summary by CodeRabbit
Release Notes
New Features
Localisation
Tip: You can customize this high-level summary in your review settings.