Skip to content

Conversation

@TomasEng
Copy link
Contributor

@TomasEng TomasEng commented Nov 26, 2025

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.

image

I have testet this both locally and in the dev environment. Locally, the endpoint responds with an error because it depends on an external service that is not available locally, but in dev it works as expected.

Verification

  • Related issues are connected (if applicable)
  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Summary by CodeRabbit

Release Notes

  • New Features

    • Code lists now include a publish capability. Users can publish code lists from the content library editor using the new publish button, providing a dedicated publishing workflow.
  • Localisation

    • Added Norwegian translation for code list publish labels.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 26, 2025

Walkthrough

Adds 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

Cohort / File(s) Summary
API Layer & Paths
src/Designer/frontend/packages/shared/src/api/mutations.ts, src/Designer/frontend/packages/shared/src/api/paths.js
New publishCodeList(org, payload) mutation and orgCodeListPublishPath for POST /code-lists/new/publish.
React Query Hook & Test
src/Designer/frontend/packages/shared/src/hooks/mutations/usePublishCodeListMutation.ts, src/Designer/frontend/packages/shared/src/hooks/mutations/usePublishCodeListMutation.test.ts
New usePublishCodeListMutation(orgName) hook that calls publishCodeList; unit test asserts correct call with org and payload.
Type Definitions
src/Designer/frontend/packages/shared/src/types/api/PublishCodeListPayload.ts
New PublishCodeListPayload type: Required<Pick<CodeListDataNew, 'codeList' | 'title'>>.
Transformer Utility & Tests
src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.ts, src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.test.ts
New libraryCodeListDataToBackendCodeListData exported; used in mapping updated lists and covered by unit test.
Page Integration & Tests
src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx, src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
useCodeListsProps now exposes onPublish which transforms CodeListData to PublishCodeListPayload and invokes usePublishCodeListMutation; test ensures publish mutation called with org and payload.
Studio Content Library Components & Tests
src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.tsx, .../CodeListsPage.test.tsx, .../CodeListDataEditor/CodeListDataEditor.tsx, .../CodeListDataEditor/CodeListDataEditor.test.tsx
Propagated new onPublish prop through CodeListsPageListOfCodeListsCodeListDataEditor; CodeListDataEditor adds publish button, onPublish handler and tests for click/disabled state.
Editor Styling
src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.module.css
Grid layout updated to include publish-button column and new .publishButton rule.
Mocks & Config
src/Designer/frontend/libs/studio-content-library/mocks/mockPagesConfig.ts, src/Designer/frontend/packages/shared/src/mocks/queriesMock.ts
Added onPublish to mock page config and publishCodeList jest mock in services mock.
Translations
src/Designer/frontend/language/src/nb.json
Added Norwegian translation key app_content_library.code_lists.publish: "Publiser".

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Attention areas:
    • Payload transformer libraryCodeListDataToBackendCodeListData — ensure field mapping aligns with backend CodeListDataNew.
    • usePublishCodeListMutation wiring and services mock consistency.
    • Propagation of onPublish through component typings and tests.
    • CSS grid changes for the publish button layout.

Possibly related PRs

Suggested reviewers

  • Konrad-Simso

Poem

🐰 A little hop, a button bright,
Clicks send lists into the night.
From editor to API they race,
Titles and codes find their place.
Hooray — publish hops into sight!

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main feature: adding a publish button to the code list library. It aligns with the primary changes across the codebase.
Description check ✅ Passed The pull request description is mostly complete but lacks detail in the 'Description' section about specific changes, and manual testing is mentioned generically without specific details about what was tested.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-publish-code-list-button

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.

@TomasEng TomasEng linked an issue Nov 26, 2025 that may be closed by this pull request
7 tasks
@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 Nov 26, 2025
@TomasEng TomasEng force-pushed the add-publish-code-list-button branch from 34fd0df to f7d7ebd Compare November 26, 2025 14:49
@TomasEng TomasEng moved this to 👷 In progress in Team Altinn Studio Nov 26, 2025
@TomasEng TomasEng added area/content-library Area: Related to library for shared resources squad/data Issues that belongs to the named squad. labels Nov 26, 2025
@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.29%. Comparing base (f63ea9c) to head (242c039).
⚠️ Report is 395 commits behind head on main.

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.
📢 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
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 27, 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: 1

🧹 Nitpick comments (5)
src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.test.tsx (1)

12-18: Also reset onPublish between tests

You already clear onSave in beforeEach; it would be slightly safer to also clear onPublish so 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: New publishCodeList mutation aligns with existing API style

publishCodeList follows the same pattern as other org‑scoped mutations, using orgCodeListPublishPath and the PublishCodeListPayload type, so the wiring from hook → services context → HTTP call is coherent. If you want slightly stronger typing, you could mirror some other calls and write post<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

onPublish is threaded into CodeListDataEditor, and handlePublish correctly captures the current data via useCallback, 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: Make PublishCodeListPayload the single source of truth for the publish payload shape

You now use libraryCodeListDataToBackendCodeListData to build a PublishCodeListPayload, and both are defined as Required<Pick<CodeListDataNew, 'title' | 'codeList'>> in different places. To keep things DRY and avoid the two drifting, consider changing the utility to return PublishCodeListPayload directly and, if applicable, align its input type with what CodeListsPage actually 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 feedback

The new publish flow in useCodeListsProps is nicely scoped:

  • usePublishCodeListMutation(orgName) is used inside the hook, keeping the org context local.
  • handlePublish is memoised and passed as onPublish, which matches how onSave is 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. Mirroring useUploadCodeList, you could either handle onSuccess/onError here (with toasts, logging, etc.) or thread callbacks/status up through onPublish.
  • 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

📥 Commits

Reviewing files that changed from the base of the PR and between de9bf05 and f7d7ebd.

📒 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.js
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.ts
  • src/Designer/frontend/packages/shared/src/api/mutations.ts
  • src/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.js
  • src/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.ts
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.test.tsx
  • src/Designer/frontend/packages/shared/src/hooks/mutations/usePublishCodeListMutation.ts
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.test.ts
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.ts
  • src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.test.tsx
  • src/Designer/frontend/packages/shared/src/mocks/queriesMock.ts
  • src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.tsx
  • src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListDataEditor/CodeListDataEditor.test.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/OrgContentLibraryPage.tsx
  • src/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.tsx
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.test.ts
  • src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.ts
  • src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.test.tsx
  • src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.tsx
  • src/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.ts
  • src/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.tsx
  • src/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.tsx
  • src/Designer/frontend/packages/shared/src/mocks/queriesMock.ts
  • src/Designer/frontend/packages/shared/src/hooks/mutations/usePublishCodeListMutation.test.ts
  • src/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 conventions

The new orgCodeListPublishPath mirrors 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 correctly

Adding onPublish: () => {} to the codeLists mock 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 wiring

The new test exercises the onPublish callback end‑to‑end for the new code list page and asserts that publishCodeList is 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.publish follows 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 integration

The test cleanly verifies that usePublishCodeListMutation delegates to publishCodeList with the provided org and PublishCodeListPayload. Using renderHookWithProviders and 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 covered

Wiring onPublish into defaultProps and asserting it’s called once with the current data when the publish button (labelled via app_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 publishCodeList

Adding publishCodeList to queriesMock keeps 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‑proof

Deriving PublishCodeListPayload as Required<Pick<CodeListDataNew, 'codeList' | 'title'>> reuses the existing domain model and guarantees the publish endpoint always receives the required fields without leaking editor‑only flags like hasError.

src/Designer/frontend/dashboard/pages/OrgContentLibraryPage/utils.test.ts (1)

1-7: Converter test matches implementation and payload shape

The new test correctly verifies that name and codes from CodeListData become title and codeList.codes on the backend type, aligned with libraryCodeListDataToBackendCodeListData and CodeListDataNew. 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 coherent

The added publish-button area and third auto column integrate cleanly with the existing grid, and the .publishButton rule 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 logic

Refactoring mapUpdatedLists to use libraryCodeListDataToBackendCodeListData removes duplication and guarantees the update and publish flows share the same { title, codeList: { codes } } shape. The narrowing via CodeListDataNew still lines up with DeletableCodeListData, so behaviour is unchanged.

src/Designer/frontend/libs/studio-content-library/src/pages/CodeLists/CodeListsPage/CodeListsPage.tsx (1)

20-24: onPublish is cleanly threaded through the page hierarchy

Extending CodeListsPageProps with onPublish and passing it unchanged via ListOfCodeLists down to each CodeListDataEditor keeps the component tree simple and respects the existing uncontrolled codeListMap model. Each publish action gets the current CodeListData for the chosen entry, which is exactly what the backend mapping utilities expect.

Also applies to: 26-27, 74-79, 88-93, 95-116

@TomasEng TomasEng marked this pull request as ready for review November 27, 2025 08:13
@TomasEng TomasEng moved this from 👷 In progress to 🔎 In review in Team Altinn Studio Nov 27, 2025
@Konrad-Simso Konrad-Simso self-assigned this Nov 28, 2025
Copy link
Contributor

@Konrad-Simso Konrad-Simso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Konrad-Simso Konrad-Simso removed their assignment Nov 28, 2025
@Konrad-Simso Konrad-Simso moved this from 🔎 In review to 🧪 Test in Team Altinn Studio Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/content-library Area: Related to library for shared resources area/dashboard Area: Related to the dashboard application frontend skip-releasenotes Issues that do not make sense to list in our release notes solution/studio/designer squad/data Issues that belongs to the named squad.

Projects

Status: 🧪 Test

Development

Successfully merging this pull request may close these issues.

Create the graphical interface for the new code list page

2 participants