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-6031 fix missing enum filter translations #494

Merged

Conversation

noherczeg
Copy link
Contributor

@noherczeg noherczeg commented Nov 26, 2024

BugJNG-6031 Filter dialog enum values are not translated

Copy link

coderabbitai bot commented Nov 26, 2024

Walkthrough

The changes in this pull request involve updates across multiple files related to the actiongrouptest-frontend-react-action_group_test__god project. Key modifications include the addition of a new source entry in the Maven configuration for the judo-diff-checker-maven-plugin, the introduction of a new React component ViewMatterTableTableComponent, and enhancements to the FilterDialog component to improve the handling of enumeration values. These changes collectively enhance the functionality and structure of the codebase.

Changes

File Change Summary
judo-ui-react-itest/ActionGroupTest/action_group_test__god/pom.xml Added new source entry for judo-diff-checker-maven-plugin to include index.tsx in the diff checking process.
judo-ui-react-itest/ActionGroupTest/action_group_test__god/src/test/resources/snapshots/.../index.tsx.snapshot Introduced ViewMatterTableTableComponent, a React component for managing ViewMatter entities with various features.
judo-ui-react/src/main/resources/actor/src/components-api/dialog/FilterDialog.ts.hbs Added FilterEnumValue interface, updated enumValues type in FilterOption interface from Array<string> to Array<FilterEnumValue>.
judo-ui-react/src/main/resources/actor/src/components/dialog/FilterDialog.tsx.hbs Modified FilterInput to use item.value and item.label for enumeration filter options instead of raw item.
judo-ui-react/src/main/resources/actor/src/fragments/table/filter-option.fragment.hbs Changed enumValues representation from strings to objects with value and label properties for better context.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FilterDialog
    participant FilterInput
    participant ViewMatterTableTableComponent

    User->>FilterDialog: Open Filter
    FilterDialog->>FilterInput: Render Filters
    FilterInput->>FilterInput: Access enumValues
    FilterInput-->>User: Display Filter Options
    User->>ViewMatterTableTableComponent: Apply Filter
    ViewMatterTableTableComponent->>ViewMatterTableTableComponent: Update Table Data
Loading

🐇 "In the code, new paths we tread,
With tables and filters, our work is spread.
A component for matters, so neat and bright,
With enums and labels, all set to delight!
Let's hop through the changes, with joy in our hearts,
For every new feature, a fresh work of arts!" 🐇


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: 2

🧹 Outside diff range and nitpick comments (3)
judo-ui-react/src/main/resources/actor/src/components/dialog/FilterDialog.tsx.hbs (1)

Line range hint 89-106: Consider implementing the commented-out time picker using MUI's TimePicker component.

For consistency with other date/time related filters that use proper picker components, consider implementing the time filter using MUI's TimePicker component instead of TextField.

Here's a suggested implementation:

- // case FilterType.time:
- //   return (
- //     <TextField
- //       className={valueId}
- //       label={filter.filterOption.label ?? filter.filterOption.attributeName}
- //       value={filter.filterBy.value}
- //       onChange={(event) => setFilterValue(filter, event.target.value)}
- //       InputProps=\{{
- //         startAdornment: (
- //           <InputAdornment position="start">
- //             <MdiIcon path="clock-outline" />
- //           </InputAdornment>
- //         ),
- //       }}
- //     />
- //   );
+ case FilterType.time:
+   return (
+     <TimePicker
+       className={valueId}
+       label={filter.filterOption.label ?? filter.filterOption.attributeName}
+       value={filter.filterBy.value ?? null}
+       ampm={false}
+       views={['hours', 'minutes', 'seconds']}
+       onChange={(newValue) => setFilterValue(filter, newValue)}
+       slotProps={ {
+         textField: {
+           InputProps: {
+             startAdornment: (
+               <InputAdornment position="start">
+                 <MdiIcon path="clock-outline" />
+               </InputAdornment>
+             ),
+           },
+         },
+       } }
+     />
+   );
judo-ui-react-itest/ActionGroupTest/action_group_test__god/src/test/resources/snapshots/frontend-react/src/containers/View/Matter/Table/components/ViewMatterTableTableComponent/index.tsx.snapshot (2)

174-183: Use appropriate cell editor type for numeric field

The cellEditorType for the numeric mass field is set to 'text', which may not provide the optimal input for numeric values. Consider using 'number' to ensure the input is appropriate for numeric data.

Apply this diff to change the cellEditorType:

return <CellEditInput {...props} error={error} cellEditorType={'text'} />;
+ return <CellEditInput {...props} error={error} cellEditorType={'number'} />;

152-159: Ensure appropriate cell editor for single-select field

For the type column of type 'singleSelect', the cellEditorType is set to 'text'. To provide a proper editor component for single-select fields, consider using 'select' or a custom editor that supports single selection.

Apply this diff to update the cellEditorType:

return <CellEditInput {...props} error={error} cellEditorType={'text'} />;
+ return <CellEditInput {...props} error={error} cellEditorType={'select'} />;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e3af723 and 0232272.

📒 Files selected for processing (5)
  • judo-ui-react-itest/ActionGroupTest/action_group_test__god/pom.xml (1 hunks)
  • judo-ui-react-itest/ActionGroupTest/action_group_test__god/src/test/resources/snapshots/frontend-react/src/containers/View/Matter/Table/components/ViewMatterTableTableComponent/index.tsx.snapshot (1 hunks)
  • judo-ui-react/src/main/resources/actor/src/components-api/dialog/FilterDialog.ts.hbs (1 hunks)
  • judo-ui-react/src/main/resources/actor/src/components/dialog/FilterDialog.tsx.hbs (1 hunks)
  • judo-ui-react/src/main/resources/actor/src/fragments/table/filter-option.fragment.hbs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • judo-ui-react-itest/ActionGroupTest/action_group_test__god/pom.xml
🔇 Additional comments (6)
judo-ui-react/src/main/resources/actor/src/fragments/table/filter-option.fragment.hbs (2)

9-9: LGTM! Good separation of concerns between value and display text.

The new structure properly separates the enum's internal value from its display text, enabling proper internationalization while maintaining the original enum value for data operations.


9-9: Verify translation key structure across the application.

The translation key follows the pattern enumerations.<type>.<member>. Let's verify this convention is consistent across the codebase.

✅ Verification successful

Translation key structure follows consistent pattern across the codebase

The verification shows that the translation key pattern enumerations.<type>.<member> is consistently used across the codebase:

  • Template files (filter-option.fragment.hbs, column.fragment.hbs) use the pattern correctly
  • Translation generation in UiI18NHelper.java follows the same structure
  • Test snapshots demonstrate consistent usage with concrete examples (e.g., enumerations.MatterType.dark)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistency in enum translation key patterns
# Expected: All enum translations should follow the 'enumerations.<type>.<member>' pattern

# Search for translation keys in i18n files
echo "Checking translation files for enum keys:"
fd -e json -e yaml -e yml . | xargs rg '"enumerations\.' -A 1

# Search for enum translation usage in code
echo -e "\nChecking translation usage in code:"
rg "t\(['\"]enumerations\." -A 1

Length of output: 3121

judo-ui-react/src/main/resources/actor/src/components-api/dialog/FilterDialog.ts.hbs (2)

5-8: LGTM! Well-structured interface for enum translations.

The new FilterEnumValue interface provides a clean separation between the actual enum value and its display label, enabling proper translation support.


15-15: LGTM! Verify enum value usage across components.

The type change from Array<string> to Array<FilterEnumValue> is appropriate for supporting translations.

Let's verify that all components using enum values have been updated to handle the new structure:

✅ Verification successful

All components have been updated to handle the new FilterEnumValue structure

The code analysis shows that all components using enumValues are already handling the new FilterEnumValue structure correctly:

  • FilterDialog.tsx.hbs renders enum values using item.value and item.label
  • filter-option.fragment.hbs generates the correct structure with value and label properties
  • ContextMenu.tsx.hbs passes through the enumValues without direct manipulation
  • No other components directly access the internal structure of enum values

The type change from Array<string> to Array<FilterEnumValue> is safe to proceed with.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all files that might be using enumValues to ensure they're updated
# to handle the new FilterEnumValue structure

# Search for direct enumValues usage
echo "Files potentially using enumValues:"
rg -l "enumValues" --type=typescript --type=javascript

# Search for FilterOption usage as they might indirectly use enumValues
echo -e "\nFiles using FilterOption:"
rg -l "FilterOption" --type=typescript --type=javascript

# Look for potential MenuItem rendering of enum values
echo -e "\nFiles potentially rendering enum values in MenuItems:"
rg -l "MenuItem.*enum" --type=typescript --type=javascript

Length of output: 548


Script:

#!/bin/bash
# Let's try without specifying file types since typescript might not be recognized
# Search for direct enumValues usage
echo "Files potentially using enumValues:"
rg -l "enumValues"

# Search for FilterOption usage
echo -e "\nFiles using FilterOption:"
rg -l "FilterOption"

# Look for potential MenuItem rendering of enum values
echo -e "\nFiles potentially rendering enum values in MenuItems:"
rg -l "MenuItem.*enum"

# Also search for the new type FilterEnumValue
echo -e "\nFiles using FilterEnumValue:"
rg -l "FilterEnumValue"

Length of output: 4714


Script:

#!/bin/bash
# Let's examine the implementation of FilterDialog and related components to see how enumValues are used
echo "Checking FilterDialog implementation:"
rg -A 10 "enumValues" "judo-ui-react/src/main/resources/actor/src/components/dialog/FilterDialog.tsx.hbs"

echo -e "\nChecking filter-option fragment:"
rg -A 10 "enumValues" "judo-ui-react/src/main/resources/actor/src/fragments/table/filter-option.fragment.hbs"

echo -e "\nChecking ContextMenu implementation:"
rg -A 10 "enumValues" "judo-ui-react/src/main/resources/actor/src/components/table/ContextMenu.tsx.hbs"

echo -e "\nChecking filter helper implementation:"
rg -A 10 "FilterOption" "judo-ui-react/src/main/resources/actor/src/utilities/filter-helper.ts.hbs"

Length of output: 4555

judo-ui-react/src/main/resources/actor/src/components/dialog/FilterDialog.tsx.hbs (1)

156-157: LGTM! Proper separation of enum value and label.

The changes correctly implement the separation of enum values and their display labels, fixing the translation issue for enum filters.

Let's verify the proper usage of the new FilterEnumValue interface across the codebase:

judo-ui-react-itest/ActionGroupTest/action_group_test__god/src/test/resources/snapshots/frontend-react/src/containers/View/Matter/Table/components/ViewMatterTableTableComponent/index.tsx.snapshot (1)

127-130: Review handling of validation errors on unsuccessful edits

When an error occurs during applyRowEdit and it is not a validation error (status code other than 400), the validation errors for the row are being deleted. This might inadvertently remove existing validation errors. Please confirm whether this behavior is intended.

@noherczeg noherczeg merged commit 50b3f2f into develop Nov 26, 2024
3 checks passed
@noherczeg noherczeg deleted the bugfix/JNG-6031-fix-missing-enum-filter-translations branch November 26, 2024 19:40
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