fix: refactor CreateJourneyButton to use new journey duplication and…#6813
Conversation
… 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.
|
""" WalkthroughThis update refactors the journey duplication and translation workflow in the Changes
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
Possibly related PRs
Suggested reviewers
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
npm warn EBADENGINE Unsupported engine { 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (8)
✨ Finishing Touches
🧪 Generate Unit Tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
libs/journeys/ui/src/components/TemplateView/CreateJourneyButton/CreateJourneyButton.spec.tsx (1)
621-623: Passundefinedinstead of an empty object
<JourneyProvider value={{}}>…hands the provider a partial object that may violate its run-time expectations if it assumesvalue.journeyexists.
Replace withvalue={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 usersThe catch branch always shows the generic
t('Journey duplication failed'), discardingerror.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
📒 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 thatonCompleteis supported for subscriptions
useJourneyAiTranslateSubscriptionis wired withonComplete, but Apollo’suseSubscriptiononly exposesonData/onError.
IfonCompleteisn’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
onDatawith aprogress === 100guard.
… 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.
… translation logic
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Tests
Documentation