Unify UI for action_button_for and property_control_for

This commit is contained in:
Julian Stirling 2025-12-17 23:36:06 +00:00
parent afbc00acef
commit 51512f36f7
3 changed files with 17 additions and 13 deletions

View file

@ -1,6 +1,6 @@
"""Functionality for communicating the required user interface for a thing."""
from typing import Any, Callable
from typing import Any
from pydantic import BaseModel
@ -47,14 +47,12 @@ class ActionButton(BaseModel):
"""The message to show on successful completion."""
def action_button_for(action: Callable[..., Any], **kwargs: Any) -> ActionButton:
def action_button_for(thing: lt.Thing, action_name: str, **kwargs: Any) -> ActionButton:
"""Create a ActionButton data for the specified Thing Action.
:param action: The thing action to create a button for.
:param kwargs: Any attribute of `ActionButton` except for ``thing`` or ``action``.
"""
thing = action.args[0]
action_name = action.func.__name__
return ActionButton(thing=thing.name, action=action_name, **kwargs)