Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: ln support modules constants #6428

Merged
merged 4 commits into from
Jan 27, 2025
Merged

Conversation

gakshita
Copy link
Collaborator

@gakshita gakshita commented Jan 20, 2025

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

References

Summary by CodeRabbit

  • Internationalization

    • Added support for translating module status, layouts, and order-by options.
    • Updated various components to use translation hooks for dynamic text rendering.
  • Constants Refactoring

    • Moved module-related constants to a centralized @plane/constants package.
    • Updated import statements across multiple components.
  • Localization

    • Added English translations for project module statuses, layouts, and sorting options.
    • Implemented dynamic label resolution for improved multi-language support.
  • New Features

    • Introduced a new ModuleLayoutIcon component for flexible layout icon rendering.

Copy link
Contributor

coderabbitai bot commented Jan 20, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request introduces significant internationalization (i18n) enhancements across various components and files. The changes focus on updating module-related components to support dynamic translation of labels, statuses, and layout options. Modifications include adding new export statements, integrating the useTranslation hook, and replacing hardcoded strings with translatable keys. Additionally, there are improvements to constants and import management throughout the project.

Changes

File Path Change Summary
packages/constants/src/index.ts Added new export statement for module exports
packages/constants/src/module.ts Replaced hardcoded labels with localization keys
packages/i18n/src/locales/en/translations.json Added new translation keys for project modules
web/core/components/modules/* Updated multiple components to use translation hook and new constants
web/core/components/modules/module-layout-icon.tsx Introduced new component for layout icons
web/core/components/modules/index.ts Added export statement for module-layout-icon

Sequence Diagram

sequenceDiagram
    participant User
    participant Component
    participant TranslationHook
    participant TranslationFile

    User->>Component: Interact with module
    Component->>TranslationHook: Request translation
    TranslationHook->>TranslationFile: Fetch translation key
    TranslationFile-->>TranslationHook: Return translated text
    TranslationHook-->>Component: Provide translated label
    Component->>User: Display localized content
Loading

Possibly related PRs

Suggested labels

🌐frontend, 🧹chore, 🌟improvement

Suggested reviewers

  • rahulramesha
  • sriramveeraghanta

Poem

🐰 Hop, hop, internationalize!
Constants dance, labels rise
Translations bloom like spring's surprise
From hardcoded text to global wise
Code rabbits rejoice, localization flies! 🌍


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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.

Copy link
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: 3

🔭 Outside diff range comments (1)
web/core/components/modules/dropdowns/order-by.tsx (1)

Line range hint 62-77: Add translation for sort order labels

The "Ascending" and "Descending" strings should be translated for consistency with other labels.

- Ascending
+ {t("common.sort_order.ascending")}
- Descending
+ {t("common.sort_order.descending")}
🧹 Nitpick comments (5)
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/modules/(list)/mobile-header.tsx (1)

Line range hint 31-32: Use strict equality comparison.

Replace loose equality (==) with strict equality (===) for type-safe comparisons.

-          if (layout.key == "gantt") return;
+          if (layout.key === "gantt") return;
web/core/components/modules/module-status-dropdown.tsx (1)

33-33: Improve operator precedence clarity

The parentheses grouping could be clearer. Consider restructuring for better readability:

- {(moduleStatus && t(moduleStatus?.label)) ?? t("project_modules.status.backlog")}
+ {moduleStatus ? t(moduleStatus.label) : t("project_modules.status.backlog")}
web/core/components/modules/select/status.tsx (1)

40-42: Simplify conditional rendering

The nested ternary with optional chaining could be simplified for better readability:

- {(selectedValue && t(selectedValue?.label)) ?? (
-   <span className={`${error ? "text-red-500" : "text-custom-text-200"}`}>Status</span>
- )}
+ {selectedValue ? t(selectedValue.label) : (
+   <span className={`${error ? "text-red-500" : "text-custom-text-200"}`}>Status</span>
+ )}
web/core/components/modules/sidebar-select/select-status.tsx (1)

41-42: Simplify color styling logic

The find operation could be stored in a variable to avoid repetition and improve readability.

+ const selectedStatus = MODULE_STATUS?.find((option) => option.value === value);
  <span
    className="h-2 w-2 flex-shrink-0 rounded-full"
    style={{
-     backgroundColor: MODULE_STATUS?.find((option) => option.value === value)?.color,
+     backgroundColor: selectedStatus?.color,
    }}
  />
packages/i18n/src/locales/en/translations.json (1)

320-342: LGTM! Well-structured translation keys for module-related content.

The translation structure is well-organized and follows a logical hierarchy. The translations are clear and match the keys used in the constants.

However, consider adding descriptions or context for translators to better understand where and how these strings are used.

Add translator comments like this:

   "project_modules": {
+    // @context: These are the different states a project module can be in
     "status": {
       "backlog": "Backlog",
       "planned": "Planned",
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 13cc8b0 and 3072ced.

📒 Files selected for processing (17)
  • packages/constants/src/index.ts (1 hunks)
  • packages/constants/src/module.ts (2 hunks)
  • packages/i18n/src/locales/en/translations.json (1 hunks)
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/modules/(list)/mobile-header.tsx (2 hunks)
  • web/core/components/modules/analytics-sidebar/root.tsx (5 hunks)
  • web/core/components/modules/applied-filters/status.tsx (3 hunks)
  • web/core/components/modules/dropdowns/filters/status.tsx (3 hunks)
  • web/core/components/modules/dropdowns/order-by.tsx (4 hunks)
  • web/core/components/modules/gantt-chart/blocks.tsx (1 hunks)
  • web/core/components/modules/module-card-item.tsx (1 hunks)
  • web/core/components/modules/module-list-item-action.tsx (1 hunks)
  • web/core/components/modules/module-status-dropdown.tsx (1 hunks)
  • web/core/components/modules/module-view-header.tsx (4 hunks)
  • web/core/components/modules/select/status.tsx (2 hunks)
  • web/core/components/modules/sidebar-select/select-status.tsx (2 hunks)
  • web/core/components/stickies/layout/stickies-list.tsx (1 hunks)
  • web/core/constants/empty-state.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • web/core/constants/empty-state.tsx
  • web/core/components/stickies/layout/stickies-list.tsx
🔇 Additional comments (13)
packages/constants/src/index.ts (1)

17-17: LGTM! Clean addition of module exports.

The new export maintains the file's alphabetical ordering pattern and follows the established re-export structure.

web/core/components/modules/applied-filters/status.tsx (1)

6-7: Add fallback for missing translation keys.

The translation implementation looks good, but consider adding a fallback for missing translation keys to prevent displaying raw keys to users.

-            {t(statusDetails.label)}
+            {t(statusDetails.label, { defaultValue: statusDetails.label })}

Let's verify that all status label translation keys exist:

Also applies to: 19-19, 30-30

web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/modules/(list)/mobile-header.tsx (1)

40-40: Add fallback for missing translation keys.

Consider adding a fallback for missing translation keys:

-              <div className="text-custom-text-300">{t(layout.title)}</div>
+              <div className="text-custom-text-300">{t(layout.title, { defaultValue: layout.title })}</div>

Let's verify that all layout title translation keys exist:

web/core/components/modules/gantt-chart/blocks.tsx (1)

7-7: LGTM! Import path updated correctly.

The change to import MODULE_STATUS from @plane/constants aligns with the centralization of constants.

web/core/components/modules/module-list-item-action.tsx (1)

9-9: LGTM! Import path updated correctly.

The change to import MODULE_STATUS from @plane/constants maintains consistency with the centralized constants approach.

web/core/components/modules/module-view-header.tsx (1)

8-8: LGTM! Import updates and i18n integration look good.

The changes successfully:

  1. Update the import path for MODULE_VIEW_LAYOUTS
  2. Add i18n support for layout titles in tooltips

Also applies to: 11-11, 47-47, 169-169

web/core/components/modules/module-card-item.tsx (1)

9-9: LGTM! Import statement updated correctly.

The change properly imports both MODULE_STATUS and PROGRESS_STATE_GROUPS_DETAILS from @plane/constants, maintaining consistency with the centralized constants approach.

web/core/components/modules/analytics-sidebar/root.tsx (2)

21-22: LGTM! Import changes for i18n support.

The imports are correctly updated to use the centralized constants and i18n packages.


89-89: LGTM! Proper implementation of translations.

The translation hook is correctly initialized and used to translate module status labels.

Also applies to: 379-379, 392-392

packages/constants/src/module.ts (4)

3-7: LGTM! Improved type imports organization.

The type imports are now properly organized for better readability.


17-17: LGTM! Consistent translation keys for module statuses.

The status labels are correctly updated to use translation keys that match the structure in translations.json.

Also applies to: 24-24, 31-31, 38-38, 45-45, 52-52


60-64: LGTM! Layout titles updated for i18n support.

The layout titles are properly updated to use translation keys.

Also applies to: 68-68, 73-73, 78-78


82-85: LGTM! Order by options updated for i18n support.

The order by options are correctly updated to use translation keys.

Also applies to: 88-88, 92-92, 96-96, 100-100, 104-104, 108-108

Comment on lines +5 to +6
import { MODULE_STATUS } from "@plane/constants";
import { useTranslation } from "@plane/i18n";
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Translate "No matches found" message.

For consistency, the "No matches found" message should also be translated.

-            <p className="text-xs italic text-custom-text-400">No matches found</p>
+            <p className="text-xs italic text-custom-text-400">{t("no_matches_found")}</p>

Also, consider adding a fallback for missing translation keys:

-                title={t(status.label)}
+                title={t(status.label, { defaultValue: status.label })}

Also applies to: 22-22, 43-43, 46-46

Comment on lines +5 to +6
import { MODULE_VIEW_LAYOUTS } from "@plane/constants";
import { useTranslation } from "@plane/i18n";
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Translate "Layout" text.

For consistency, the "Layout" text should also be translated.

-            <span>Layout</span>
+            <span>{t("layout")}</span>

Also applies to: 13-13, 23-23

backgroundColor: MODULE_STATUS?.find((option) => option.value === value)?.color,
}}
/>
{watch("status")}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix status label translation

The status value is being displayed directly without translation. This should use the translated label from MODULE_STATUS.

- {watch("status")}
+ {value ? t(MODULE_STATUS.find((option) => option.value === value)?.label ?? "") : "Status"}

Committable suggestion skipped: line range outside the PR's diff.

Copy link
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

♻️ Duplicate comments (1)
web/core/components/modules/dropdowns/filters/status.tsx (1)

43-46: 🛠️ Refactor suggestion

Complete the internationalization implementation.

The "No matches found" message is still hardcoded and translation keys lack fallbacks.

-                title={t(status.i18n_label)}
+                title={t(status.i18n_label, { defaultValue: status.value })}
             ))
           ) : (
-            <p className="text-xs italic text-custom-text-400">No matches found</p>
+            <p className="text-xs italic text-custom-text-400">
+              {t("common.no_matches_found", { defaultValue: "No matches found" })}
+            </p>
🧹 Nitpick comments (2)
web/core/components/modules/module-layout-icon.tsx (1)

14-38: Consider performance optimization opportunities.

The component could benefit from:

  1. Adding prop validation for the size prop to ensure positive numbers
  2. Memoizing the component to prevent unnecessary re-renders
-export const ModuleLayoutIcon: React.FC<ILayoutIcon> = (props) => {
+export const ModuleLayoutIcon: React.FC<ILayoutIcon> = React.memo((props) => {
   const { layoutType, className = "", containerClassName = "", size = 14, withContainer = false } = props;
+  
+  if (size <= 0) {
+    console.warn('ModuleLayoutIcon: size prop must be positive');
+    return null;
+  }

   // rest of the implementation...
-};
+});
+
+ModuleLayoutIcon.displayName = 'ModuleLayoutIcon';
packages/constants/src/module.ts (1)

65-73: Consider more specific translation keys for layouts.

The layout translation keys could be more specific to differentiate between title and description.

-    i18n_title: "project_modules.layout.list",
+    i18n_title: "project_modules.layout.list.title",

-    i18n_title: "project_modules.layout.board",
+    i18n_title: "project_modules.layout.board.title",

-    i18n_title: "project_modules.layout.timeline",
+    i18n_title: "project_modules.layout.timeline.title",

This change would allow for adding descriptions later without key conflicts:

// Future addition example:
i18n_description: "project_modules.layout.list.description"
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3072ced and f8dc1bd.

📒 Files selected for processing (12)
  • packages/constants/src/module.ts (1 hunks)
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/modules/(list)/mobile-header.tsx (2 hunks)
  • web/core/components/modules/analytics-sidebar/root.tsx (5 hunks)
  • web/core/components/modules/applied-filters/status.tsx (3 hunks)
  • web/core/components/modules/dropdowns/filters/status.tsx (3 hunks)
  • web/core/components/modules/dropdowns/order-by.tsx (4 hunks)
  • web/core/components/modules/index.ts (1 hunks)
  • web/core/components/modules/module-layout-icon.tsx (1 hunks)
  • web/core/components/modules/module-status-dropdown.tsx (1 hunks)
  • web/core/components/modules/module-view-header.tsx (5 hunks)
  • web/core/components/modules/select/status.tsx (2 hunks)
  • web/core/components/modules/sidebar-select/select-status.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • web/core/components/modules/module-status-dropdown.tsx
  • web/core/components/modules/select/status.tsx
  • web/core/components/modules/analytics-sidebar/root.tsx
  • web/core/components/modules/module-view-header.tsx
  • web/core/components/modules/sidebar-select/select-status.tsx
  • web/core/components/modules/applied-filters/status.tsx
  • web/core/components/modules/dropdowns/order-by.tsx
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/modules/(list)/mobile-header.tsx
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: lint-admin
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (3)
web/core/components/modules/index.ts (1)

17-17: LGTM! Export statement follows existing pattern.

The new export for module-layout-icon is correctly placed and maintains consistency with the existing export structure.

web/core/components/modules/module-layout-icon.tsx (1)

6-12: LGTM! Well-structured interface with clear prop types.

The interface is well-defined with appropriate optional properties and type safety.

packages/constants/src/module.ts (1)

16-56: LGTM! Consistent i18n implementation for module statuses.

The translation keys follow a clear hierarchical structure and maintain type safety while preserving the existing color schemes.

@gakshita gakshita changed the base branch from preview to feat-language-support January 27, 2025 14:46
@gakshita gakshita merged commit 4cd94bb into feat-language-support Jan 27, 2025
7 of 11 checks passed
@gakshita gakshita deleted the chore-ln-module branch January 27, 2025 15:08
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.

2 participants