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

Update TableView with multi inline actions #5118

Merged
merged 5 commits into from
Nov 15, 2024

Conversation

minhtuev
Copy link
Contributor

@minhtuev minhtuev commented Nov 14, 2024

What changes are proposed in this pull request?

Update TableView with multiple inline actions

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

  • Tested locally

Users can set the max_icons_inline arg from TableView:

table = types.TableView(
    on_click_row=self.on_click_row,
    max_icons_inline=2,
)

Result:

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

Summary by CodeRabbit

  • New Features
    • Enhanced the Actions Menu to display up to two actions inline, improving visibility and accessibility.
    • Introduced a new property in the TableView component to customize the maximum number of actions displayed inline, allowing for better control over the layout.

@minhtuev minhtuev requested a review from imanjra November 14, 2024 23:43
Copy link
Contributor

coderabbitai bot commented Nov 14, 2024

Walkthrough

The pull request modifies the DEFAULT_MAX_INLINE constant in the ActionsMenu component from 1 to 2, allowing for the display of up to two actions inline. If the number of actions exceeds this maximum, the ActionsOverflowMenu will be rendered. Additionally, a new property max_inline_actions is introduced in the TableView component to customize the maximum number of actions displayed inline in the ActionsMenu.

Changes

File Path Change Summary
app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx Updated DEFAULT_MAX_INLINE from 1 to 2, modifying the condition for displaying actions inline.
app/packages/core/src/plugins/SchemaIO/components/TableView.tsx Added max_inline_actions prop to TableView, allowing customization of actions displayed inline in ActionsMenu.

Possibly related PRs

Suggested reviewers

  • ritch

🐰 In the meadow where actions play,
Two can dance in bright array.
With a hop and a skip, they shine so bright,
Overflowing joy, a delightful sight!
So let us cheer, with a joyful cheer,
For actions inline, we hold so dear! 🌼

Warning

Rate limit exceeded

@minhtuev has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 45 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between e0e52d4 and a355227.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e0e52d4 and a355227.

📒 Files selected for processing (1)
  • app/packages/core/src/plugins/SchemaIO/components/TableView.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/packages/core/src/plugins/SchemaIO/components/TableView.tsx

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 requested a review from ritch November 14, 2024 23:44
@minhtuev minhtuev changed the base branch from develop to release/v1.1.0 November 14, 2024 23:44
@minhtuev minhtuev marked this pull request as ready for review November 15, 2024 21:07
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

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

Line range hint 21-29: LGTM! Consider enhancing prop types for better type safety.

The condition correctly implements the multi-inline actions logic with appropriate spacing.

Consider adding a constraint to the maxInline prop type to ensure it's a positive number:

 type ActionsPropsType = {
   actions: Array<ActionPropsType>;
-  maxInline?: number;
+  maxInline?: number & { __brand: 'PositiveNumber' };
   size?: SizeType;
 };

+// Type guard to ensure positive numbers
+function isPositiveNumber(n: number): n is number & { __brand: 'PositiveNumber' } {
+  return n > 0;
+}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 02ae185 and 84a38d5.

📒 Files selected for processing (1)
  • app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
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.

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

16-16: LGTM! Verify UI layout with maximum inline actions.

The increase to 2 inline actions provides a good balance between accessibility and UI cleanliness.

Let's verify all places where this component is used to ensure the UI layout remains clean with 2 inline actions:

✅ Verification successful

Verified: DEFAULT_MAX_INLINE change is safe and well-contained

The change to show 2 inline actions is used only in TableView component, where actions are rendered within table cells. This context makes the change even more appropriate as table rows typically have sufficient width to accommodate 2 inline actions without causing layout issues.

  • Used in: app/packages/core/src/plugins/SchemaIO/components/TableView.tsx
  • Implementation shows proper usage with size prop being passed, ensuring consistent styling
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find all files that import or use ActionsMenu
rg -l "ActionsMenu" --type ts --type tsx

Length of output: 68


Script:

#!/bin/bash
# Find all files that import or use ActionsMenu, searching through all text files
rg -l "ActionsMenu" 

Length of output: 149


Script:

#!/bin/bash
# Check how ActionsMenu is used in TableView.tsx
rg "ActionsMenu" app/packages/core/src/plugins/SchemaIO/components/TableView.tsx -C 3

Length of output: 625

imanjra
imanjra previously approved these changes Nov 15, 2024
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/TableView.tsx (1)

Line range hint 49-63: Consider memoizing row actions computation.

The getRowActions callback processes all row actions for each row. For tables with many rows and actions, this could impact performance. Consider memoizing the results using useMemo to prevent unnecessary recomputations.

- const getRowActions = useCallback((row) => {
+ const getRowActions = useCallback((row) => {
+   const memoizedActions = useMemo(() => {
    const computedRowActions = [] as any;
    for (const action of row_actions) {
      if (action.rows?.[row] !== false) {
        computedRowActions.push({
          ...action,
          onClick: (action, e) => {
            handleClick(panelId, {
              operator: action.on_click,
              params: { path, event: action.name, row },
            });
          },
        });
      }
    }
    return computedRowActions;
+   }, [row, row_actions, panelId, path]);
+   return memoizedActions;
  }, []);
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 84a38d5 and e0e52d4.

📒 Files selected for processing (2)
  • app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/TableView.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx
🧰 Additional context used
📓 Path-based instructions (1)
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 (1)
app/packages/core/src/plugins/SchemaIO/components/TableView.tsx (1)

202-202: Verify ActionsMenu prop handling and consider consistent naming.

The prop name changes from max_icons_inline to maxInline between components. While this follows React conventions (snake_case for schema props, camelCase for component props), we should verify that ActionsMenu properly handles this prop.

✅ Verification successful

The shell script results show that the maxInline prop is properly defined and handled in the ActionsMenu component. Let me verify the complete implementation:

  1. In ActionsMenu.tsx:
    • The prop is correctly typed as maxInline?: number
    • It's destructured with a default value: const { actions, maxInline = DEFAULT_MAX_INLINE, size } = props
    • It's used in logic: if (actions.length <= maxInline)

Let me verify if there's a constant definition for DEFAULT_MAX_INLINE:


Prop handling is correct, naming convention follows React patterns

The maxInline prop in ActionsMenu is properly defined, typed, and used with a default value of 1. The prop naming difference (snake_case max_icons_inline in TableView vs camelCase maxInline in ActionsMenu) follows React's convention of using camelCase for component props while preserving snake_case for schema-derived values. No changes needed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for ActionsMenu component definition and prop usage
ast-grep --pattern 'interface $interface {
  $$$
  maxInline$_: $_
  $$$
}'

# Search for any existing usages of maxInline prop
rg -A 5 'maxInline[^a-zA-Z]'

Length of output: 2021


Script:

#!/bin/bash
# Search for DEFAULT_MAX_INLINE constant
rg "DEFAULT_MAX_INLINE"

Length of output: 252

@minhtuev minhtuev force-pushed the feat/update-table-multi-inline-actions branch from 5197df4 to a355227 Compare November 15, 2024 21:47
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