Coverage for src / lexigram / admin / settings / panel / types.py: 94%
16 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-13 22:14 +0800
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-13 22:14 +0800
1"""Type definitions for Configuration Center."""
3from __future__ import annotations
5from dataclasses import dataclass
7from lexigram.domain import DomainModel
8from lexigram.validation import Field
10__all__ = [
11 "DEFAULT_CATEGORIES",
12 "ConfigCategory",
13 "get_default_categories",
14]
17@dataclass(init=False)
18class ConfigCategory(DomainModel):
19 """A grouping of configuration specs.
21 Categories organize related configuration specs into logical groups
22 displayed in the Configuration Center sidebar.
24 Attributes:
25 name: Internal identifier (e.g., "env", "app", "system")
26 label: Display label (e.g., "Environment", "Application", "System")
27 icon: Icon identifier for the category header
28 order: Sort order for display (lower = higher priority)
29 description: Optional description shown in the UI
30 """
32 name: str
33 label: str
34 icon: str = Field(default="folder")
35 order: int = Field(default=100)
36 description: str = Field(default="")
38 # Populated dynamically from registry
39 specs: list = Field(default_factory=list)
42# Default category definitions
43DEFAULT_CATEGORIES: tuple[ConfigCategory, ...] = (
44 ConfigCategory(
45 name="env",
46 label="Environment",
47 icon="server",
48 order=10,
49 description="Environment variables and runtime configuration",
50 ),
51 ConfigCategory(
52 name="app",
53 label="Application",
54 icon="layout",
55 order=20,
56 description="Application-specific settings",
57 ),
58 ConfigCategory(
59 name="system",
60 label="System",
61 icon="settings",
62 order=30,
63 description="Core system and admin interface settings",
64 ),
65)
68def get_default_categories() -> list[ConfigCategory]:
69 """Return a fresh copy of default categories."""
70 return [
71 ConfigCategory(
72 name=c.name,
73 label=c.label,
74 icon=c.icon,
75 order=c.order,
76 description=c.description,
77 )
78 for c in DEFAULT_CATEGORIES
79 ]