Merge branch 'gallery-sidebar' into 'v3'
Add gallery bulk actions and sidebar See merge request openflexure/openflexure-microscope-server!625
This commit is contained in:
commit
d2e19142df
10 changed files with 232 additions and 66 deletions
|
|
@ -15,6 +15,7 @@ from openflexure_microscope_server.things.gallery import (
|
|||
GalleryCompatibleThing,
|
||||
GalleryThing,
|
||||
)
|
||||
from openflexure_microscope_server.ui import ActionButton
|
||||
|
||||
from ..shared_utils.lt_test_utils import LabThingsTestEnv
|
||||
|
||||
|
|
@ -63,6 +64,10 @@ class MinimalGalleryClass:
|
|||
def delete_all_gallery_items(self) -> None:
|
||||
"""Mock deleting all the data."""
|
||||
|
||||
def get_gallery_bulk_actions(self) -> list[ActionButton]:
|
||||
"""No bulk actions."""
|
||||
return []
|
||||
|
||||
|
||||
class MinimalGallerySource(OFMThing, MinimalGalleryClass):
|
||||
"""Minimal example of a Thing that can show data in the gallery.
|
||||
|
|
@ -94,6 +99,10 @@ class BadGallerySource(OFMThing):
|
|||
def delete_all_gallery_items(self) -> None:
|
||||
"""Mock deleting all the data."""
|
||||
|
||||
def get_gallery_bulk_actions(self) -> list[ActionButton]:
|
||||
"""No bulk actions."""
|
||||
return []
|
||||
|
||||
|
||||
class BadMockGalleryData(BaseModel):
|
||||
"""Mock gallery data without a card type."""
|
||||
|
|
@ -119,6 +128,10 @@ class BadGallerySource2(OFMThing):
|
|||
def delete_all_gallery_items(self) -> None:
|
||||
"""Mock deleting all the data."""
|
||||
|
||||
def get_gallery_bulk_actions(self) -> list[ActionButton]:
|
||||
"""No bulk actions."""
|
||||
return []
|
||||
|
||||
|
||||
def test_gallery_compatible_protocol():
|
||||
"""Check the gallery compatible protocol detects compatible classes only."""
|
||||
|
|
@ -161,6 +174,16 @@ def test_gallery_thing_finds_all_providers(simulation_test_env):
|
|||
assert gallery.card_types == ["Capture", "Scan"]
|
||||
assert gallery._card_type_map == {"camera": "Capture", "smart_scan": "Scan"}
|
||||
|
||||
# Also check all bulk actions
|
||||
bulk_actions = gallery.bulk_actions
|
||||
# Only actions should be stitch all scans
|
||||
assert len(bulk_actions) == 1
|
||||
assert bulk_actions[0].thing == "smart_scan"
|
||||
assert bulk_actions[0].action == "stitch_all_scans"
|
||||
assert bulk_actions[0].can_terminate
|
||||
assert bulk_actions[0].requires_confirmation
|
||||
assert "Stitch all unstitched scans?" in bulk_actions[0].confirmation_message
|
||||
|
||||
# Also check the runtime checkable protocol GalleryCompatibleThing works directly
|
||||
# when called with isinstance.
|
||||
assert not isinstance(snake_workflow, GalleryCompatibleThing)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue