Coverage for src / lexigram / admin / actions / types.py: 100%

31 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-08-13 22:14 +0800

1"""Action types for lexigram-admin actions module. 

2 

3Defines shared enums, dataclasses, and value objects used across 

4the action system. All types here are framework-level and can be 

5imported by any admin action implementation. 

6""" 

7 

8from __future__ import annotations 

9 

10from dataclasses import dataclass, field 

11from enum import Enum 

12from typing import Any 

13 

14 

15class ActionColor(str, Enum): 

16 """Visual color variants for action buttons and indicators.""" 

17 

18 GRAY = "gray" 

19 PRIMARY = "primary" 

20 SECONDARY = "secondary" 

21 SUCCESS = "success" 

22 WARNING = "warning" 

23 DANGER = "danger" 

24 INFO = "info" 

25 

26 

27@dataclass 

28class ActionContext: 

29 """Contextual information passed to action execution. 

30 

31 Carries the request, authenticated user, resource name, 

32 authorizer, audit writer, and request-metadata fields 

33 that together describe the environment in which an action runs. 

34 """ 

35 

36 request: Any | None = None 

37 user: Any | None = None 

38 resource_name: str = "" 

39 resource_prefix: str = "" 

40 authorizer: Any | None = None 

41 audit_writer: Any | None = None 

42 correlation_id: str | None = None 

43 request_id: str | None = None 

44 request_ip: str | None = None 

45 metadata: dict[str, Any] = field(default_factory=dict) 

46 record_id: str | None = None 

47 

48 

49@dataclass(frozen=True, kw_only=True) 

50class ConfirmationConfig: 

51 """Configuration for action confirmation dialogs. 

52 

53 Attributes: 

54 title: Required dialog title. 

55 message: Optional explanatory body text. 

56 style: Visual style of the confirmation. Defaults to WARNING. 

57 """ 

58 

59 title: str 

60 message: str | None = None 

61 style: ActionColor = ActionColor.WARNING 

62 

63 

64__all__ = [ 

65 "ActionColor", 

66 "ActionContext", 

67 "ConfirmationConfig", 

68]