Skip to content

Conversation

@ChmaraX
Copy link
Contributor

@ChmaraX ChmaraX commented Jul 1, 2025

What changed? Why was the change needed?

Related Maily change: novuhq/maily.to#26

translation-variables.mov

Summary by CodeRabbit

  • New Features

    • Added support for managing translation keys in the email editor, including fetching, creating, and updating translation keys and values.
    • Introduced context-aware variable icons and lists that distinguish between variables and translations.
    • Implemented tooltips and error indicators for missing translation keys in the editor.
    • Added new hooks for translation key management and value updates.
  • Enhancements

    • Improved hover and tooltip interactions in variable lists for better user experience.
    • Translation suggestions now dynamically include creation options and improved navigation.
    • Enhanced feedback with success and error notifications for translation actions.
  • Bug Fixes

    • Improved handling of control characters in JSON strings to prevent parsing errors in email output rendering.
  • Refactor

    • Updated import sources and component names for clarity and maintainability.
    • Enhanced popover and tooltip positioning and validation logic for translation editing.
  • Chores

    • Updated core dependency version for improved compatibility.

@linear
Copy link

linear bot commented Jul 1, 2025

@netlify
Copy link

netlify bot commented Jul 1, 2025

Deploy Preview for dashboard-v2-novu-staging canceled.

Name Link
🔨 Latest commit 0c396f7
🔍 Latest deploy log https://app.netlify.com/projects/dashboard-v2-novu-staging/deploys/6863b8821be0d500083ddf87

@ChmaraX
Copy link
Contributor Author

ChmaraX commented Jul 1, 2025

@coderabbitai summary

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 1, 2025

✅ Actions performed

Summary regeneration triggered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 1, 2025

Walkthrough

This update introduces comprehensive translation key management features to the dashboard's email workflow editor. It adds hooks for fetching, creating, and updating translation keys and values, integrates translation key suggestions and validation into the UI, and refines tooltip and hover interactions. Several components and hooks are refactored or extended to support dynamic translation workflows.

Changes

File(s) / Area Change Summary
apps/api/src/app/environments-v1/usecases/output-renderers/email-output-renderer.usecase.ts Added method to escape control characters in translated JSON strings before parsing.
apps/dashboard/package.json Updated @maily-to/core dependency version.
apps/dashboard/src/api/translations.ts
apps/dashboard/src/hooks/use-fetch-translation.ts
apps/dashboard/src/hooks/use-fetch-translations.ts
Changed import source for LocalizationResourceEnum to a local type definition.
apps/dashboard/src/components/icons/translate-variable.tsx Renamed exported component from TranslateVariable to TranslateVariableIcon.
apps/dashboard/src/components/translations/types.ts Defined LocalizationResourceEnum locally.
apps/dashboard/src/components/variable/components/variable-icon.tsx Added context prop to VariableIcon for translation-aware rendering.
apps/dashboard/src/components/variable/variable-list.tsx Added context prop, improved hover/tooltip logic, and context-aware rendering to VariableList and VariableListItem.
apps/dashboard/src/components/workflow-editor/steps/email/maily-config.tsx Extended createExtensions function to support translation keys and creation callback.
apps/dashboard/src/components/workflow-editor/steps/email/maily.tsx Integrated translation key fetching, creation, and state into the email editor; updated extension memoization.
apps/dashboard/src/components/workflow-editor/steps/email/translations/edit-translation-popover.tsx Refactored to use async hooks for translation key/value management, debounced saving, improved popover and validation logic.
apps/dashboard/src/components/workflow-editor/steps/email/translations/translation-decorator.tsx Enhanced extension to support dynamic translation keys, creation, and custom suggestion UI.
apps/dashboard/src/components/workflow-editor/steps/email/translations/translation-pill.tsx Added translation key existence validation, error display, and updated prop/data flow.
apps/dashboard/src/components/workflow-editor/steps/email/translations/translation-suggestions-list-view.tsx Introduced new component for translation key suggestions with keyboard navigation and new key preview.
apps/dashboard/src/components/workflow-editor/steps/email/translations/translation-tooltip.tsx Added new tooltip component for translation errors.
apps/dashboard/src/components/workflow-editor/steps/email/views/maily-variables-list-view.tsx Passed context="variables" to VariableList.
apps/dashboard/src/hooks/use-create-translation-key.ts Added hook for creating translation keys with nested support and cache invalidation.
apps/dashboard/src/hooks/use-fetch-translation-keys.ts Added hook for fetching and processing translation keys for a workflow.
apps/dashboard/src/hooks/use-save-translation.ts Enhanced to invalidate translation key queries and show user feedback on save.
apps/dashboard/src/hooks/use-update-translation-value.ts Added hook for updating translation values with cache invalidation and error handling.
apps/dashboard/src/utils/query-keys.ts Added fetchTranslationKeys constant to exported query keys.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Editor as Email Editor
    participant Hooks
    participant API
    participant UI as UI Components

    User->>Editor: Opens email workflow editor
    Editor->>Hooks: useFetchTranslationKeys (workflowId)
    Hooks->>API: Fetch translation keys for workflow
    API-->>Hooks: Return translation keys
    Hooks-->>Editor: Provide translation keys

    User->>UI: Types new translation key
    UI->>Hooks: useCreateTranslationKey (workflowId, key)
    Hooks->>API: Create translation key in backend
    API-->>Hooks: Confirm creation
    Hooks-->>UI: Invalidate caches, show toast

    User->>UI: Edits translation value
    UI->>Hooks: useUpdateTranslationValue (workflowId, key, value)
    Hooks->>API: Update translation value
    API-->>Hooks: Confirm update
    Hooks-->>UI: Invalidate caches, show toast

    UI->>User: Shows updated translation key/value, tooltips, and suggestions
Loading

Suggested reviewers

  • scopsy
  • LetItRock

Poem

A rabbit hopped through code so bright,
With keys for words and translations light.
Suggestions pop and tooltips glow,
New hooks and lists in tidy rows.
From workflows deep, to emails sent—
This bunny’s joy is evident!
🐇✨


📜 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 bf0fa14 and 281417b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (22)
  • apps/api/src/app/environments-v1/usecases/output-renderers/email-output-renderer.usecase.ts (2 hunks)
  • apps/dashboard/package.json (1 hunks)
  • apps/dashboard/src/api/translations.ts (1 hunks)
  • apps/dashboard/src/components/icons/translate-variable.tsx (1 hunks)
  • apps/dashboard/src/components/translations/types.ts (1 hunks)
  • apps/dashboard/src/components/variable/components/variable-icon.tsx (2 hunks)
  • apps/dashboard/src/components/variable/variable-list.tsx (5 hunks)
  • apps/dashboard/src/components/workflow-editor/steps/email/maily-config.tsx (2 hunks)
  • apps/dashboard/src/components/workflow-editor/steps/email/maily.tsx (4 hunks)
  • apps/dashboard/src/components/workflow-editor/steps/email/translations/edit-translation-popover.tsx (8 hunks)
  • apps/dashboard/src/components/workflow-editor/steps/email/translations/translation-decorator.tsx (2 hunks)
  • apps/dashboard/src/components/workflow-editor/steps/email/translations/translation-pill.tsx (2 hunks)
  • apps/dashboard/src/components/workflow-editor/steps/email/translations/translation-suggestions-list-view.tsx (1 hunks)
  • apps/dashboard/src/components/workflow-editor/steps/email/translations/translation-tooltip.tsx (1 hunks)
  • apps/dashboard/src/components/workflow-editor/steps/email/views/maily-variables-list-view.tsx (1 hunks)
  • apps/dashboard/src/hooks/use-create-translation-key.ts (1 hunks)
  • apps/dashboard/src/hooks/use-fetch-translation-keys.ts (1 hunks)
  • apps/dashboard/src/hooks/use-fetch-translation.ts (1 hunks)
  • apps/dashboard/src/hooks/use-fetch-translations.ts (1 hunks)
  • apps/dashboard/src/hooks/use-save-translation.ts (2 hunks)
  • apps/dashboard/src/hooks/use-update-translation-value.ts (1 hunks)
  • apps/dashboard/src/utils/query-keys.ts (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

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 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.

Comment on lines +167 to +181
const handleMouseLeave = () => {
// Small delay to allow moving to tooltip
timeoutRef.current = setTimeout(() => {
setHoveredOptionIndex(-1);
}, 150);
};

const handleMouseEnter = () => {
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
timeoutRef.current = null;
}

setHoveredOptionIndex(index);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any other way of handling this maybe? Usually those mouseleave things are creating troubles down the read. What is the issue we try to solve with this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue is that we need to display a tooltip with a link to translation page, therefore user should be able to actually click it.

I also don't like timeouts, there might be a more elegant way but that would require changing / creating new component for that, figuring out how to make it works and then apply it to all places where the component is used etc. I will try to revisit when there are no more higher priority items.

@ChmaraX ChmaraX merged commit a375d38 into next Jul 1, 2025
31 checks passed
@ChmaraX ChmaraX deleted the nv-6188-dashboard-add-keyvalue-pairs-from-editor-to-translation-json branch July 1, 2025 11:02
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jul 2, 2025

Open in StackBlitz

npm i https://pkg.pr.new/novuhq/novu@8615
npm i https://pkg.pr.new/novuhq/novu/@novu/providers@8615
npm i https://pkg.pr.new/novuhq/novu/@novu/shared@8615

commit: 942ba29

bricehemery pushed a commit to jack-agency/novu that referenced this pull request Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants