Skip to content

fix: unarchive option in archived template library #8585

Merged
jaycnz merged 4 commits intomainfrom
jaychen/nes-1186-check-for-unarchive-option-in-template-library
Jan 19, 2026
Merged

fix: unarchive option in archived template library #8585
jaycnz merged 4 commits intomainfrom
jaychen/nes-1186-check-for-unarchive-option-in-template-library

Conversation

@jaycnz
Copy link
Copy Markdown
Contributor

@jaycnz jaycnz commented Jan 13, 2026

Summary by CodeRabbit

  • Refactor

    • Renamed an internal routing parameter used by the Status Tab Panel to improve consistency in tab/state handling.
  • Tests

    • Updated test cases and mocked values to reflect the internal parameter rename and ensure accurate validation of active/archived/trashed states.

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

@jaycnz jaycnz requested a review from edmonday January 13, 2026 03:52
@jaycnz jaycnz self-assigned this Jan 13, 2026
@jaycnz jaycnz added effort: 2 type: fix Iterations on existing features or infrastructure. Bug labels Jan 13, 2026
@linear
Copy link
Copy Markdown

linear Bot commented Jan 13, 2026

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 13, 2026

Walkthrough

Renames the URL query parameter key from tab to status in the StatusTabPanel component and its tests. All router.push calls and unmountUntilVisible checks now use router.query.status; tests and mocks updated accordingly.

Changes

Cohort / File(s) Summary
StatusTabPanel implementation & tests
apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.tsx, apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.spec.tsx
Replaced query key tabstatus. Updated router.push to use { query: { status: ... } } and adjusted unmountUntilVisible conditions and test router mocks/assertions to reference router.query.status.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • Kneesal
🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ⚠️ Warning The PR title mentions 'unarchive option in archived template library', but the actual changes involve renaming query parameter keys from 'tab' to 'status' in StatusTabPanel component files, unrelated to unarchive functionality. Update the title to reflect the actual changes, such as 'refactor: rename tab query parameter to status in StatusTabPanel' to accurately describe the query parameter refactoring being made.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jaychen/nes-1186-check-for-unarchive-option-in-template-library

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.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Jan 13, 2026

View your CI Pipeline Execution ↗ for commit 1587c94

Command Status Duration Result
nx run journeys-admin-e2e:e2e ✅ Succeeded 28s View ↗
nx run-many --target=vercel-alias --projects=jo... ✅ Succeeded 2s View ↗
nx run-many --target=upload-sourcemaps --projec... ✅ Succeeded 22s View ↗
nx run-many --target=deploy --projects=journeys... ✅ Succeeded 2m 28s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-19 00:33:45 UTC

@github-actions github-actions Bot requested a deployment to Preview - journeys-admin January 13, 2026 03:54 Pending
@jaycnz jaycnz changed the title Jaychen/nes 1186 check for unarchive option in template library fix: unarchive option in archived template library Jan 13, 2026
Copy link
Copy Markdown
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: 0

Caution

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

⚠️ Outside diff range comments (5)
apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.tsx (1)

63-65: Bug: Incomplete migration from tab to status query parameter.

Line 64 still reads from router?.query?.tab while all other references have been updated to router?.query?.status. This breaks initial tab selection from URL - users navigating to ?status=archived will see the Active tab instead.

🐛 Proposed fix
  const tabIndex =
-   journeyStatusTabs.find((status) => status.queryParam === router?.query?.tab)
+   journeyStatusTabs.find((status) => status.queryParam === router?.query?.status)
      ?.tabIndex ?? 0
apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.spec.tsx (4)

16-19: Incomplete migration: Default router mock still uses tab.

The default mock should use status to align with the component's updated query parameter. While undefined may work, it's better to be consistent.

🐛 Proposed fix
 jest.mock('next/router', () => ({
   __esModule: true,
-  useRouter: jest.fn(() => ({ query: { tab: undefined } }))
+  useRouter: jest.fn(() => ({ query: { status: undefined } }))
 }))

94-120: Test will fail: Mock uses tab but component reads status.

This test verifies URL-based tab selection, but the mock still uses tab: 'archived' while the component now reads from router?.query?.status. The test will pass incorrectly (defaulting to Active tab) instead of verifying the Archived tab is selected.

🐛 Proposed fix
   it('should set active tab based on url query params', () => {
     mockedUseRouter.mockReturnValue({
       query: {
-        tab: 'archived'
+        status: 'archived'
       }
     } as unknown as NextRouter)

122-154: Test mock inconsistency: Uses tab instead of status.

The mock at line 127 uses tab: 'archived' but should use status: 'archived' for consistency with the component's updated query parameter reading.

🐛 Proposed fix
     mockedUseRouter.mockReturnValue({
       query: {
-        tab: 'archived'
+        status: 'archived'
       },
       push
     } as unknown as NextRouter)

156-190: Test mock inconsistency: Uses tab instead of status.

The mock at line 161 uses tab: 'active' but should use status: 'active' for consistency.

🐛 Proposed fix
     mockedUseRouter.mockReturnValue({
       query: {
-        tab: 'active'
+        status: 'active'
       },
       push
     } as unknown as NextRouter)
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ab58543 and af94adf.

📒 Files selected for processing (2)
  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.spec.tsx
  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.tsx
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/base.mdc)

**/*.{ts,tsx,js,jsx}: Use early returns whenever possible to make the code more readable.
Use descriptive variable and function/const names.
Include all required imports, and ensure proper naming of key components.

Files:

  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.tsx
  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.spec.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/base.mdc)

Define a type if possible.

Files:

  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.tsx
  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.spec.tsx
apps/**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/apps.mdc)

apps/**/*.{js,jsx,ts,tsx}: Always use MUI over HTML elements; avoid using CSS or tags.
Use descriptive variable and function/const names. Also, event functions should be named with a “handle” prefix, like “handleClick” for onClick and “handleKeyDown” for onKeyDown.
Implement accessibility features on elements. For example, a tag should have a tabindex=“0”, aria-label, on:click, and on:keydown, and similar attributes.

Files:

  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.tsx
  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.spec.tsx
🧠 Learnings (6)
📚 Learning: 2025-12-19T04:58:24.460Z
Learnt from: CR
Repo: JesusFilm/core PR: 0
File: apps/watch/AGENTS.md:0-0
Timestamp: 2025-12-19T04:58:24.460Z
Learning: Applies to apps/watch/src/**/*.spec.{ts,tsx} : Co-locate React Testing Library specs under `*.spec.ts(x)` and mock network traffic with MSW handlers in `apps/watch/test`.

Applied to files:

  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.spec.tsx
📚 Learning: 2025-12-19T04:58:24.460Z
Learnt from: CR
Repo: JesusFilm/core PR: 0
File: apps/watch/AGENTS.md:0-0
Timestamp: 2025-12-19T04:58:24.460Z
Learning: Applies to apps/watch/src/**/*.spec.{ts,tsx} : Enclose SWR-based hooks in `TestSWRConfig` (`apps/watch/test/TestSWRConfig.tsx`) to isolate cache state between assertions in tests.

Applied to files:

  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.spec.tsx
📚 Learning: 2025-12-19T19:18:43.790Z
Learnt from: CR
Repo: JesusFilm/core PR: 0
File: apps/resources/AGENTS.md:0-0
Timestamp: 2025-12-19T19:18:43.790Z
Learning: Applies to apps/resources/**/*.spec.ts?(x) : Enclose SWR-based hooks in `TestSWRConfig` (`apps/resources/test/TestSWRConfig.tsx`) to isolate cache state between assertions

Applied to files:

  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.spec.tsx
📚 Learning: 2025-12-19T19:18:43.790Z
Learnt from: CR
Repo: JesusFilm/core PR: 0
File: apps/resources/AGENTS.md:0-0
Timestamp: 2025-12-19T19:18:43.790Z
Learning: Applies to apps/resources/**/*.spec.ts?(x) : Co-locate React Testing Library specs under `*.spec.ts(x)` and mock network traffic with MSW handlers in `apps/resources/test`

Applied to files:

  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.spec.tsx
📚 Learning: 2025-12-19T04:58:24.460Z
Learnt from: CR
Repo: JesusFilm/core PR: 0
File: apps/watch/AGENTS.md:0-0
Timestamp: 2025-12-19T04:58:24.460Z
Learning: Applies to apps/watch/src/**/*.spec.{ts,tsx} : Use the shared Jest setup in `apps/watch/setupTests.tsx` which already boots MSW, Next router mock, and has a longer async timeout.

Applied to files:

  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.spec.tsx
📚 Learning: 2025-12-19T19:18:43.790Z
Learnt from: CR
Repo: JesusFilm/core PR: 0
File: apps/resources/AGENTS.md:0-0
Timestamp: 2025-12-19T19:18:43.790Z
Learning: Applies to apps/resources/**/*.spec.ts?(x) : Wrap component specs with `MockedProvider`, `VideoProvider`, and `WatchProvider` when the unit touches those contexts—`NewVideoContentPage.spec.tsx` shows the expected harness

Applied to files:

  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.spec.tsx
⏰ 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: Deploy Preview (journeys-admin, 8585/merge, pull_request, 22)
  • GitHub Check: build (22)
  • GitHub Check: test (22, 2/3)
  • GitHub Check: test (22, 1/3)
  • GitHub Check: test (22, 3/3)
  • GitHub Check: lint (22)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.tsx (2)

89-95: LGTM!

The router.push call correctly uses the new status query parameter.


146-171: LGTM!

The unmountUntilVisible conditions for all three TabPanel instances correctly reference router?.query?.status.

apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.spec.tsx (1)

192-226: LGTM!

This test correctly uses status: 'active' in the mock and verifies the push call with status: 'trashed'.

@github-actions github-actions Bot temporarily deployed to Preview - journeys-admin January 13, 2026 03:57 Inactive
Copy link
Copy Markdown
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: 0

Caution

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

⚠️ Outside diff range comments (1)
apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.tsx (1)

63-65: Bug: Incomplete refactor - still using tab instead of status.

The initial tabIndex calculation still references router?.query?.tab, but router.push on line 91 now writes to status, and the unmountUntilVisible checks also use status. This causes the initial tab selection to fail when navigating directly to a URL like ?status=archived.

🐛 Proposed fix
  const tabIndex =
-   journeyStatusTabs.find((status) => status.queryParam === router?.query?.tab)
+   journeyStatusTabs.find((status) => status.queryParam === router?.query?.status)
      ?.tabIndex ?? 0
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between af94adf and 91a21e1.

📒 Files selected for processing (2)
  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.spec.tsx
  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.spec.tsx
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/base.mdc)

**/*.{ts,tsx,js,jsx}: Use early returns whenever possible to make the code more readable.
Use descriptive variable and function/const names.
Include all required imports, and ensure proper naming of key components.

Files:

  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/base.mdc)

Define a type if possible.

Files:

  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.tsx
apps/**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/apps.mdc)

apps/**/*.{js,jsx,ts,tsx}: Always use MUI over HTML elements; avoid using CSS or tags.
Use descriptive variable and function/const names. Also, event functions should be named with a “handle” prefix, like “handleClick” for onClick and “handleKeyDown” for onKeyDown.
Implement accessibility features on elements. For example, a tag should have a tabindex=“0”, aria-label, on:click, and on:keydown, and similar attributes.

Files:

  • apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.tsx
⏰ 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). (5)
  • GitHub Check: Deploy Preview (journeys-admin, 8585/merge, pull_request, 22)
  • GitHub Check: test (22, 2/3)
  • GitHub Check: build (22)
  • GitHub Check: lint (22)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
apps/journeys-admin/src/components/StatusTabPanel/StatusTabPanel.tsx (2)

89-95: LGTM!

The query parameter rename from tab to status in the router push is correct.


150-172: LGTM!

The unmountUntilVisible logic is consistent:

  • Active panel mounts when status is undefined or 'active' (default behavior)
  • Archived/Trashed panels mount only when their respective status values are set

This correctly implements the status-based tab visibility.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 13, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys-admin ✅ Ready journeys-admin preview Mon Jan 19 13:30:46 NZDT 2026

@edmonday edmonday changed the title fix: unarchive option in archived template library fix: unarchive option in archived template library Jan 13, 2026
@github-actions github-actions Bot temporarily deployed to Preview - journeys-admin January 19, 2026 00:26 Inactive
@jaycnz jaycnz added this pull request to the merge queue Jan 19, 2026
Merged via the queue into main with commit 0a4ad18 Jan 19, 2026
20 checks passed
@jaycnz jaycnz deleted the jaychen/nes-1186-check-for-unarchive-option-in-template-library branch January 19, 2026 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug effort: 2 type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants