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: Housekeeping of List Item and Entity Item #38524

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

hetunandu
Copy link
Member

@hetunandu hetunandu commented Jan 8, 2025

Description

General housekeeping items to ADS ListItem, Editable and Entity Item. In prep for usage of EntityListTree we found these items missing. PR #38493

Automation

/ok-to-test tags="@tag.IDE, @tag.Sanity"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12665028794
Commit: 3f68ddf
Cypress dashboard.
Tags: @tag.IDE, @tag.Sanity
Spec:


Wed, 08 Jan 2025 06:51:47 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced event handling for list items with improved mouse event support
    • Added unique identifiers for entity items to support testing and tracking
  • Improvements

    • Streamlined tooltip handling in list components
    • Updated keyboard event management to prevent event propagation
    • Improved class name and test ID management for entity items
  • Technical Updates

    • Integrated useEventCallback hook for more efficient event handling
    • Updated method signatures to support more detailed event interactions

@hetunandu hetunandu requested a review from ankitakinger January 8, 2025 06:06
@hetunandu hetunandu added the ok-to-test Required label for CI label Jan 8, 2025
Copy link
Contributor

coderabbitai bot commented Jan 8, 2025

Walkthrough

The pull request introduces several enhancements to the design system's list and entity explorer components. The changes primarily focus on improving event handling, adding test capabilities, and refining component interactions. Key modifications include updating event callbacks, adding unique identifiers, and implementing more robust event management across multiple files in the design system package.

Changes

File Change Summary
List/List.tsx Replaced useEffect with useEventCallback, simplified tooltip handling, updated event handlers
List/List.types.tsx Modified onClick method signature to accept MouseEvent
Templates/EntityExplorer/Editable/useEditableText.ts Added e.stopPropagation() to handleKeyUp function
Templates/EntityExplorer/EntityItem/EntityItem.tsx Added classnames, dynamic className, data-testid, and id props
Templates/EntityExplorer/EntityItem/EntityItem.types.ts Introduced id property to EntityItemProps interface

Sequence Diagram

sequenceDiagram
    participant User
    participant EntityItem
    participant ListItem
    participant EventHandler

    User->>EntityItem: Interact with item
    EntityItem->>ListItem: Trigger event
    ListItem->>EventHandler: Process event
    EventHandler-->>ListItem: Return handled event
    ListItem-->>EntityItem: Update component state
Loading

Possibly related PRs

Suggested Labels

Enhancement, IDE Product, Task, IDE Pod

Suggested Reviewers

  • hetunandu
  • ankitakinger
  • albinAppsmith

Poem

🖥️ Code flows like a river's might,
Events dancing with pure delight,
Components sing their refactored song,
Where useEventCallback makes things strong,
Elegance blooms in each new line! 🌟


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.

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.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Jan 8, 2025
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

🧹 Nitpick comments (2)
app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.tsx (1)

7-7: Consider using consistent import alias

The import alias clx is used for classnames. Consider using classNames to match common conventions.

app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.stories.tsx (1)

39-39: Consider demonstrating id prop variations

While the hardcoded "storyItem" id works, consider showing different id values in various stories to better demonstrate the prop's usage.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7296ef and 3f68ddf.

📒 Files selected for processing (7)
  • app/client/packages/design-system/ads/src/List/List.tsx (4 hunks)
  • app/client/packages/design-system/ads/src/List/List.types.tsx (2 hunks)
  • app/client/packages/design-system/ads/src/Templates/EntityExplorer/Editable/useEditableText.test.tsx (4 hunks)
  • app/client/packages/design-system/ads/src/Templates/EntityExplorer/Editable/useEditableText.ts (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.stories.tsx (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.tsx (2 hunks)
  • app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.types.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests
  • GitHub Check: chromatic-deployment
🔇 Additional comments (9)
app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.types.ts (1)

8-9: Well-documented addition of the id property

Good addition of the id property with clear JSDoc documentation explaining its purpose in the markup.

app/client/packages/design-system/ads/src/Templates/EntityExplorer/EntityItem/EntityItem.tsx (1)

81-84: Good addition of test and identification attributes

The changes improve component testability and identification:

  • Proper class composition using classnames
  • Descriptive data-testid
  • Consistent id prefix pattern
app/client/packages/design-system/ads/src/Templates/EntityExplorer/Editable/useEditableText.ts (1)

77-78: Verify the necessity of stopping event propagation

Adding stopPropagation() prevents parent components from receiving these keyboard events. While this might be intentional to prevent unwanted side effects, it could also break existing functionality that relies on these events.

✅ Verification successful

Stopping event propagation is appropriate here

The addition of stopPropagation() in the handleKeyUp function follows the established patterns in the codebase for handling keyboard events. This prevents unwanted interactions with global keyboard shortcuts or parent components while editing text in the EntityExplorer component.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for parent components that might be listening for keyboard events
rg -B 2 -A 2 "onKeyUp|onKeyDown|addEventListener.*keyup|addEventListener.*keydown" --type ts --type tsx

Length of output: 133


Script:

#!/bin/bash
# Search for keyboard event handlers with correct file types
rg -t ts "onKeyUp|onKeyDown|addEventListener.*keyup|addEventListener.*keydown" -B 2 -A 2

# Search for the component hierarchy to understand event bubbling
ast-grep --pattern 'const useEditableText = $_' -A 10

Length of output: 67517

app/client/packages/design-system/ads/src/Templates/EntityExplorer/Editable/useEditableText.test.tsx (1)

85-85: LGTM! Test coverage is comprehensive

The test modifications correctly mock the event's stopPropagation method and cover all relevant scenarios including valid saves, invalid saves, and cancellation cases.

Also applies to: 117-117, 139-142, 163-166

app/client/packages/design-system/ads/src/List/List.types.tsx (1)

2-2: LGTM! Improved type safety for click handlers

The addition of MouseEvent type for onClick callback provides better type safety and access to event properties.

Also applies to: 14-14

app/client/packages/design-system/ads/src/List/List.tsx (4)

40-57: LGTM! Performance optimization in tooltip handling

Replaced effect-based checking with event-based approach using useEventCallback. This is more efficient as it computes tooltip visibility only when needed.


95-101: LGTM! Consistent event handling pattern

The handleDoubleClick implementation follows the same pattern as handleOnClick, maintaining consistency in event handling.


103-105: Verify empty handler intention

The handleRightControlClick only stops propagation without any handler logic. Is this intentional or should it handle the rightControl click events?

✅ Verification successful

Empty handler is intentional and correct

The empty handler with stopPropagation() is the correct implementation. It prevents click events on rightControl elements from triggering the parent ListItem's onClick handler, allowing rightControl components to handle their own click events independently.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for rightControl usage patterns
rg "rightControl.*onClick" app/client/packages/

Length of output: 49


Script:

#!/bin/bash
# Search for rightControl prop definition and usage in List component
ast-grep --pattern 'interface $_ {
  $$$
  rightControl?: $_;
  $$$
}'

# Look for the List component implementation
cat app/client/packages/design-system/ads/src/List/List.tsx

# Search for similar event handlers in List component
rg "handle.*Click.*stopPropagation" app/client/packages/design-system/ads/src/List/

Length of output: 8257


87-93: Verify stopPropagation impact on EntityListTree

The addition of stopPropagation is good for preventing event bubbling, but please verify this doesn't interfere with any required event bubbling in EntityListTree usage.

✅ Verification successful

stopPropagation usage is safe

The codebase analysis shows no direct usage of the List component in tree-related components. The stopPropagation addition won't interfere with any tree component functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for EntityListTree usage of List components
rg -l "EntityListTree.*List" app/client/packages/

Length of output: 51


Script:

#!/bin/bash
# Search for EntityListTree files
echo "=== Searching for EntityListTree files ==="
fd EntityListTree

# Search for tree-like components importing List
echo "=== Searching for List imports in tree components ==="
rg "import.*List.*from.*ads" -A 5 --glob "*Tree*.{ts,tsx}"

# Search for List component usage in tree components
echo "=== Searching for List usage in tree components ==="
rg "<List" --glob "*Tree*.{ts,tsx}"

Length of output: 443


Script:

#!/bin/bash
# Search for any tree-related components
echo "=== Searching for tree-related files ==="
fd -e tsx -e ts --glob "*[Tt]ree*"

# Search for List component usage in any file
echo "=== Searching for List component usage ==="
rg -l "import.*List.*from.*ads"

# Search for recent changes to tree components
echo "=== Searching for tree-related changes ==="
git diff --name-only HEAD~5 HEAD | grep -i "tree"

Length of output: 5355

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants