feat: implement merge_missing_catalog_widgets function to enhance dashboard layout
- Added the `merge_missing_catalog_widgets` function to append missing widget IDs from the catalog to the dashboard layout while preserving the existing order. - Updated the admin and app dashboard routes to utilize the new function, ensuring that new catalog entries are visible without requiring users to reset their layouts. - Enhanced tests to validate the functionality of the new merging logic, ensuring proper integration with existing layouts. - Bumped application version to reflect these changes.
This commit is contained in:
1 parent
2453da0da1
commit
01c0d1745f
6 files changed
+53
-6
No files matched your search
@@ -14,7 +14,12 @@ from fastapi import APIRouter, HTTPException, Depends
|
||||
from db import get_db, get_cursor, r2d
|
||||
from auth import require_admin, hash_pin
|
||||
from models import AdminProfileUpdate
|
||||
from dashboard_layout_schema import ALLOWED_WIDGET_IDS, DashboardLayoutPayload, product_default_layout_dict
|
||||
from dashboard_layout_schema import (
|
||||
ALLOWED_WIDGET_IDS,
|
||||
DashboardLayoutPayload,
|
||||
merge_missing_catalog_widgets,
|
||||
product_default_layout_dict,
|
||||
)
|
||||
from dashboard_widget_entitlements import widgets_catalog_admin_payload
|
||||
from widget_catalog import WIDGET_CATALOG
|
||||
from widget_feature_requirements_db import (
|
||||
@@ -184,7 +189,7 @@ def admin_get_dashboard_product_default(session: dict = Depends(require_admin)):
|
||||
"""Aktueller Produkt-Dashboard-Standard (DB oder Code)."""
|
||||
_ = session
|
||||
with get_db() as conn:
|
||||
layout = get_product_default_base_dict(conn)
|
||||
layout = merge_missing_catalog_widgets(get_product_default_base_dict(conn))
|
||||
from_database = get_stored_product_default_validated(conn) is not None
|
||||
code_ref = product_default_layout_dict()
|
||||
return {
|
||||
@@ -217,7 +222,7 @@ def admin_delete_dashboard_product_default(session: dict = Depends(require_admin
|
||||
_ = session
|
||||
with get_db() as conn:
|
||||
delete_product_default_override(conn)
|
||||
layout = get_product_default_base_dict(conn)
|
||||
layout = merge_missing_catalog_widgets(get_product_default_base_dict(conn))
|
||||
return {"ok": True, "layout": layout, "from_database": False}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user