Coverage for src / lexigram / admin / actions / row_manager / shortcuts.py: 0%
12 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-11 02:25 +0800
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-11 02:25 +0800
1"""
2Keyboard shortcuts management for row actions.
4Handles keyboard shortcut registration and execution for row actions.
5"""
7from __future__ import annotations
9from typing import Any
11from lexigram.admin.actions.row_manager.types import RowAction
12from lexigram.admin.actions.shortcuts import KeyboardShortcutManager as _Base
15class KeyboardShortcutManager(_Base[RowAction]):
16 """Manages keyboard shortcuts for row actions."""
18 def execute_shortcut(
19 self,
20 shortcut: str,
21 record_id: Any,
22 record: Any | None = None,
23 ) -> RowAction | None:
24 """Return the action for *shortcut* if it can execute for *record*."""
25 action = self._shortcuts.get(shortcut)
26 if action and record and action.visible(record) and not action.disabled(record):
27 return action
28 return None
30 def get_registered_shortcuts_with_labels(self) -> dict[str, str]:
31 """Return a mapping of shortcut → action label."""
32 return {sc: action.label for sc, action in self._shortcuts.items()}