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

Tooltip support for TableView actions #5142

Merged
merged 3 commits into from
Nov 19, 2024
Merged

Conversation

minhtuev
Copy link
Contributor

@minhtuev minhtuev commented Nov 19, 2024

What changes are proposed in this pull request?

  • Added tooltip support for TableView actions

How is this patch tested? If it is not, please explain why.

  • Tested locally

image

Release Notes

Is this a user-facing change that should be mentioned in the release notes?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release
    notes for FiftyOne users.

(Details in 1-2 sentences. You can just refer to another PR with a description
if this PR is part of a larger change.)

What areas of FiftyOne does this PR affect?

  • App: FiftyOne application changes
  • Build: Build and test infrastructure changes
  • Core: Core fiftyone Python library changes
  • Documentation: FiftyOne documentation changes
  • Other

Summary by CodeRabbit

  • New Features

    • Introduced tooltips for actions in the ActionsMenu and TableView components, enhancing user experience by providing additional context.
    • Updated the alignment and width of the actions column in the TableView for improved presentation.
  • Bug Fixes

    • Ensured correct handling of action click events in the TableView.

Copy link
Contributor

coderabbitai bot commented Nov 19, 2024

Walkthrough

The changes in this pull request involve modifications to the ActionsMenu and TableView components, enhancing their functionality by adding support for tooltips. The ActionsMenu component now includes a tooltip property in its Action function, allowing for conditional rendering of tooltips. The TableView component has updated its actions cell alignment and width properties, and the add_row_action method in the TableView class has been modified to accept a tooltip parameter. These updates aim to improve user interaction and presentation.

Changes

File Path Change Summary
app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx Added tooltip property to Action function and updated rendering logic to include Tooltip. Updated type definitions for ActionsPropsType and ActionPropsType.
app/packages/core/src/plugins/SchemaIO/components/TableView.tsx Changed alignment of actions cell from "right" to "left" and added dynamic width based on max_inline_actions. Updated getRowActions to correctly reference action on_click.
fiftyone/operators/types.py Added optional tooltip parameter to add_row_action method and updated Action class to store tooltip information. Modified to_json method to include tooltip in serialized output.

Possibly related PRs

Suggested reviewers

  • minhtuev
  • ritch
  • imanjra

🐇 In the garden, bright and spry,
Tooltips now dance, oh my, oh my!
Actions align, with a friendly glow,
Hover and learn, as you go!
A sprinkle of joy in every click,
Happy users, that's the trick! 🌼


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

@minhtuev minhtuev changed the title Tooltip support for TableView Tooltip support for TableView actions Nov 19, 2024
@minhtuev minhtuev marked this pull request as ready for review November 19, 2024 00:10
@minhtuev minhtuev requested a review from ritch November 19, 2024 00:13
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: 1

🧹 Outside diff range and nitpick comments (1)
app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx (1)

111-117: Remove unnecessary space character and consider styling implications

  1. The space character in </span>{" "} appears unnecessary
  2. Using a span wrapper might affect styling in some edge cases, especially with flex layouts

Consider this cleaner implementation:

  return tooltip ? (
    <Tooltip title={tooltip}>
-     <span>{content}</span>{" "}
+     <span>{content}</span>
    </Tooltip>
  ) : (
    content
  );

Also, consider adding a comment explaining why we can't directly wrap the Button/MenuItem with Tooltip for future maintainers.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f677604 and 14bf171.

📒 Files selected for processing (3)
  • app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx (5 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/TableView.tsx (1 hunks)
  • fiftyone/operators/types.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

app/packages/core/src/plugins/SchemaIO/components/TableView.tsx (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

🔇 Additional comments (7)
app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx (5)

12-12: LGTM: Import statement follows existing patterns

The Tooltip import is correctly placed within the Material-UI imports group.


77-78: LGTM: Clean props destructuring

The tooltip prop is correctly added to the destructuring pattern.


92-109: LGTM: Clean content extraction

The content variable extraction improves code readability and reusability.


138-138: LGTM: Type definition matches MUI expectations

The tooltip type definition as string | null aligns with Material-UI's Tooltip component expectations.


24-24: Verify the alignment change impact

The alignment change from "flex-end" to "flex-start" will shift inline actions from right to left alignment. Please confirm this is the intended behavior with the new tooltip support.

✅ Verification successful

Let me gather more context about the ActionsMenu component to understand the alignment change better.


Alignment change is consistent with component's usage

The alignment change from "flex-end" to "flex-start" in ActionsMenu is appropriate because:

  • The component is used within table cells (TableView) where left alignment is more natural for content readability
  • Other similar Stack components in the codebase either use "space-between" for full-width layouts or don't specify justification
  • The component renders a row of action buttons with consistent spacing (0.5), and left alignment provides a predictable starting point for these actions
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other Stack components with similar usage to ensure consistency
rg -A 2 "Stack.*direction=\"row\".*justify" 

Length of output: 2204


Script:

#!/bin/bash
# Search for the ActionsMenu component implementation and its usage
rg -A 5 "ActionsMenu" 

# Also search for any test files related to ActionsMenu
fd "ActionsMenu.*test" 

Length of output: 1930

fiftyone/operators/types.py (2)

1819-1819: LGTM: Clean addition of tooltip parameter documentation.

The tooltip parameter is properly documented in the Action class docstring, maintaining consistent documentation standards.


1855-1857: LGTM: Well-implemented tooltip support in add_row_action method.

The method signature and implementation are updated correctly to support tooltips while maintaining backward compatibility.

Comment on lines +144 to +146
sx: { ...headingCellBaseStyles, textAlign: "left" },
})}
width={`${max_inline_actions * 5}%`}
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

Fix inconsistent alignment and improve width calculation

There are two issues with the actions column:

  1. The header is left-aligned but the content in table cells (line 198) is right-aligned, creating an inconsistent visual appearance.
  2. The width calculation (max_inline_actions * 5%) might be too narrow for action buttons with text, especially with the default max_inline_actions=1.

Consider these improvements:

 <TableCell
   {...getComponentProps(props, "tableHeadCell", {
-    sx: { ...headingCellBaseStyles, textAlign: "left" },
+    sx: { ...headingCellBaseStyles, textAlign: "right" },
   })}
-  width={`${max_inline_actions * 5}%`}
+  width={`${Math.max(max_inline_actions * 8, 10)}%`}
   onClick={() => {
     handleCellClick(-1, -1);
   }}
 >

This change:

  • Aligns the header with the content
  • Ensures a minimum width of 10% and allocates 8% per action instead of 5%
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
sx: { ...headingCellBaseStyles, textAlign: "left" },
})}
width={`${max_inline_actions * 5}%`}
sx: { ...headingCellBaseStyles, textAlign: "right" },
})}
width={`${Math.max(max_inline_actions * 8, 10)}%`}

@minhtuev minhtuev merged commit c9f7688 into develop Nov 19, 2024
14 checks passed
@minhtuev minhtuev deleted the feat/action-item-tooltip branch November 19, 2024 02:39
minhtuev added a commit that referenced this pull request Nov 19, 2024
* Added tooltip to actions
* Added tooltip to Python obj
* Left align actions column and fix spacing

---------

Co-authored-by: minhtuevo <minhtuev@voxel51.com>
Co-authored-by: CamronStaley <camron_staley@live.com>
minhtuev added a commit that referenced this pull request Nov 19, 2024
* Added tooltip to actions
* Added tooltip to Python obj
* Left align actions column and fix spacing

---------

Co-authored-by: minhtuevo <minhtuev@voxel51.com>
Co-authored-by: CamronStaley <camron_staley@live.com>
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