Skip to content

Conversation

olemartinorg
Copy link
Contributor

@olemartinorg olemartinorg commented Sep 22, 2025

Description

Currently, taskStore is a context that is provided pretty much all around, and some places we set data in it (and then wait until that data is set in the zustand store before continuing rendering). This seemed overly complicated, as what we really need here (as far as i can tell) is just to provide some overrides to components below us - so a regular context will suffice and be easier to follow.

This PR cherry-picks such a refactor from #3731, where I really needed to provide multiple different sets of overrides side-by-side for rendering automatic PDFs for different tasks.

I also found a minor issue in the useLayoutSetId() hook, which simply re-did much of what useCurrentLayoutSetId() already did. The only difference I could find was that it preferred the URL as a source of taskId over the current process data, which is what useCurrentLayoutSetId() preferred. Removed the cruft and renamed the hook useLayoutSetIdFromUrl() to reflect what it actually is there to do.

Related Issue(s)

  • closes #{issue number}

Verification/QA

  • Manual functionality testing
    • I have tested these changes manually
    • Creator of the original issue (or service owner) has been contacted for manual testing (or will be contacted when released in alpha)
    • No testing done/necessary
  • Automated tests
    • Unit test(s) have been added/updated
    • Cypress E2E test(s) have been added/updated
    • No automatic tests are needed here (no functional changes/additions)
    • I want someone to help me make some tests
  • UU/WCAG (follow these guidelines until we have our own)
    • I have tested with a screen reader/keyboard navigation/automated wcag validator
    • No testing done/necessary (no DOM/visual changes)
    • I want someone to help me perform accessibility testing
  • User documentation @ altinn-studio-docs
    • Has been added/updated
    • No functionality has been changed/added, so no documentation is needed
    • I will do that later/have created an issue
  • Support in Altinn Studio
    • Issue(s) created for support in Studio
    • This change/feature does not require any changes to Altinn Studio
  • Sprint board
    • The original issue (or this PR itself) has been added to the Team Apps project and to the current sprint board
    • I don't have permissions to do that, please help me out
  • Labels
    • I have added a kind/* and backport* label to this PR for proper release notes grouping
    • I don't have permissions to add labels, please help me out

Summary by CodeRabbit

  • New Features

    • Centralized task/data/layout override mechanism available across the app.
  • Refactor

    • Replaced legacy task-store/provider usage with a lightweight override context and URL-driven layout selection.
    • Reduced provider nesting and simplified subform, summary and instantiation rendering with clearer read-only handling for non-current tasks.
  • Bug Fixes

    • More consistent layout/data selection and attachment behavior across tasks.
  • Tests

    • Updated test provider setup to match the streamlined context.

Ole Martin Handeland added 3 commits September 22, 2025 16:02
… using zustand. It is only really used to override things, and the pattern we used to wait until things were set in zustand clearly indicated this was the wrong approach.
@olemartinorg olemartinorg self-assigned this Sep 22, 2025
@olemartinorg olemartinorg added kind/other Pull requests containing chores/repo structure/other changes backport-ignore This PR is a new feature and should not be cherry-picked onto release branches squad/utforming Issues that belongs to the named squad. labels Sep 22, 2025
Copy link

coderabbitai bot commented Sep 22, 2025

📝 Walkthrough

Walkthrough

Replaces the old TaskStore context with a new TaskOverrides React context and hook. Removes TaskStoreProvider usage throughout the app and tests. Updates many consumers to read overrides via useTaskOverrides, adds SubformOverrideWrapper, and shifts layout-set resolution to a URL-driven hook.

Changes

Cohort / File(s) Summary of changes
Introduce TaskOverrides context
src/core/contexts/TaskOverrides.tsx
Adds TaskOverridesContext, TaskOverrides provider component that merges parent overrides with local props, and useTaskOverrides hook exposing optional overrides: taskId, dataModelType, dataModelElementId, layoutSetId.
Remove TaskStore context
src/core/contexts/taskStoreContext.tsx
Deletes the TaskStore implementation: TaskStoreProvider, useTaskStore, TaskState/TaskActions types, internal state and action handlers, and module exports.
Global/provider tree updates
src/index.tsx, src/test/renderWithProviders.tsx, src/features/instantiate/containers/InstantiationContainer.tsx, src/features/instantiate/selection/InstanceSelection.tsx
Removes TaskStoreProvider wrappers and imports; reflows provider nesting and test/provider helpers to render without TaskStoreProvider.
Subform refactor & new wrapper
src/layout/Subform/SubformWrapper.tsx, src/layout/Subform/Summary/SubformSummaryComponent2.tsx, src/layout/Subform/index.tsx
Replaces inline override hooks and TaskStoreProvider usage with SubformOverrideWrapper that resolves data IDs/types and renders children inside TaskOverrides; per-element TaskStoreProvider replaced with Fragment + TaskOverrides; old override hooks removed.
Summary wrappers & task summary
src/layout/Summary2/SummaryComponent2/TaskSummaryWrapper.tsx, src/layout/Summary2/SummaryComponent2/SummaryComponent2.tsx, src/layout/Summary2/CommonSummaryComponents/EditButton.tsx
Removes TaskStore-driven syncing/effects; derives layoutSetForTask and wraps children in TaskOverrides; adjusts conditional rendering (readOnly FormProvider) and replaces useTaskStore usages with useTaskOverrides.
Consumers switched to TaskOverrides
src/features/attachments/StoreAttachmentsInNode.tsx, src/features/datamodel/DataModelsProvider.tsx, src/features/datamodel/useBindingSchema.tsx, src/features/instance/useProcessTaskId.ts, src/layout/FileUpload/FileUploadTable/FileTableRow.tsx
Replaces useTaskStore selectors with useTaskOverrides() calls to read taskId, dataModelElementId, dataModelType, layoutSetId; updates imports and uses optional chaining/nullish coalescing where appropriate.
Layout-set URL-driven access
src/features/form/layoutSets/useCurrentLayoutSet.ts, src/features/form/layout/LayoutsContext.tsx, src/queries/formPrefetcher.ts, src/features/form/layoutSettings/LayoutSettingsContext.tsx, src/features/devtools/components/LayoutInspector/LayoutInspector.tsx
Introduces useLayoutSetIdFromUrl() (reads taskId from navigation param) and refactors useCurrentLayoutSet/useCurrentLayoutSetId to accept an optional taskId; updates callers to use URL-driven layout-set resolution instead of the removed useLayoutSetId.
Miscellaneous UI/test updates
src/utils/layout/all.test.tsx, src/layout/Subform/Summary/SubformSummaryComponent2.tsx, src/layout/Summary2/SummaryComponent2/SummaryComponent2.tsx
Removes TaskStoreProvider from tests and several render paths; replaces provider wrappers with Fragments or TaskOverrides where appropriate; adjusts keys/structure in per-element renders.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly and accurately summarizes the primary change: converting the TaskStore into a regular React context and simplifying provider/hook usage. It is concise, focused, and directly reflects the diffs that remove TaskStoreProvider usages and introduce TaskOverrides and related hook renames. A reviewer scanning history will understand the main refactor from this title.
Description Check ✅ Passed The PR description follows the repository template and provides a clear non-technical summary, motivation for the refactor, and verification checklist including manual testing; it also documents the hook renaming and references the source PR. Overall the content is sufficient for reviewers to understand the intent and scope of the change. However, the Related Issue(s) section still contains the placeholder "closes #{issue number}" rather than a concrete issue reference.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/task-store

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ad6918e and 98d2171.

📒 Files selected for processing (1)
  • src/features/devtools/components/LayoutInspector/LayoutInspector.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Avoid using any and unnecessary type casts (as Type) in TypeScript; prefer precise typings and refactor existing casts/anys
For TanStack Query, use objects to manage query keys and functions, and centralize shared options via queryOptions

Files:

  • src/features/devtools/components/LayoutInspector/LayoutInspector.tsx
🧬 Code graph analysis (1)
src/features/devtools/components/LayoutInspector/LayoutInspector.tsx (1)
src/features/form/layoutSets/useCurrentLayoutSet.ts (1)
  • useLayoutSetIdFromUrl (14-17)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Cypress Run Internal (6)
  • GitHub Check: Cypress Run Internal (2)
  • GitHub Check: Cypress Run Internal (5)
  • GitHub Check: Cypress Run Internal (4)
  • GitHub Check: Cypress Run Internal (3)
  • GitHub Check: Cypress Run Internal (1)
  • GitHub Check: Type-checks, eslint, unit tests and SonarCloud
🔇 Additional comments (2)
src/features/devtools/components/LayoutInspector/LayoutInspector.tsx (2)

24-24: Guard for missing layoutSetId

useLayoutSetIdFromUrl() can be undefined; downstream this is used in a TanStack Query filter. See fix below to avoid touching incorrect queries or no-ops when the URL lacks taskId.


13-14: Swap to URL-driven layout-set ID looks correct — confirm hook stability when no taskId

useLayoutSetIdFromUrl() -> useNavigationParam('taskId') -> useCurrentLayoutSetId(...) which falls back to processTaskId; if both are absent (or app/layoutSets contexts not provided) it returns undefined, causing saves/prefetches that use ['formLayouts', currentLayoutSetId] to no-op. Verify preview/PDF routes supply a stable layoutSetId (URL, process, or override) or add a guard/default before saving/prefetching.

Check: src/features/devtools/components/LayoutInspector/LayoutInspector.tsx; src/features/form/layout/LayoutsContext.tsx; src/features/form/layoutSettings/LayoutSettingsContext.tsx; src/queries/formPrefetcher.ts


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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/features/datamodel/DataModelsProvider.tsx (1)

214-225: Align layout-set source between DataModelsProvider and LayoutsContext

DataModelsLoader stores layoutSetId from useCurrentLayoutSetId, while LayoutsContext selects layouts via useLayoutSetId (which prefers TaskOverrides / useNavigationParam('taskId') before falling back) — they can diverge and cause spurious 'layout-set-change' loaders. Use the same source (e.g., call useLayoutSetId or derive the id from the layouts used) when calling setDataTypes in src/features/datamodel/DataModelsProvider.tsx.

🧹 Nitpick comments (7)
src/core/contexts/TaskOverrides.tsx (3)

13-13: Remove unused Omit key ('depth').

depth isn’t part of TaskOverridesContext; dropping the Omit reduces confusion.

-type Props = PropsWithChildren & Omit<TaskOverridesContext, 'depth'>;
+type Props = PropsWithChildren & TaskOverridesContext;

11-11: Add a displayName for easier React DevTools debugging.

-const Context = createContext<TaskOverridesContext>({});
+const Context = createContext<TaskOverridesContext>({});
+Context.displayName = 'TaskOverridesContext';

1-2: Memoize provider value to avoid unnecessary re-renders of consumers.

-import React, { createContext, useContext } from 'react';
+import React, { createContext, useContext, useMemo } from 'react';
@@
-  return (
-    <Context.Provider
-      value={{
-        taskId: overrides.taskId ?? parentContext.taskId,
-        dataModelType: overrides.dataModelType ?? parentContext.dataModelType,
-        dataModelElementId: overrides.dataModelElementId ?? parentContext.dataModelElementId,
-        layoutSetId: overrides.layoutSetId ?? parentContext.layoutSetId,
-      }}
-    >
+  const value = useMemo(
+    () => ({
+      taskId: overrides.taskId ?? parentContext.taskId,
+      dataModelType: overrides.dataModelType ?? parentContext.dataModelType,
+      dataModelElementId: overrides.dataModelElementId ?? parentContext.dataModelElementId,
+      layoutSetId: overrides.layoutSetId ?? parentContext.layoutSetId,
+    }),
+    [
+      overrides.taskId,
+      overrides.dataModelType,
+      overrides.dataModelElementId,
+      overrides.layoutSetId,
+      parentContext.taskId,
+      parentContext.dataModelType,
+      parentContext.dataModelElementId,
+      parentContext.layoutSetId,
+    ],
+  );
+  return (
+    <Context.Provider value={value}>
       {children}
     </Context.Provider>
   );

Also applies to: 17-24

src/layout/FileUpload/FileUploadTable/FileTableRow.tsx (1)

43-46: Rename typo and simplify boolean derivation.

Use a single boolean and fix “Overriden” → “Overridden”.

-  const overriddenTaskId = useTaskOverrides()?.taskId;
-
-  const hasOverridenTaskId = !!overriddenTaskId;
+  const hasOverriddenTaskId = Boolean(useTaskOverrides()?.taskId);
@@
-      style={hasOverridenTaskId ? { padding: '8px 0' } : {}}
+      style={hasOverriddenTaskId ? { padding: '8px 0' } : {}}

Also applies to: 81-81

src/features/attachments/StoreAttachmentsInNode.tsx (1)

92-103: Use nullish coalescing for readability

Small readability tweak; keeps behavior identical.

-  const overriddenTaskId = useTaskOverrides()?.taskId;
+  const overriddenTaskId = useTaskOverrides()?.taskId;
@@
-  const mappedAttachments = useMemoDeepEqual(() => {
-    const taskId = overriddenTaskId ? overriddenTaskId : currentTask;
-
-    return mapAttachments(indexedId, baseId, data, application, taskId, nodeData);
-  }, [indexedId, baseId, data, application, currentTask, nodeData, overriddenTaskId]);
+  const mappedAttachments = useMemoDeepEqual(() => {
+    const taskId = overriddenTaskId ?? currentTask;
+    return mapAttachments(indexedId, baseId, data, application, taskId, nodeData);
+  }, [indexedId, baseId, data, application, currentTask, nodeData, overriddenTaskId]);
src/layout/Summary2/CommonSummaryComponents/EditButton.tsx (1)

69-85: Tighten conditionals

Minor simplification to avoid redundant checks.

-  const overrides = useTaskOverrides();
-  const overriddenTaskId = overrides?.taskId;
-  const overriddenDataElementId = overrides?.dataModelElementId;
+  const overrides = useTaskOverrides();
+  const overriddenTaskId = overrides?.taskId;
+  const overriddenDataElementId = overrides?.dataModelElementId;
@@
-  if (pdfModeActive || (overriddenTaskId && overriddenTaskId?.length > 0)) {
+  if (pdfModeActive || overriddenTaskId?.length) {
     return null;
   }
src/test/renderWithProviders.tsx (1)

481-505: Optional: Add an easy path to inject TaskOverrides in tests

DefaultProviders/MinimalProviders in src/test/renderWithProviders.tsx do not provide TaskOverrides, and many components call useTaskOverrides (e.g. src/layout/Subform/SubformWrapper.tsx, src/layout/Summary2/CommonSummaryComponents/EditButton.tsx, src/features/instance/useProcessTaskId.ts). Add an optional wrapper prop or an overrides argument to the test render helpers (or accept an overrides object in DefaultProviders/MinimalProviders) so tests can pass { taskId, dataModelType, dataModelElementId, layoutSetId } when needed.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8556c9a and 2c05342.

📒 Files selected for processing (20)
  • src/core/contexts/TaskOverrides.tsx (1 hunks)
  • src/core/contexts/taskStoreContext.tsx (0 hunks)
  • src/features/attachments/StoreAttachmentsInNode.tsx (2 hunks)
  • src/features/datamodel/DataModelsProvider.tsx (2 hunks)
  • src/features/datamodel/useBindingSchema.tsx (3 hunks)
  • src/features/form/layout/LayoutsContext.tsx (2 hunks)
  • src/features/form/layoutSets/useCurrentLayoutSet.ts (2 hunks)
  • src/features/instance/useProcessTaskId.ts (1 hunks)
  • src/features/instantiate/containers/InstantiationContainer.tsx (1 hunks)
  • src/features/instantiate/selection/InstanceSelection.tsx (3 hunks)
  • src/index.tsx (1 hunks)
  • src/layout/FileUpload/FileUploadTable/FileTableRow.tsx (2 hunks)
  • src/layout/Subform/SubformWrapper.tsx (4 hunks)
  • src/layout/Subform/Summary/SubformSummaryComponent2.tsx (5 hunks)
  • src/layout/Subform/index.tsx (1 hunks)
  • src/layout/Summary2/CommonSummaryComponents/EditButton.tsx (2 hunks)
  • src/layout/Summary2/SummaryComponent2/SummaryComponent2.tsx (1 hunks)
  • src/layout/Summary2/SummaryComponent2/TaskSummaryWrapper.tsx (2 hunks)
  • src/test/renderWithProviders.tsx (2 hunks)
  • src/utils/layout/all.test.tsx (1 hunks)
💤 Files with no reviewable changes (1)
  • src/core/contexts/taskStoreContext.tsx
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Avoid using any and unnecessary type casts (as Type) in TypeScript; prefer precise typings and refactor existing casts/anys
For TanStack Query, use objects to manage query keys and functions, and centralize shared options via queryOptions

Files:

  • src/features/form/layoutSets/useCurrentLayoutSet.ts
  • src/features/instantiate/containers/InstantiationContainer.tsx
  • src/features/instantiate/selection/InstanceSelection.tsx
  • src/layout/FileUpload/FileUploadTable/FileTableRow.tsx
  • src/core/contexts/TaskOverrides.tsx
  • src/index.tsx
  • src/features/datamodel/useBindingSchema.tsx
  • src/layout/Summary2/SummaryComponent2/SummaryComponent2.tsx
  • src/layout/Summary2/SummaryComponent2/TaskSummaryWrapper.tsx
  • src/layout/Subform/Summary/SubformSummaryComponent2.tsx
  • src/features/instance/useProcessTaskId.ts
  • src/test/renderWithProviders.tsx
  • src/utils/layout/all.test.tsx
  • src/layout/Summary2/CommonSummaryComponents/EditButton.tsx
  • src/layout/Subform/SubformWrapper.tsx
  • src/features/attachments/StoreAttachmentsInNode.tsx
  • src/features/form/layout/LayoutsContext.tsx
  • src/layout/Subform/index.tsx
  • src/features/datamodel/DataModelsProvider.tsx
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

In tests, use renderWithProviders from src/test/renderWithProviders.tsx to supply required form layout context

Files:

  • src/utils/layout/all.test.tsx
src/layout/*/{config.ts,Component.tsx,index.tsx,config.generated.ts}

📄 CodeRabbit inference engine (CLAUDE.md)

Layout components must follow the standardized structure: config.ts, Component.tsx, index.tsx, and include generated types in config.generated.ts

Files:

  • src/layout/Subform/index.tsx
🧠 Learnings (2)
📚 Learning: 2025-08-22T13:53:28.252Z
Learnt from: CR
PR: Altinn/app-frontend-react#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-22T13:53:28.252Z
Learning: Applies to **/*.test.{ts,tsx} : In tests, use `renderWithProviders` from `src/test/renderWithProviders.tsx` to supply required form layout context

Applied to files:

  • src/features/form/layoutSets/useCurrentLayoutSet.ts
  • src/layout/Summary2/SummaryComponent2/TaskSummaryWrapper.tsx
  • src/layout/Subform/Summary/SubformSummaryComponent2.tsx
  • src/test/renderWithProviders.tsx
  • src/utils/layout/all.test.tsx
  • src/layout/Subform/SubformWrapper.tsx
  • src/features/form/layout/LayoutsContext.tsx
  • src/layout/Subform/index.tsx
📚 Learning: 2025-08-22T13:53:28.252Z
Learnt from: CR
PR: Altinn/app-frontend-react#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-22T13:53:28.252Z
Learning: Applies to src/features/*/Provider.tsx : Place feature-specific context providers as `Provider.tsx` within each feature directory under `src/features/`

Applied to files:

  • src/index.tsx
  • src/test/renderWithProviders.tsx
🧬 Code graph analysis (18)
src/features/form/layoutSets/useCurrentLayoutSet.ts (1)
src/core/contexts/TaskOverrides.tsx (1)
  • useTaskOverrides (31-31)
src/features/instantiate/containers/InstantiationContainer.tsx (2)
src/core/ui/RenderStart.tsx (1)
  • RenderStart (22-31)
src/components/ReadyForPrint.tsx (1)
  • ReadyForPrint (21-52)
src/features/instantiate/selection/InstanceSelection.tsx (2)
src/features/instantiate/selection/ActiveInstancesProvider.tsx (1)
  • ActiveInstancesProvider (43-47)
src/components/presentation/Presentation.tsx (1)
  • PresentationComponent (34-99)
src/layout/FileUpload/FileUploadTable/FileTableRow.tsx (1)
src/core/contexts/TaskOverrides.tsx (1)
  • useTaskOverrides (31-31)
src/core/contexts/TaskOverrides.tsx (1)
src/core/contexts/context.tsx (1)
  • createContext (45-89)
src/index.tsx (8)
src/features/applicationMetadata/ApplicationMetadataProvider.tsx (1)
  • ApplicationMetadataProvider (59-65)
src/features/formData/FormDataReaders.tsx (1)
  • GlobalFormDataReadersProvider (106-158)
src/features/language/LanguageProvider.tsx (1)
  • SetShouldFetchAppLanguages (90-102)
src/features/party/PartiesProvider.tsx (1)
  • PartyProvider (168-180)
src/core/auth/KeepAliveProvider.tsx (1)
  • KeepAliveProvider (48-55)
src/core/errorHandling/DisplayErrorProvider.tsx (1)
  • DisplayErrorProvider (9-17)
src/core/contexts/processingContext.tsx (1)
  • ProcessingProvider (14-24)
src/queries/partyPrefetcher.ts (1)
  • PartyPrefetcher (8-15)
src/features/datamodel/useBindingSchema.tsx (1)
src/core/contexts/TaskOverrides.tsx (1)
  • useTaskOverrides (31-31)
src/layout/Summary2/SummaryComponent2/SummaryComponent2.tsx (2)
src/layout/Summary2/summaryStoreContext.tsx (1)
  • Summary2StoreProvider (16-27)
src/layout/Summary2/SummaryComponent2/TaskSummaryWrapper.tsx (1)
  • TaskSummaryWrapper (14-28)
src/layout/Summary2/SummaryComponent2/TaskSummaryWrapper.tsx (2)
src/core/contexts/TaskOverrides.tsx (1)
  • TaskOverrides (14-29)
src/features/form/FormContext.tsx (1)
  • FormProvider (43-86)
src/layout/Subform/Summary/SubformSummaryComponent2.tsx (2)
src/core/contexts/TaskOverrides.tsx (1)
  • TaskOverrides (14-29)
src/layout/Summary2/SummaryComponent2/LayoutSetSummary.tsx (1)
  • LayoutSetSummary (13-33)
src/features/instance/useProcessTaskId.ts (1)
src/core/contexts/TaskOverrides.tsx (1)
  • useTaskOverrides (31-31)
src/utils/layout/all.test.tsx (1)
src/layout/Subform/SubformWrapper.tsx (1)
  • SubformWrapper (16-22)
src/layout/Summary2/CommonSummaryComponents/EditButton.tsx (1)
src/core/contexts/TaskOverrides.tsx (1)
  • useTaskOverrides (31-31)
src/layout/Subform/SubformWrapper.tsx (2)
src/features/form/FormContext.tsx (1)
  • FormProvider (43-86)
src/core/contexts/TaskOverrides.tsx (1)
  • TaskOverrides (14-29)
src/features/attachments/StoreAttachmentsInNode.tsx (1)
src/core/contexts/TaskOverrides.tsx (1)
  • useTaskOverrides (31-31)
src/features/form/layout/LayoutsContext.tsx (1)
src/core/contexts/TaskOverrides.tsx (1)
  • useTaskOverrides (31-31)
src/layout/Subform/index.tsx (1)
src/layout/Subform/SubformWrapper.tsx (3)
  • SubformWrapper (16-22)
  • SubformForm (24-32)
  • RedirectBackToMainForm (34-43)
src/features/datamodel/DataModelsProvider.tsx (1)
src/core/contexts/TaskOverrides.tsx (1)
  • useTaskOverrides (31-31)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Type-checks, eslint, unit tests and SonarCloud
  • GitHub Check: Install
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (27)
src/layout/Summary2/SummaryComponent2/SummaryComponent2.tsx (1)

31-35: LGTM: Provider stack simplified correctly.

Wrapping with Summary2StoreProvider and using TaskSummaryWrapper for overrides matches the new context approach; no behavior regressions apparent.

src/utils/layout/all.test.tsx (1)

82-82: LGTM: Test wrapper aligns with new Subform override flow.

Dropping the old TaskStore wrapper is consistent; renderWithInstanceAndLayout still supplies required providers.

src/features/instantiate/containers/InstantiationContainer.tsx (1)

21-28: LGTM: Removal of legacy provider.

Direct rendering under RenderStart is consistent with the refactor; no lost dependencies spotted.

src/layout/Subform/index.tsx (1)

27-40: LGTM: Sub-routing now uses SubformWrapper with new overrides.

Routes are intact; redirect preserved. Matches the TaskOverrides migration.

src/features/instance/useProcessTaskId.ts (1)

1-1: LGTM: Override source switched to TaskOverrides.

Resolution order (override → process → URL) remains unchanged.

Also applies to: 6-9

src/features/form/layoutSets/useCurrentLayoutSet.ts (1)

2-2: LGTM: Layout set override sourced from TaskOverrides.

Fallback to getCurrentLayoutSet maintained; nullability handling is correct.

Also applies to: 16-26

src/test/renderWithProviders.tsx (2)

332-358: LGTM: Provider simplification reads clean and preserves loading order

LanguageProvider remains above SetShouldFetchAppLanguages and Router is wrapped with NavigationEffectProvider. Looks good.


383-388: LGTM: MinimalProviders keeps a lean tree

Appropriate for lightweight tests; removing TaskStoreProvider here is safe.

src/features/attachments/StoreAttachmentsInNode.tsx (1)

5-5: LGTM: Switched to TaskOverrides

Importing useTaskOverrides aligns with the refactor.

src/features/instantiate/selection/InstanceSelection.tsx (2)

46-54: LGTM: Provider removal

Wrapping with ActiveInstancesProvider and PresentationComponent is sufficient here.


237-290: LGTM: Wrapper fragment

No behavioral change; title and ReadyForPrint remain intact.

src/layout/Summary2/CommonSummaryComponents/EditButton.tsx (1)

6-6: LGTM: Import moved to TaskOverrides

Matches the new context.

src/features/datamodel/useBindingSchema.tsx (2)

37-49: LGTM: Overridden data element id respected

Correctly short-circuits to the override in the selector.


133-148: LGTM: Overridden data model type respected

Falls back to computed type when no override is present.

src/features/datamodel/DataModelsProvider.tsx (1)

173-176: LGTM: Override plumbing

Using overrides to relax instance data element checks prevents false negatives during subform add flows.

src/index.tsx (1)

95-125: LGTM — confirm TaskStoreProvider/useTaskStore fully removed

Sandbox search produced no matches; run locally to verify no lingering imports/usages:

rg -n --hidden -S -uu '\b(TaskStoreProvider|useTaskStore)\b' --glob '!node_modules/**' || true
src/features/form/layout/LayoutsContext.tsx (1)

86-103: LGTM — overrides are respected consistently.

Both useLayoutSetId (LayoutsContext.tsx) and useCurrentLayoutSet/useCurrentLayoutSetId (useCurrentLayoutSet.ts) read useTaskOverrides(), and DataModelsProvider sets and compares its layoutSetId via useCurrentLayoutSetId() in BlockUntilLoaded — no change required.

src/layout/Summary2/SummaryComponent2/TaskSummaryWrapper.tsx (3)

1-3: LGTM! Clean import replacement.

The import changes align with the refactor from TaskStore to TaskOverrides context.


17-17: LGTM! Direct data derivation improves clarity.

The derivation of layoutSetForTask directly from layoutSets and taskId is more straightforward than the previous approach using TaskStore state.


19-27: Verify TaskOverrides context consumption. useTaskOverrides() is invoked in:

  • src/features/instance/useProcessTaskId.ts
  • src/layout/Summary2/CommonSummaryComponents/EditButton.tsx
  • src/layout/FileUpload/FileUploadTable/FileTableRow.tsx
  • src/features/attachments/StoreAttachmentsInNode.tsx
  • src/features/form/layoutSets/useCurrentLayoutSet.ts
  • src/features/form/layout/LayoutsContext.tsx
  • src/features/datamodel/useBindingSchema.tsx
  • src/features/datamodel/DataModelsProvider.tsx

Confirm each consumer receives the correct taskId, layoutSetId, and dataModelType when rendered under this wrapper.

src/layout/Subform/SubformWrapper.tsx (3)

6-6: LGTM! Proper context import.

Adding TaskOverrides import aligns with the refactor to use the new context system.


17-22: Good delegation pattern.

The refactor to delegate to SubformOverrideWrapper creates a cleaner separation of concerns. The wrapper handles overrides while this component focuses on providing the FormProvider.


45-71: Approve — wrapper is correct; confirm desired failure mode

SubformOverrideWrapper (src/layout/Subform/SubformWrapper.tsx) correctly derives actualDataElementId, resolves layoutSet/dataType and throws if dataType is missing.

  • TaskOverrides is used to scope dataModelType/dataModelElementId/layoutSet.
  • Error boundaries exist: src/components/ErrorBoundary.tsx (used in src/index.tsx), plus ComponentErrorBoundary (src/utils/layout/ComponentErrorBoundary.tsx) and GeneratorErrorBoundary (src/utils/layout/generator/GeneratorErrorBoundary.tsx).

If fail-fast is acceptable, no change needed. If you want graceful degradation, replace the throw with a user-facing fallback (Loader/error UI) or ensure callers always provide a valid layoutSet/dataType.

src/layout/Subform/Summary/SubformSummaryComponent2.tsx (4)

1-1: LGTM! Import changes support the refactor.

Adding Fragment and TaskOverrides imports while removing TaskStoreProvider aligns with the context migration.

Also applies to: 7-7


58-58: Simplified keying strategy with Fragment.

Using Fragment with idx key simplifies the wrapper structure. This is acceptable since the data elements array should remain stable within a render cycle.

Also applies to: 67-67


105-140: Well-structured TaskOverrides integration.

The TaskOverrides wrapper correctly provides:

  • dataModelElementId from the data element
  • dataModelType from the data element
  • layoutSetId from the layout set

The nested FormProvider with readOnly=true and the addition of LayoutSetSummary as a sibling component maintains the expected behavior while using the new context system.


94-96: Verify removal of TaskStore dependency.

useSubformFormData now exposes isSubformDataFetching from useFormDataQuery (src/layout/Subform/utils.ts:22–34). Component early-returns while fetching:

  if (isSubformDataFetching) {
    return null;
  }

Confirm TaskOverrides (previously synced from TaskStore) are available before this component renders — repo search did not find useTaskOverrides (TSX search reported unrecognized file type); manual verification required to avoid timing/race issues.

Ole Martin Handeland added 3 commits September 22, 2025 17:11
…ed, and did much of the same stuff that useCurrentLayoutSetId() already did. The main difference was the taskId source, where useLayoutSetId() preferred the one from the URL, so I renamed it to reflect that.
Copy link

@olemartinorg olemartinorg merged commit 9ed8295 into main Sep 23, 2025
16 checks passed
@olemartinorg olemartinorg deleted the refactor/task-store branch September 23, 2025 11:40
@github-project-automation github-project-automation bot moved this from 🔎 In review to ✅ Done in Team Altinn Studio Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-ignore This PR is a new feature and should not be cherry-picked onto release branches kind/other Pull requests containing chores/repo structure/other changes squad/utforming Issues that belongs to the named squad.
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants