Coverage for src/lexigram/admin/actions/types.py: 100%
32 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-24 23:39 +0800
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-24 23:39 +0800
1"""Action types for lexigram-admin actions module.
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"""
8from __future__ import annotations
10from dataclasses import dataclass, field
11from enum import Enum
12from typing import Any
15class ActionColor(str, Enum):
16 """Visual color variants for action buttons and indicators."""
18 GRAY = "gray"
19 PRIMARY = "primary"
20 SECONDARY = "secondary"
21 SUCCESS = "success"
22 WARNING = "warning"
23 DANGER = "danger"
24 INFO = "info"
27@dataclass
28class ActionContext:
29 """Contextual information passed to action execution.
31 Carries the request, authenticated user, resource name,
32 authorizer, audit writer, request-metadata fields, and an
33 optional data source that together describe the environment
34 in which an action runs.
35 """
37 request: Any | None = None
38 user: Any | None = None
39 resource_name: str = ""
40 resource_prefix: str = ""
41 authorizer: Any | None = None
42 audit_writer: Any | None = None
43 correlation_id: str | None = None
44 request_id: str | None = None
45 request_ip: str | None = None
46 metadata: dict[str, Any] = field(default_factory=dict)
47 record_id: str | None = None
48 data_source: Any | None = None
51@dataclass(frozen=True, kw_only=True)
52class ConfirmationConfig:
53 """Configuration for action confirmation dialogs.
55 Attributes:
56 title: Required dialog title.
57 message: Optional explanatory body text.
58 style: Visual style of the confirmation. Defaults to WARNING.
59 """
61 title: str
62 message: str | None = None
63 style: ActionColor = ActionColor.WARNING
66__all__ = [
67 "ActionColor",
68 "ActionContext",
69 "ConfirmationConfig",
70]