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

JNG-5946 fix row delete translation #465

Merged
merged 2 commits into from
Oct 1, 2024

Conversation

noherczeg
Copy link
Contributor

@noherczeg noherczeg commented Oct 1, 2024

BugJNG-5946 Translation of delete operation is missing from tables

Copy link

coderabbitai bot commented Oct 1, 2024

Walkthrough

The changes enhance the Judo UI React application by introducing new translation keys specifically for row deletion functionality. Modifications were made to the UiI18NHelper class to include these translations, and corresponding entries were added to the localization files for both English and Hungarian languages. The updates ensure that users receive appropriate feedback for row deletion actions, improving the overall user experience in the application.

Changes

Files Change Summary
.../judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiI18NHelper.java Updated methods to include handling and checks for row-delete action translations.
.../judo-ui-react/src/main/resources/actor/public/i18n/system_default.json.hbs Added new translation keys: "judo.action.row-delete" and "judo.action.row-delete.success".
.../judo-ui-react/src/main/resources/actor/public/i18n/system_en-US.json.hbs Added new translation keys: "judo.action.row-delete" and "judo.action.row-delete.success" with corresponding values.
.../judo-ui-react/src/main/resources/actor/public/i18n/system_hu-HU.json.hbs Added new translation keys: "judo.action.row-delete" and "judo.action.row-delete.success" with corresponding values in Hungarian.
.../judo-ui-react-itest/ActionGroupTestPro/action_group_test_pro__god/src/test/resources/snapshots/frontend-react/src/containers/View/Galaxy/Table/components/ViewGalaxyTableTableComponent/index.tsx.snapshot Updated row action label to use new translation key for delete action.

Poem

🐰 In the realm of code, where translations grow,
New keys for deletion, a delightful flow.
"Törlés" and "Delete," they dance with glee,
Enhancing the UI, as clear as can be!
With every click, a success we find,
A hop in our step, leaving worries behind! 🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 01f156c and be1711c.

📒 Files selected for processing (1)
  • judo-ui-react-itest/ActionGroupTestPro/action_group_test_pro__god/src/test/resources/snapshots/frontend-react/src/containers/View/Galaxy/Table/components/ViewGalaxyTableTableComponent/index.tsx.snapshot (1 hunks)
🔇 Additional comments (1)
judo-ui-react-itest/ActionGroupTestPro/action_group_test_pro__god/src/test/resources/snapshots/frontend-react/src/containers/View/Galaxy/Table/components/ViewGalaxyTableTableComponent/index.tsx.snapshot (1)

535-535: Improved internationalization for row delete action label.

The label for the row delete action has been updated to use a more generic translation key 'judo.action.row-delete' instead of 'View.Galaxy.Table.Delete'. This change improves the internationalization of the component by using a consistent key across the application for row deletion actions. The default value 'Delete' is retained, ensuring backwards compatibility.


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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

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

@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

🧹 Outside diff range and nitpick comments (5)
judo-ui-react/src/main/resources/actor/public/i18n/system_default.json.hbs (1)

24-25: LGTM! Consider a minor adjustment for consistency.

The new translation entries for row deletion are well-placed and consistent with the existing structure. They align perfectly with the PR objective of fixing row delete translation.

For improved consistency with other action translations, consider changing "Delete successful" to "Row delete successful". This would make it more specific and in line with the "row-delete" action.

Here's a suggested minor adjustment:

 "judo.action.row-delete": "Delete",
-"judo.action.row-delete.success": "Delete successful",
+"judo.action.row-delete.success": "Row delete successful",
judo-ui-react/src/main/resources/actor/public/i18n/system_en-US.json.hbs (1)

24-25: LGTM! Consider a minor enhancement for clarity.

The new translation keys "judo.action.row-delete" and "judo.action.row-delete.success" are well-integrated and consistent with the existing translations. They follow the established naming conventions and provide clear, concise translations.

To further improve clarity and maintain consistency with other similar keys, consider the following minor enhancement:

Consider changing "judo.action.row-delete.success" to "Row delete successful" instead of "Delete successful". This would make it more specific and consistent with the "row" context, similar to how you have "judo.action.create.success" as "Create successful".

 "judo.action.row-delete": "Delete",
-"judo.action.row-delete.success": "Delete successful",
+"judo.action.row-delete.success": "Row delete successful",

This change would make the success message more explicit about the specific action that was successful.

judo-ui-react/src/main/resources/actor/public/i18n/system_hu-HU.json.hbs (1)

24-25: LGTM! Consider a minor enhancement for clarity.

The new translation entries for row deletion are correct and consistent with the existing translations. They follow the established naming conventions and provide clear, concise Hungarian translations for the delete action and success message.

For even greater clarity, you might consider making the success message more specific to row deletion:

 "judo.action.row-delete": "Törlés",
-"judo.action.row-delete.success": "Sikeres törlés"
+"judo.action.row-delete.success": "Sor sikeresen törölve"

This change would translate to "Row successfully deleted" in English, which might provide more context. However, the current translation is also acceptable and consistent with other success messages in the file.

judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiI18NHelper.java (2)

180-181: LGTM! Consider adding a constant for the translation key.

The addition of the row-delete action handling is correct and follows the existing pattern. For consistency with other parts of the codebase, consider defining a constant for the "judo.action.row-delete" translation key.

You could add a constant at the top of the class:

private static final String ROW_DELETE_ACTION_KEY = "judo.action.row-delete";

Then use it in the method:

} else if (ad.getIsRowDeleteAction()) {
    return ROW_DELETE_ACTION_KEY;
}

This approach would be consistent with best practices for maintainability and reduce the risk of typos in string literals.


369-369: LGTM! Consider refactoring for improved readability.

The addition of the row-delete action check is correct and consistent with the existing pattern. However, the long chain of boolean expressions might affect readability.

Consider refactoring the hasSystemTranslation method to improve readability. Here's a suggestion:

  1. Create an enum for action types:
private enum SystemAction {
    ADD, CLEAR, CREATE, BACK, CANCEL, SET, UPDATE, DELETE, ROW_DELETE, REMOVE, 
    FILTER, FILTER_RELATION, REFRESH, REFRESH_RELATION, SELECTOR_RANGE, 
    BULK_REMOVE, BULK_DELETE, OPEN_PAGE, OPEN_CREATE_FORM, OPEN_ADD_SELECTOR, 
    OPEN_SET_SELECTOR, EXPORT
}
  1. Create a method to check if an action is a system action:
private static boolean isSystemAction(ActionDefinition ad) {
    return Stream.of(SystemAction.values())
        .anyMatch(action -> {
            try {
                String methodName = "getIs" + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, action.name()) + "Action";
                Method method = ActionDefinition.class.getMethod(methodName);
                return (boolean) method.invoke(ad);
            } catch (Exception e) {
                log.warning("Failed to check action: " + action);
                return false;
            }
        });
}
  1. Update the hasSystemTranslation method:
private static boolean hasSystemTranslation(VisualElement visualElement) {
    if (visualElement instanceof Button button) {
        ActionDefinition ad = button.getActionDefinition();
        return !ad.getIsCustomAction() && isSystemAction(ad);
    } else if (visualElement instanceof ButtonGroup buttonGroup) {
        return buttonGroup.getFQName().endsWith("::PageActions");
    }
    return false;
}

This refactoring would make the code more maintainable and easier to extend in the future.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a4a710c and 01f156c.

📒 Files selected for processing (4)
  • judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiI18NHelper.java (2 hunks)
  • judo-ui-react/src/main/resources/actor/public/i18n/system_default.json.hbs (1 hunks)
  • judo-ui-react/src/main/resources/actor/public/i18n/system_en-US.json.hbs (1 hunks)
  • judo-ui-react/src/main/resources/actor/public/i18n/system_hu-HU.json.hbs (1 hunks)
🔇 Additional comments (1)
judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiI18NHelper.java (1)

Line range hint 1-386: Overall assessment: Changes are correct and consistent.

The modifications to handle the new row-delete action have been implemented correctly and consistently with the existing codebase. The changes enhance the translation capabilities of the UI framework by integrating additional action translations for buttons, specifically targeting the row-delete functionality.

While the implementation is correct, there are opportunities for minor improvements:

  1. Consider using constants for translation keys to improve maintainability.
  2. The hasSystemTranslation method could benefit from refactoring to enhance readability and extensibility.

These suggestions aim to further improve code quality without changing the core functionality.

@noherczeg noherczeg merged commit 1eb5f3d into develop Oct 1, 2024
3 checks passed
@noherczeg noherczeg deleted the bugfix/JNG-5946-fix-row-delete-translation branch October 1, 2024 17:54
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.

3 participants