feat: Implement user profile preferences for start page, Git identity, and task drawer auto-open, alongside Git server default branch configuration.
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
# [DEF:backend.src.schemas.profile:Module]
|
||||
#
|
||||
# @TIER: STANDARD
|
||||
# @SEMANTICS: profile, schemas, pydantic, preferences, superset, lookup
|
||||
# @PURPOSE: Defines API schemas for profile preference persistence and Superset account lookup flows.
|
||||
# @SEMANTICS: profile, schemas, pydantic, preferences, superset, lookup, security, git, ux
|
||||
# @PURPOSE: Defines API schemas for profile preference persistence, security read-only snapshot, and Superset account lookup.
|
||||
# @LAYER: API
|
||||
# @RELATION: DEPENDS_ON -> pydantic
|
||||
#
|
||||
# @INVARIANT: Schema shapes stay stable for profile UI states and dashboards filter metadata.
|
||||
# @INVARIANT: Schema shapes stay stable for profile UI states and backend preference contracts.
|
||||
|
||||
# [SECTION: IMPORTS]
|
||||
from datetime import datetime
|
||||
@@ -15,6 +15,28 @@ from pydantic import BaseModel, Field
|
||||
# [/SECTION]
|
||||
|
||||
|
||||
# [DEF:ProfilePermissionState:Class]
|
||||
# @TIER: STANDARD
|
||||
# @PURPOSE: Represents one permission badge state for profile read-only security view.
|
||||
class ProfilePermissionState(BaseModel):
|
||||
key: str
|
||||
allowed: bool
|
||||
# [/DEF:ProfilePermissionState:Class]
|
||||
|
||||
|
||||
# [DEF:ProfileSecuritySummary:Class]
|
||||
# @TIER: STANDARD
|
||||
# @PURPOSE: Read-only security and access snapshot for current user.
|
||||
class ProfileSecuritySummary(BaseModel):
|
||||
read_only: bool = True
|
||||
auth_source: Optional[str] = None
|
||||
current_role: Optional[str] = None
|
||||
role_source: Optional[str] = None
|
||||
roles: List[str] = Field(default_factory=list)
|
||||
permissions: List[ProfilePermissionState] = Field(default_factory=list)
|
||||
# [/DEF:ProfileSecuritySummary:Class]
|
||||
|
||||
|
||||
# [DEF:ProfilePreference:Class]
|
||||
# @TIER: STANDARD
|
||||
# @PURPOSE: Represents persisted profile preference for a single authenticated user.
|
||||
@@ -23,6 +45,16 @@ class ProfilePreference(BaseModel):
|
||||
superset_username: Optional[str] = None
|
||||
superset_username_normalized: Optional[str] = None
|
||||
show_only_my_dashboards: bool = False
|
||||
|
||||
git_username: Optional[str] = None
|
||||
git_email: Optional[str] = None
|
||||
has_git_personal_access_token: bool = False
|
||||
git_personal_access_token_masked: Optional[str] = None
|
||||
|
||||
start_page: Literal["dashboards", "datasets", "reports"] = "dashboards"
|
||||
auto_open_task_drawer: bool = True
|
||||
dashboards_table_density: Literal["compact", "comfortable"] = "comfortable"
|
||||
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
@@ -33,16 +65,44 @@ class ProfilePreference(BaseModel):
|
||||
|
||||
# [DEF:ProfilePreferenceUpdateRequest:Class]
|
||||
# @TIER: STANDARD
|
||||
# @PURPOSE: Request payload for updating current user's dashboard filter preference.
|
||||
# @PURPOSE: Request payload for updating current user's profile settings.
|
||||
class ProfilePreferenceUpdateRequest(BaseModel):
|
||||
superset_username: Optional[str] = Field(
|
||||
default=None,
|
||||
description="Apache Superset username bound to current user profile.",
|
||||
)
|
||||
show_only_my_dashboards: bool = Field(
|
||||
default=False,
|
||||
show_only_my_dashboards: Optional[bool] = Field(
|
||||
default=None,
|
||||
description='When true, "/dashboards" can auto-apply profile filter in main context.',
|
||||
)
|
||||
git_username: Optional[str] = Field(
|
||||
default=None,
|
||||
description="Git author username used for commit signature.",
|
||||
)
|
||||
git_email: Optional[str] = Field(
|
||||
default=None,
|
||||
description="Git author email used for commit signature.",
|
||||
)
|
||||
git_personal_access_token: Optional[str] = Field(
|
||||
default=None,
|
||||
description="Personal Access Token value. Empty string clears existing token.",
|
||||
)
|
||||
start_page: Optional[
|
||||
Literal["dashboards", "datasets", "reports", "reports-logs"]
|
||||
] = Field(
|
||||
default=None,
|
||||
description="Preferred start page after login.",
|
||||
)
|
||||
auto_open_task_drawer: Optional[bool] = Field(
|
||||
default=None,
|
||||
description="Auto-open task drawer when long-running tasks start.",
|
||||
)
|
||||
dashboards_table_density: Optional[
|
||||
Literal["compact", "comfortable", "free"]
|
||||
] = Field(
|
||||
default=None,
|
||||
description="Preferred table density for dashboard listings.",
|
||||
)
|
||||
# [/DEF:ProfilePreferenceUpdateRequest:Class]
|
||||
|
||||
|
||||
@@ -54,6 +114,7 @@ class ProfilePreferenceResponse(BaseModel):
|
||||
message: Optional[str] = None
|
||||
validation_errors: List[str] = Field(default_factory=list)
|
||||
preference: ProfilePreference
|
||||
security: ProfileSecuritySummary = Field(default_factory=ProfileSecuritySummary)
|
||||
# [/DEF:ProfilePreferenceResponse:Class]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user