diff --git a/app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx b/app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx index b75c4991f6..1c742d2cf1 100644 --- a/app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx +++ b/app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx @@ -9,6 +9,7 @@ import { Menu, MenuItem, Stack, + Tooltip, } from "@mui/material"; import React, { useCallback } from "react"; import { getColorByCode } from "../utils"; @@ -20,7 +21,7 @@ export default function ActionsMenu(props: ActionsPropsType) { if (actions.length <= maxInline) { return ( - + {actions.map((action) => ( ))} @@ -73,7 +74,8 @@ function ActionsOverflowMenu(props: ActionsPropsType) { } function Action(props: ActionPropsType) { - const { label, name, onClick, icon, variant, mode, color, size } = props; + const { label, name, onClick, icon, variant, mode, color, size, tooltip } = + props; const resolvedColor = color ? getColorByCode(color) : undefined; const Icon = icon ? ( @@ -87,20 +89,32 @@ function Action(props: ActionPropsType) { [onClick, props] ); - return mode === "inline" ? ( - + const content = + mode === "inline" ? ( + + ) : ( + + {Icon && {Icon}} + + {label || name} + + + ); + + return tooltip ? ( + + {content}{" "} + {/* Use to wrap the child to avoid DOM issues */} + ) : ( - - {Icon && {Icon}} - {label || name} - + content ); } @@ -121,4 +135,5 @@ type ActionPropsType = { mode: "inline" | "menu"; color?: string; size?: SizeType; + tooltip: string | null; }; diff --git a/app/packages/core/src/plugins/SchemaIO/components/TableView.tsx b/app/packages/core/src/plugins/SchemaIO/components/TableView.tsx index 7deb8e852e..8567db0760 100644 --- a/app/packages/core/src/plugins/SchemaIO/components/TableView.tsx +++ b/app/packages/core/src/plugins/SchemaIO/components/TableView.tsx @@ -141,8 +141,9 @@ export default function TableView(props: ViewPropsType) { {hasRowActions && ( { handleCellClick(-1, -1); }} diff --git a/fiftyone/operators/types.py b/fiftyone/operators/types.py index 9135a18ba4..496a67e934 100644 --- a/fiftyone/operators/types.py +++ b/fiftyone/operators/types.py @@ -1824,6 +1824,7 @@ class Action(View): name: the name of the action label (None): the label of the action icon (None): the icon of the action + tooltip (None): the tooltip of the action on_click: the operator to execute when the action is clicked """ @@ -1859,9 +1860,9 @@ def add_column(self, key, **kwargs): self.columns.append(column) return column - def add_row_action(self, name, on_click, label=None, icon=None, **kwargs): + def add_row_action(self, name, on_click, label=None, icon=None, tooltip=None, **kwargs): row_action = Action( - name=name, on_click=on_click, label=label, icon=icon, **kwargs + name=name, on_click=on_click, label=label, icon=icon, tooltip=tooltip, **kwargs ) self.row_actions.append(row_action) return row_action