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

Small fix for AML block UI #2383

Merged
merged 2 commits into from
May 15, 2024
Merged

Small fix for AML block UI #2383

merged 2 commits into from
May 15, 2024

Conversation

tomer-shvadron
Copy link
Collaborator

@tomer-shvadron tomer-shvadron commented May 15, 2024

User description

image


PR Type

Enhancement


Description

  • Added emptyCell prop to DataTable for custom styling when no data is available.
  • Adjusted UI elements in AmlMatch for better spacing and readability.
  • Enhanced useAmlBlock hook to dynamically adjust the scroll height based on the number of matches.
  • Updated the submodule reference in data-migrations to point to the latest commit.

Changes walkthrough 📝

Relevant files
Enhancement
DataTable.tsx
Enhance DataTable with emptyCell Prop and Adjust No Results Styling

apps/backoffice-v2/src/common/components/organisms/DataTable/DataTable.tsx

  • Added a new property emptyCell to IDataTableProps.
  • Updated the TableCell component to use padding from emptyCell when no
    results are displayed.
  • +2/-1     
    AmlMatch.tsx
    Improve Layout and Key Handling in AmlMatch Component       

    apps/backoffice-v2/src/lib/blocks/components/AmlBlock/AmlMatch.tsx

  • Increased the width and spacing for the 'Type' and 'Source URL'
    fields.
  • Adjusted the key for each item in the list to include the index for
    better React key handling.
  • +7/-7     
    useAmlBlock.tsx
    Dynamic Scroll Height and New Table Styling in useAmlBlock Hook

    apps/backoffice-v2/src/lib/blocks/components/AmlBlock/hooks/useAmlBlock/useAmlBlock.tsx

  • Modified the scroll className to adjust height based on totalMatches.
  • Added a new table className with a fixed height.
  • +5/-1     
    Configuration changes
    data-migrations
    Update Data Migrations Submodule Reference                             

    services/workflows-service/prisma/data-migrations

    • Updated the submodule reference to a new commit.
    +1/-1     

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    Summary by CodeRabbit

    Summary by CodeRabbit

    • New Features

      • Added emptyCell prop to DataTable for enhanced customization of empty cells.
    • Improvements

      • Updated styling and layout in AmlMatch component for better readability and consistency.
      • Conditional scroll height setting and new table prop added in useAmlBlock for improved table handling.
    • Maintenance

      • Updated subproject commit reference for workflows service data migrations.

    Copy link

    changeset-bot bot commented May 15, 2024

    ⚠️ No Changeset found

    Latest commit: c5071ae

    Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

    This PR includes no changesets

    When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

    Click here to learn what changesets are, and how to add one.

    Click here if you're a maintainer who wants to add a changeset to this PR

    Copy link
    Contributor

    coderabbitai bot commented May 15, 2024

    Walkthrough

    The recent updates encompass various enhancements across components in the backoffice application. These include the addition of an noDataCell prop in the DataTable, adjustments to element widths and spacing in AmlMatch, conditional scroll height setting in useAmlBlock, and a revision to the subproject commit reference in data-migrations.

    Changes

    Files Change Summaries
    .../DataTable/DataTable.tsx Added noDataCell prop to IDataTableProps and updated TableCell className usage.
    .../AmlBlock/AmlMatch.tsx Adjusted widths and spacing of elements, and updated key for mapped elements.
    .../useAmlBlock/useAmlBlock.tsx Conditionally set scroll height and added table prop with a specific class.
    .../prisma/data-migrations Updated subproject commit reference.

    In fields of code, where changes bloom,
    A rabbit hops, dispelling gloom.
    With props and styles, it tweaks with care,
    Making sure all bugs are rare.
    Commit by commit, it weaves the tale,
    Of a project strong, that will prevail.
    🌸🐇✨


    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>.
      • 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 generate interesting stats about this repository and render them as a table.
      • @coderabbitai show all the console.log statements in this repository.
      • @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.

    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 as PR comments)

    • @coderabbitai pause to pause the reviews on a PR.
    • @coderabbitai resume to resume the paused reviews.
    • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
    • @coderabbitai resolve resolve all the CodeRabbit review comments.
    • @coderabbitai help to get help.

    Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

    @tomer-shvadron tomer-shvadron changed the title feat: small fix for AML block UI Small fix for AML block UI May 15, 2024
    @github-actions github-actions bot added the enhancement New feature or request label May 15, 2024
    Copy link
    Contributor

    PR Description updated to latest commit (8653eea)

    Copy link
    Contributor

    PR Review 🔍

    ⏱️ Estimated effort to review [1-5]

    3, because the PR involves changes across multiple files and components, including UI adjustments, hook logic enhancements, and submodule updates. The changes are moderate in complexity and require careful review to ensure they integrate well without side effects.

    🧪 Relevant tests

    No

    ⚡ Possible issues

    Possible Bug: The emptyCell prop in DataTable.tsx might not be fully utilized if not passed explicitly where DataTable is used. This could lead to inconsistent styling when no data is available.

    UI Consistency: Changes in AmlMatch.tsx increase the width of elements, which might affect the layout or alignment with other UI components not visible in this PR.

    🔒 Security concerns

    No

    Code feedback:
    relevant fileapps/backoffice-v2/src/common/components/organisms/DataTable/DataTable.tsx
    suggestion      

    Consider providing a default value for emptyCell to ensure consistent styling even when it is not explicitly passed by the consuming components. This can enhance the robustness of the DataTable component. [important]

    relevant lineemptyCell?: ComponentProps;

    relevant fileapps/backoffice-v2/src/lib/blocks/components/AmlBlock/hooks/useAmlBlock/useAmlBlock.tsx
    suggestion      

    Add a check for totalMatches to handle cases where it might be undefined or null, to prevent runtime errors in conditional class assignment. [important]

    relevant linescroll: { className: totalMatches === 0 ? 'h-[10vh]' : 'h-[50vh]' },

    Copy link
    Contributor

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Ensure uniqueness of the key prop in list renders to enhance React performance

    Ensure that the key prop in the map function is unique across all possible renders to
    prevent potential issues with React's rendering optimizations. Using a combination of
    type.key and index might not be unique if type.key can be repeated in different parts of
    the list.

    apps/backoffice-v2/src/lib/blocks/components/AmlBlock/AmlMatch.tsx [39]

    -<div key={`${type.key}-${index}`} className={`flex gap-x-10 px-4`}>
    +<div key={`${type.key}-${item.id}-${index}`} className={`flex gap-x-10 px-4`}>
     
    Suggestion importance[1-10]: 8

    Why: This is a valid concern in React for ensuring efficient updates and re-renders. The suggestion to include item.id in the key prop is a good practice to ensure keys are unique, especially in lists where the same type.key might appear multiple times.

    8
    Possible issue
    Improve the robustness of class name application by ensuring non-null and non-empty values

    Consider using a more specific conditional check for props?.emptyCell?.className to ensure
    that the class name is only applied when it is non-null and non-empty. This avoids
    potential issues where an undefined or empty class name could overwrite existing styles.

    apps/backoffice-v2/src/common/components/organisms/DataTable/DataTable.tsx [298]

    -className={ctw('p-4', props?.emptyCell?.className)}
    +className={ctw('p-4', props?.emptyCell?.className ?? '')}
     
    Suggestion importance[1-10]: 7

    Why: The suggestion correctly identifies a potential issue with class name handling and proposes a safer approach to ensure that undefined or empty class names do not overwrite existing styles.

    7
    Add a default value for totalMatches to ensure consistent behavior in conditional logic

    Consider setting a default value for totalMatches to ensure that the conditional logic for
    scroll.className does not fail in cases where totalMatches might be undefined.

    apps/backoffice-v2/src/lib/blocks/components/AmlBlock/hooks/useAmlBlock/useAmlBlock.tsx [93]

    -scroll: { className: totalMatches === 0 ? 'h-[10vh]' : 'h-[50vh]' }
    +scroll: { className: (totalMatches ?? 0) === 0 ? 'h-[10vh]' : 'h-[50vh]' }
     
    Suggestion importance[1-10]: 6

    Why: Adding a default value for totalMatches is a good safeguard against undefined values, ensuring that the conditional logic for class names behaves consistently. This is a good preventive measure, though not critical.

    6
    Enhancement
    Maintain consistent layout spacing to enhance UI uniformity

    Consider using a more consistent margin or padding strategy across different elements to
    maintain a uniform layout, especially when changing the gap and padding values
    significantly.

    apps/backoffice-v2/src/lib/blocks/components/AmlBlock/AmlMatch.tsx [31]

    -<div className={`flex gap-x-10 px-4 font-semibold`}>
    +<div className={`flex gap-x-6 px-4 font-semibold`}>
     
    Suggestion importance[1-10]: 5

    Why: The suggestion to maintain consistent layout spacing is valid for UI consistency. However, the existing and improved code snippets provided in the suggestion do not reflect a change that aligns with the suggestion's intent, leading to a lower score.

    5

    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

    Review Details

    Configuration used: CodeRabbit UI
    Review profile: CHILL

    Commits Files that changed from the base of the PR and between fdcc030 and 8653eea.
    Files selected for processing (4)
    • apps/backoffice-v2/src/common/components/organisms/DataTable/DataTable.tsx (2 hunks)
    • apps/backoffice-v2/src/lib/blocks/components/AmlBlock/AmlMatch.tsx (1 hunks)
    • apps/backoffice-v2/src/lib/blocks/components/AmlBlock/hooks/useAmlBlock/useAmlBlock.tsx (1 hunks)
    • services/workflows-service/prisma/data-migrations (1 hunks)
    Files skipped from review due to trivial changes (2)
    • apps/backoffice-v2/src/lib/blocks/components/AmlBlock/AmlMatch.tsx
    • services/workflows-service/prisma/data-migrations
    Additional comments not posted (3)
    apps/backoffice-v2/src/lib/blocks/components/AmlBlock/hooks/useAmlBlock/useAmlBlock.tsx (1)

    92-96: Ensure that the new scroll, table, and cell properties are correctly utilized and do not conflict with existing styles or functionality.

    Verification successful

    The new scroll, table, and cell properties are correctly integrated into the useAmlBlock function and are used for styling purposes. The changes appear consistent with the rest of the code and do not introduce any conflicts with existing styles or functionality.

    • The scroll property sets the class name based on the totalMatches value.
    • The table property sets a fixed height for the table.
    • The cell property sets padding for the cells.

    These changes are straightforward and align with the intended functionality.

    Scripts Executed

    The following scripts were executed for the analysis:


    Script:

    #!/bin/bash
    # Description: Verify the usage of new properties in the `props` object.
    
    # Test: Search for the usage of `scroll`, `table`, and `cell` properties in the codebase.
    rg --type typescript 'scroll|table|cell' apps/backoffice-v2/src/lib/blocks/components/AmlBlock/hooks/useAmlBlock/useAmlBlock.tsx
    

    Length of output: 165



    Script:

    #!/bin/bash
    # Description: Verify the usage of new properties in the `props` object.
    
    # Test: Search for the usage of `scroll`, `table`, and `cell` properties in the codebase.
    rg 'scroll|table|cell' apps/backoffice-v2/src/lib/blocks/components/AmlBlock/hooks/useAmlBlock/useAmlBlock.tsx
    

    Length of output: 810

    apps/backoffice-v2/src/common/components/organisms/DataTable/DataTable.tsx (2)

    63-63: The addition of the emptyCell property to the props object in the IDataTableProps interface looks good and maintains consistency with the existing structure.


    298-298: The usage of the emptyCell property in the DataTable component to set the class name for the empty cell is correct and consistent with the existing pattern.

    @tomer-shvadron tomer-shvadron enabled auto-merge (squash) May 15, 2024 11:02
    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

    Review Details

    Configuration used: CodeRabbit UI
    Review profile: CHILL

    Commits Files that changed from the base of the PR and between 8653eea and c5071ae.
    Files selected for processing (2)
    • apps/backoffice-v2/src/common/components/organisms/DataTable/DataTable.tsx (2 hunks)
    • apps/backoffice-v2/src/lib/blocks/components/AmlBlock/hooks/useAmlBlock/useAmlBlock.tsx (1 hunks)
    Files skipped from review as they are similar to previous changes (2)
    • apps/backoffice-v2/src/common/components/organisms/DataTable/DataTable.tsx
    • apps/backoffice-v2/src/lib/blocks/components/AmlBlock/hooks/useAmlBlock/useAmlBlock.tsx

    @tomer-shvadron tomer-shvadron merged commit 093245b into dev May 15, 2024
    9 checks passed
    @tomer-shvadron tomer-shvadron deleted the tomer/aml_block_ui_fix branch May 15, 2024 12:12
    @Omri-Levy Omri-Levy mentioned this pull request Nov 4, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants