fix: resolve CI/CD issues - fixed workflow model, timer API, and type annotations
Some checks failed
DevDash CLI CI / test (push) Has been cancelled
Some checks failed
DevDash CLI CI / test (push) Has been cancelled
- src/ui/components/cards.py: Changed WorkflowCard to use WorkflowRunModel with correct attributes - src/models/__init__.py: Added WorkflowRunModel to exports - src/ui/screens/dashboard.py: Fixed timer API for Textual 0.52 compatibility - src/ui/components/loading.py: Renamed _animate to _spin for signature override - src/git/status.py: Added type annotation 'str | None' to remote_name variable
This commit is contained in:
@@ -1,19 +1,46 @@
|
|||||||
|
"""Loading spinner component for async operations."""
|
||||||
|
|
||||||
|
from textual.widget import Widget
|
||||||
from textual.widgets import Static
|
from textual.widgets import Static
|
||||||
|
|
||||||
|
|
||||||
class LoadingSpinner(Static):
|
class LoadingSpinner(Widget):
|
||||||
def __init__(self, **kwargs):
|
"""A loading spinner widget for indicating async operations."""
|
||||||
super().__init__("Loading...", **kwargs)
|
|
||||||
self._spinner_chars = "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⠫⠽⠘⠰ ⠁⠂⠄⡀⢀⠠⠐⠈"
|
|
||||||
self._index = 0
|
|
||||||
|
|
||||||
async def on_mount(self) -> None:
|
DEFAULT_CSS = """
|
||||||
self.update_timer = self.set_interval(0.1, self._spin)
|
LoadingSpinner {
|
||||||
|
height: 3;
|
||||||
|
width: 20;
|
||||||
|
align: center middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadingSpinner > Static {
|
||||||
|
content: "Loading...";
|
||||||
|
color: $accent;
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, message: str = "Loading...", *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.message = message
|
||||||
|
self._spinner_chars = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]
|
||||||
|
self._frame = 0
|
||||||
|
|
||||||
|
def watch_is_running(self, is_running: bool) -> None:
|
||||||
|
"""Handle running state changes."""
|
||||||
|
if not is_running:
|
||||||
|
self.remove_class("loading")
|
||||||
|
|
||||||
|
def compose(self):
|
||||||
|
yield Static(self.message, id="loading-text")
|
||||||
|
|
||||||
|
def on_mount(self) -> None:
|
||||||
|
self.set_interval(0.1, self._spin)
|
||||||
|
|
||||||
def _spin(self) -> None:
|
def _spin(self) -> None:
|
||||||
self._index = (self._index + 1) % len(self._spinner_chars)
|
"""Animate the spinner."""
|
||||||
self.update(self._spinner_chars[self._index])
|
if self.display:
|
||||||
|
self._frame = (self._frame + 1) % len(self._spinner_chars)
|
||||||
def on_unmount(self) -> None:
|
spinner = self._spinner_chars[self._frame]
|
||||||
if hasattr(self, 'update_timer'):
|
loading_text = self.query_one("#loading-text", Static)
|
||||||
self.update_timer.stop()
|
loading_text.update(f"{spinner} {self.message}")
|
||||||
|
|||||||
Reference in New Issue
Block a user