Skip to content

fix: refactor CreateJourneyButton to use new journey duplication and…#6813

Merged
mikeallisonJS merged 4 commits into
mainfrom
mikeallison/nes-438-fix-for-template-translation
Jun 13, 2025
Merged

fix: refactor CreateJourneyButton to use new journey duplication and…#6813
mikeallisonJS merged 4 commits into
mainfrom
mikeallison/nes-438-fix-for-template-translation

Conversation

@mikeallisonJS
Copy link
Copy Markdown
Collaborator

@mikeallisonJS mikeallisonJS commented Jun 13, 2025

… translation logic

  • Removed the deprecated useJourneyDuplicateAndTranslate hook.
  • Integrated journey duplication and translation handling directly in CreateJourneyButton.
  • Added Snackbar notifications for success and error states during journey duplication and translation.
  • Implemented subscription for real-time translation updates.
  • Updated tests to cover new functionality and ensure proper dialog handling.

Summary by CodeRabbit

  • New Features

    • Improved journey duplication and translation process with clearer user feedback and progress indicators.
    • Translation progress is now observable, with notifications for success and errors.
  • Bug Fixes

    • Enhanced error handling and user notifications during journey duplication and translation.
  • Refactor

    • Streamlined internal logic for duplicating and translating journeys, resulting in a more reliable and transparent workflow.
    • Removed deprecated duplication and translation hook to simplify codebase.
  • Tests

    • Expanded test coverage for journey duplication and translation scenarios, including UI feedback and dialog interactions.
  • Documentation

    • Updated and consolidated translation keys for clearer and more consistent user messages.

… translation logic

- Removed the deprecated useJourneyDuplicateAndTranslate hook.
- Integrated journey duplication and translation handling directly in CreateJourneyButton.
- Added Snackbar notifications for success and error states during journey duplication and translation.
- Implemented subscription for real-time translation updates.
- Updated tests to cover new functionality and ensure proper dialog handling.
@mikeallisonJS mikeallisonJS requested a review from tanflem June 13, 2025 20:27
@mikeallisonJS mikeallisonJS self-assigned this Jun 13, 2025
@linear
Copy link
Copy Markdown

linear Bot commented Jun 13, 2025

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 13, 2025

"""

Walkthrough

This update refactors the journey duplication and translation workflow in the CreateJourneyButton component. It removes the combined useJourneyDuplicateAndTranslate hook, replacing it with explicit mutation and subscription hooks. The test suite is expanded to cover new duplication and translation scenarios, and localization keys are consolidated.

Changes

File(s) Change Summary
libs/journeys/ui/src/components/TemplateView/CreateJourneyButton/CreateJourneyButton.tsx Refactored to use separate mutation and subscription hooks for duplication and translation; updated state management and UI feedback logic.
libs/journeys/ui/src/components/TemplateView/CreateJourneyButton/CreateJourneyButton.spec.tsx Enhanced tests with new cases for duplication and translation; added mocks and providers for fidelity.
libs/journeys/ui/src/libs/useJourneyDuplicateAndTranslate/index.ts
libs/journeys/ui/src/libs/useJourneyDuplicateAndTranslate/useJourneyDuplicateAndTranslate.ts
Deleted the combined journey duplication and translation hook and its export.
libs/locales/en/libs-journeys-ui.json Consolidated and reorganized translation keys; removed duplicates.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CreateJourneyButton
    participant JourneyDuplicateMutation
    participant JourneyAiTranslateSubscription
    participant Snackbar
    participant Router

    User->>CreateJourneyButton: Click "Duplicate" (with/without translation)
    CreateJourneyButton->>JourneyDuplicateMutation: Duplicate journey
    JourneyDuplicateMutation-->>CreateJourneyButton: Return duplicated journey ID
    alt Translation requested
        CreateJourneyButton->>JourneyAiTranslateSubscription: Subscribe to translation
        JourneyAiTranslateSubscription-->>CreateJourneyButton: Translation complete/error
        CreateJourneyButton->>Snackbar: Show translation result
        CreateJourneyButton->>Router: Navigate to duplicated journey
    else No translation
        CreateJourneyButton->>Snackbar: Show duplication success
        CreateJourneyButton->>Router: Navigate to duplicated journey
    end
Loading

Possibly related PRs

  • JesusFilm/core#6689: Introduces the original useJourneyDuplicateAndTranslate hook and integrates it into CreateJourneyButton, which is now being refactored in this PR.
  • JesusFilm/core#6543: Adds a "Translate" menu item and dialog for journey translation, related to the translation workflow now refactored in this PR.

Suggested reviewers

  • mikeallisonJS
  • edmonday
    """

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm warn EBADENGINE Unsupported engine {
npm warn EBADENGINE package: 'i18next-parser@9.3.0',
npm warn EBADENGINE required: { node: '^18.0.0 || ^20.0.0 || ^22.0.0', npm: '>=6', yarn: '>=1' },
npm warn EBADENGINE current: { node: 'v24.2.0', npm: '11.3.0' }
npm warn EBADENGINE }
npm warn EBADENGINE Unsupported engine {
npm warn EBADENGINE package: 'next-firebase-auth-edge@1.9.1',
npm warn EBADENGINE required: {
npm warn EBADENGINE node: '>=16.0.0 <24.0.0',
npm warn EBADENGINE npm: '>=8.0.0 <12.0.0',
npm warn EBADENGINE yarn: '>=1.22.0 <2.0.0'
npm warn EBADENGINE },
npm warn EBADENGINE current: { node: 'v24.2.0', npm: '11.3.0' }
npm warn EBADENGINE }
npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-13T20_53_54_515Z-debug-0.log


📜 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 bfaa88b and 5d56b71.

📒 Files selected for processing (1)
  • libs/journeys/ui/src/components/TemplateView/CreateJourneyButton/CreateJourneyButton.spec.tsx (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • libs/journeys/ui/src/components/TemplateView/CreateJourneyButton/CreateJourneyButton.spec.tsx
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: affected (22)
  • GitHub Check: build (22)
  • GitHub Check: test (22, 2/3)
  • GitHub Check: test (22, 3/3)
  • GitHub Check: test (22, 1/3)
  • GitHub Check: visual-test (22)
  • GitHub Check: lint (22)
  • GitHub Check: Analyze (javascript)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Commit Unit Tests in branch mikeallison/nes-438-fix-for-template-translation
  • Post Copyable Unit Tests in Comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions Bot temporarily deployed to Preview - videos-admin June 13, 2025 20:29 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - journeys June 13, 2025 20:29 Inactive
@github-actions github-actions Bot requested a deployment to Preview - journeys-admin June 13, 2025 20:29 Pending
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 13, 2025

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys ✅ Ready journeys preview Sat Jun 14 08:55:51 NZST 2025

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 13, 2025

The latest updates on your projects.

Name Status Preview Updated (UTC)
videos-admin ✅ Ready videos-admin preview Sat Jun 14 08:55:58 NZST 2025

@github-actions github-actions Bot temporarily deployed to Preview - journeys June 13, 2025 20:34 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - videos-admin June 13, 2025 20:34 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - journeys-admin June 13, 2025 20:34 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - watch June 13, 2025 20:34 Inactive
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 13, 2025

The latest updates on your projects.

Name Status Preview Updated (UTC)
watch ✅ Ready watch preview Sat Jun 14 08:56:21 NZST 2025

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 13, 2025

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys-admin ✅ Ready journeys-admin preview Sat Jun 14 08:56:40 NZST 2025

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

🧹 Nitpick comments (2)
libs/journeys/ui/src/components/TemplateView/CreateJourneyButton/CreateJourneyButton.spec.tsx (1)

621-623: Pass undefined instead of an empty object

<JourneyProvider value={{}}>… hands the provider a partial object that may violate its run-time expectations if it assumes value.journey exists.
Replace with value={undefined} (or omit the prop) to avoid brittle tests.

libs/journeys/ui/src/components/TemplateView/CreateJourneyButton/CreateJourneyButton.tsx (1)

154-160: Expose the real error message to users

The catch branch always shows the generic t('Journey duplication failed'), discarding error.message.
Including the underlying message will aid debugging:

- enqueueSnackbar(t('Journey duplication failed'), {
+ enqueueSnackbar(
+   error instanceof Error ? error.message : t('Journey duplication failed'),
+   {
     variant: 'error',
     preventDuplicate: true
   }
 )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 498ad61 and 510651b.

📒 Files selected for processing (5)
  • libs/journeys/ui/src/components/TemplateView/CreateJourneyButton/CreateJourneyButton.spec.tsx (10 hunks)
  • libs/journeys/ui/src/components/TemplateView/CreateJourneyButton/CreateJourneyButton.tsx (5 hunks)
  • libs/journeys/ui/src/libs/useJourneyDuplicateAndTranslate/index.ts (0 hunks)
  • libs/journeys/ui/src/libs/useJourneyDuplicateAndTranslate/useJourneyDuplicateAndTranslate.ts (0 hunks)
  • libs/locales/en/libs-journeys-ui.json (1 hunks)
💤 Files with no reviewable changes (2)
  • libs/journeys/ui/src/libs/useJourneyDuplicateAndTranslate/index.ts
  • libs/journeys/ui/src/libs/useJourneyDuplicateAndTranslate/useJourneyDuplicateAndTranslate.ts
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: test (22, 3/3)
  • GitHub Check: build (22)
  • GitHub Check: test (22, 2/3)
  • GitHub Check: test (22, 1/3)
  • GitHub Check: visual-test (22)
  • GitHub Check: lint (22)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
libs/locales/en/libs-journeys-ui.json (1)

47-49: Translation keys look good
No issues spotted with the added strings. ✔️

libs/journeys/ui/src/components/TemplateView/CreateJourneyButton/CreateJourneyButton.tsx (1)

60-86: Verify that onComplete is supported for subscriptions

useJourneyAiTranslateSubscription is wired with onComplete, but Apollo’s useSubscription only exposes onData / onError.
If onComplete isn’t forwarded, the success branch (snackbar + navigation) will never fire and users will be stuck on the dialog.

Please double-check the custom hook’s signature or switch to onData with a progress === 100 guard.

… additional team properties

- Added UserTeamRole to the team mock data.
- Enhanced team structure in tests to include publicTitle and userTeams.
- Updated language mock to include slug for better test coverage.
- Removed outdated dialog close test for improved clarity.
@github-actions github-actions Bot requested a deployment to Preview - videos-admin June 13, 2025 20:49 Pending
@github-actions github-actions Bot requested a deployment to Preview - journeys-admin June 13, 2025 20:49 Pending
@github-actions github-actions Bot requested a deployment to Preview - journeys June 13, 2025 20:49 Pending
@github-actions github-actions Bot temporarily deployed to Preview - journeys June 13, 2025 20:53 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - videos-admin June 13, 2025 20:53 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - watch June 13, 2025 20:53 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - journeys-admin June 13, 2025 20:53 Inactive
@mikeallisonJS mikeallisonJS enabled auto-merge June 13, 2025 21:09
@mikeallisonJS mikeallisonJS disabled auto-merge June 13, 2025 21:35
@mikeallisonJS mikeallisonJS merged commit 8cb93ec into main Jun 13, 2025
25 checks passed
@mikeallisonJS mikeallisonJS deleted the mikeallison/nes-438-fix-for-template-translation branch June 13, 2025 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant