feat: compose stable product surfaces
Module Package Release / publish-packages (push) Successful in 13s
Module Package Release / publish-packages (push) Successful in 13s
This commit is contained in:
@@ -22,7 +22,9 @@ from govoplan_core.core.modules import (
|
||||
FrontendRoute,
|
||||
ModuleManifest,
|
||||
NavItem,
|
||||
ProductAvailabilityExplanation,
|
||||
ProductAreaContribution,
|
||||
ProductSurfaceContribution,
|
||||
PublicFrontendRoute,
|
||||
QuickAccessTool,
|
||||
SUPPORTED_PRESENTATION_CONTRACT_VERSION,
|
||||
@@ -254,6 +256,47 @@ def _product_area_payload(area: ProductAreaContribution) -> dict[str, object]:
|
||||
}
|
||||
|
||||
|
||||
def _product_availability_payload(
|
||||
explanation: ProductAvailabilityExplanation,
|
||||
) -> dict[str, object]:
|
||||
return {
|
||||
"reason": explanation.reason,
|
||||
"title": explanation.title,
|
||||
"description": explanation.description,
|
||||
"resolution": explanation.resolution,
|
||||
"responsible_role": explanation.responsible_role,
|
||||
}
|
||||
|
||||
|
||||
def _product_surface_payload(surface: ProductSurfaceContribution) -> dict[str, object]:
|
||||
return {
|
||||
"contract_version": surface.contract_version,
|
||||
"id": surface.id,
|
||||
"module_id": surface.module_id,
|
||||
"label": surface.label,
|
||||
"description": surface.description,
|
||||
"icon": surface.icon,
|
||||
"entry_path": surface.entry_path,
|
||||
"route_path": surface.route_path,
|
||||
"surface_ids": list(surface.surface_ids),
|
||||
"presentations": list(surface.presentations),
|
||||
"capability_ids": list(surface.capability_ids),
|
||||
"search_source_ids": list(surface.search_source_ids),
|
||||
"help_context_ids": list(surface.help_context_ids),
|
||||
"documentation_topic_ids": list(surface.documentation_topic_ids),
|
||||
"required_all": list(surface.required_all),
|
||||
"required_any": list(surface.required_any),
|
||||
"aliases": list(surface.aliases),
|
||||
"order": surface.order,
|
||||
"unavailable": _product_availability_payload(surface.unavailable),
|
||||
"degraded": (
|
||||
_product_availability_payload(surface.degraded)
|
||||
if surface.degraded is not None
|
||||
else None
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
def _quick_access_tool_payload(tool: QuickAccessTool) -> dict[str, object]:
|
||||
return {
|
||||
"id": tool.id,
|
||||
@@ -372,6 +415,10 @@ def _frontend_payload(
|
||||
"product_areas": [
|
||||
_product_area_payload(area) for area in frontend.product_areas
|
||||
],
|
||||
"product_surfaces": [
|
||||
_product_surface_payload(surface)
|
||||
for surface in frontend.product_surfaces
|
||||
],
|
||||
"quick_access_tools": [
|
||||
_quick_access_tool_payload(tool) for tool in frontend.quick_access_tools
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user