Skip to content

refactor: move ConditionalWrapper to app#18838

Open
JamalAlabdullah wants to merge 11 commits into
mainfrom
refactor/move-ConditionalWrapper-to-app
Open

refactor: move ConditionalWrapper to app#18838
JamalAlabdullah wants to merge 11 commits into
mainfrom
refactor/move-ConditionalWrapper-to-app

Conversation

@JamalAlabdullah
Copy link
Copy Markdown
Contributor

@JamalAlabdullah JamalAlabdullah commented May 19, 2026

Related issue : #18809

Description

  • Move ConditionalWrapper to @app/form-component
  • Update consumers to import from @app/form-component
  • Added a Storybook story

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

  • New Features

    • ConditionalWrapper is now available from the central form-component library for consistent use across the frontend.
  • Documentation

    • Storybook updated with three interactive variants: Wrapped, Unwrapped and Otherwise.
  • Tests

    • Test suite migrated to Vitest and extended with a scenario validating the otherwise/alternative-wrapper path.
  • Chores

    • Updated imports across the frontend and removed a local mock so the shared component is used consistently.

Review Change Stack

@github-actions github-actions Bot added the skip-releasenotes Issues that do not make sense to list in our release notes label May 19, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

ConditionalWrapper is exported from the @app/form-component library (barrel exports), gains Storybook stories, tests migrate from Jest to Vitest, multiple consumers switch imports to the library barrel, and monorepo changed-paths are updated.

Changes

ConditionalWrapper library centralisation

Layer / File(s) Summary
Library barrel exports
libs/form-component/src/app-components/ConditionalWrapper/index.ts, libs/form-component/src/app-components/index.ts
ConditionalWrapper is re-exported via nested barrel exports, enabling @app/form-component imports.
Storybook and Vitest tests
libs/form-component/src/app-components/ConditionalWrapper/ConditionalWrapper.stories.tsx, libs/form-component/src/app-components/ConditionalWrapper/ConditionalWrapper.test.tsx, src/App/frontend/src/components/atoms/AltinnAttachments.test.tsx
Adds Storybook stories (Wrapped, Unwrapped, Otherwise). Migrates tests from Jest to Vitest (uses vi.fn), adds an otherwise callback test, and removes a Jest mock from AltinnAttachments tests.
Consumer import path updates
src/App/frontend/src/app-components/Panel/Panel.tsx, src/App/frontend/src/components/form/RadioButton.tsx, src/App/frontend/src/layout/Checkboxes/CheckboxesContainerComponent.tsx, src/App/frontend/src/layout/Checkboxes/WrappedCheckbox.tsx, src/App/frontend/src/layout/FileUpload/FileUploadTable/FileTableButtons.tsx, src/App/frontend/src/layout/Grid/GridComponent.tsx, src/App/frontend/src/layout/Group/GroupComponent.tsx, src/App/frontend/src/layout/Group/GroupSummary.tsx, src/App/frontend/src/layout/RadioButtons/ControlledRadioGroup.tsx, src/App/frontend/src/layout/RepeatingGroup/Container/RepeatingGroupContainer.tsx, src/App/frontend/src/layout/RepeatingGroup/Pagination/RepeatingGroupPagination.tsx
Eleven consumer files update their ConditionalWrapper import source to @app/form-component; no runtime or API changes.
Monorepo path tracking
src/App/frontend/monorepo-changed-paths.txt
Adds src/app-components/ConditionalWrapper/ to the monitored frontend changed-paths list and adjusts Text/ monitoring entry.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Altinn/altinn-studio#18749: Adds Storybook infrastructure in libs/form-component, related to the new ConditionalWrapper stories.

Suggested labels

kind/chore

Suggested reviewers

  • framitdavid

Poem

🐰 I hopped a path from folder maze to one neat name,
Stories dressed in colour, tests with Vitest's claim,
Consumers now gather where a single import sings,
I nibble tidy barrels and applaud the simpler things.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'refactor: move ConditionalWrapper to app' accurately describes the primary change—relocating the ConditionalWrapper component to the @app/form-component module—which aligns with the changeset modifications across multiple files.
Description check ✅ Passed The description covers the main objectives (moving ConditionalWrapper, updating imports, adding Storybook story) and includes all required verification checklist items, though some checkboxes remain unchecked by the author.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/move-ConditionalWrapper-to-app

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.

@JamalAlabdullah JamalAlabdullah added the squad/utforming Issues that belongs to the named squad. label May 19, 2026
@JamalAlabdullah JamalAlabdullah moved this to 🔎 In review in Team Altinn Studio May 19, 2026
Copy link
Copy Markdown
Contributor

@walldenfilippa walldenfilippa left a comment

Choose a reason for hiding this comment

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

Ser bra ut! 🥳 Hadde et mindre spørsmål i en av filene.

Copy link
Copy Markdown
Contributor

@walldenfilippa walldenfilippa May 20, 2026

Choose a reason for hiding this comment

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

Lurte litt på hvorfor disse ble lagt til her? Om dem heller skal være i en annen PR?

src/app-components/TimePicker/TimeSegment/TimeSegment.tsx
src/features/instantiate/containers/UnknownError.module.css
src/features/instantiate/containers/UnknownErrorDetails.module.css
src/features/instantiate/containers/UnknownErrorDetails.tsx
src/layout/SigningDocumentList/api.test.ts

Copy link
Copy Markdown
Contributor Author

@JamalAlabdullah JamalAlabdullah May 20, 2026

Choose a reason for hiding this comment

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

Vi oppdaterer den for hver PR hvor vi flytter en komponent slik at vi får opp en advarsel i legacy repoet om man gjør endringer der det er gjort noe i minorepo, vi følger de here:

Instructions

  1. The task is to migrate @../../../src/App/frontend/src/app-components/$ARGUMENTS[0] to @../../../libs/form-component/src/app-components
  2. Ask the user any clarifying questions you have
  3. checkout a new branch called refactor/move-$ARGUMENTS[0]-to-app
  4. Make a plan to move
  5. Move the component
  6. Fix any imports using the component
  7. Remove forwardRef if in use in the component
  8. Add unit tests for the component if they don't exist
  9. Add a suitable storybook story for the component
  10. Go to @../../../src/App/frontend and run npx tsx scripts/compare-frontend-repos.ts update
  11. Output a PR description based on this format ../../../.github/pull_request_template.md. Keep it short and simple, keep the checkboxes, tick the relevant boxes

@JamalAlabdullah JamalAlabdullah self-assigned this May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-releasenotes Issues that do not make sense to list in our release notes squad/utforming Issues that belongs to the named squad.

Projects

Status: 🔎 In review

Development

Successfully merging this pull request may close these issues.

Move ConditionalWrapper component from app-components to libs

3 participants