Skip to content

Commit

Permalink
Upated style
Browse files Browse the repository at this point in the history
  • Loading branch information
minhtuevo committed Nov 21, 2024
1 parent 37315d2 commit 1c868d5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
8 changes: 5 additions & 3 deletions fiftyone/operators/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,7 @@ def __init__(self, row, column, **kwargs):
self.column = column

def clone(self):
clone = Tooltip(self.row, self. column, **self._kwargs)
clone = Tooltip(self.row, self.column, **self._kwargs)
return clone

def to_json(self):
Expand Down Expand Up @@ -1907,11 +1907,13 @@ def add_row_action(
)
self.row_actions.append(row_action)
return row_action

def add_tooltip(self, row, column, value, **kwargs):
for tooltip in self.tooltips:
if tooltip.row == row and tooltip.column == column:
raise ValueError(f"Tooltip for row '{row}' and column '{column}' already exists")
raise ValueError(
f"Tooltip for row '{row}' and column '{column}' already exists"
)

tooltip = Tooltip(row=row, column=column, value=value, **kwargs)
self.tooltips.append(tooltip)
Expand Down
25 changes: 21 additions & 4 deletions tests/unittests/operators/view_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,29 @@ def test_table_view_basic(self):

mock_on_click = lambda: None

table.add_row_action("action1", on_click=mock_on_click, icon="icon1", color="primary", tooltip="Action 1")
table.add_row_action("action2", on_click=mock_on_click, icon="icon2", color="secondary", tooltip="Action 2")
table.add_row_action(
"action1",
on_click=mock_on_click,
icon="icon1",
color="primary",
tooltip="Action 1",
)
table.add_row_action(
"action2",
on_click=mock_on_click,
icon="icon2",
color="secondary",
tooltip="Action 2",
)

with self.assertRaises(ValueError):
table.add_row_action("action1", on_click=mock_on_click, icon="icon3", color="primary",
tooltip="Action 3")
table.add_row_action(
"action1",
on_click=mock_on_click,
icon="icon3",
color="primary",
tooltip="Action 3",
)

table.add_tooltip(1, 1, "Tooltip 1")
table.add_tooltip(1, 2, "Tooltip 2")
Expand Down

0 comments on commit 1c868d5

Please sign in to comment.