diff --git a/src/app/admin/layout.tsx b/src/app/admin/layout.tsx index f8a0bb09..992cce7b 100644 --- a/src/app/admin/layout.tsx +++ b/src/app/admin/layout.tsx @@ -95,7 +95,6 @@ async function Sidebar({ ({ - key: "", - hrefs: [], - }); - const [storageError, setStorageError] = useState(false); - useEffect(() => { - try { - setSaved({ key, hrefs: parseFavoritePages(localStorage.getItem(key)) }); - } catch { - setSaved({ key, hrefs: [] }); - } - }, [key]); - const favorites = - saved.key === key - ? saved.hrefs.flatMap((href) => items.find((i) => i.href === href) ?? []) - : []; - function save(hrefs: string[]) { - setSaved({ key, hrefs }); - try { - localStorage.setItem(key, JSON.stringify(hrefs)); - setStorageError(false); - } catch { - setStorageError(true); - } - } - return ( -
-

- - {t("favorites")} -

- {favorites.map((item) => ( -
-
- }> - {t(item.labelKey)} - -
- -
- ))} - {favorites.length < 6 && ( - - )} - {storageError && ( -

- {t("favoriteStorageError")} -

- )} -
- ); -} diff --git a/src/components/admin/admin-sidebar-nav.tsx b/src/components/admin/admin-sidebar-nav.tsx index b003550c..116bbe0a 100644 --- a/src/components/admin/admin-sidebar-nav.tsx +++ b/src/components/admin/admin-sidebar-nav.tsx @@ -15,7 +15,6 @@ import type { AdminNavItem } from "@/lib/admin-nav"; import type { AdminNavConfig } from "@/lib/admin-nav-config"; import { visibleAdminNavigation } from "@/lib/admin-navigation"; import { cn } from "@/lib/utils"; -import { AdminFavorites } from "./admin-favorites"; const STORAGE_KEY = "admin-nav-collapsed"; @@ -62,12 +61,10 @@ function persistCollapsed(next: Record) { } export function AdminSidebarNav({ - userId = 0, allowedPermissions = [], isSuperAdmin = false, navConfig = {}, }: { - userId?: number; /** ACL slugs the staff member holds (ignored when isSuperAdmin). */ allowedPermissions?: string[]; isSuperAdmin?: boolean; @@ -263,12 +260,6 @@ export function AdminSidebarNav({
- {!search && ( - group.items)} - /> - )} {visibleGroups.length === 0 && (

{ @@ -36,11 +36,3 @@ it("respects hidden groups, owner order and ACL in every consumer", () => { }).flatMap((g) => g.items); expect(limited.every((i) => !i.permission)).toBe(true); }); -it("rejects malformed favorites, external links and duplicates", () => { - expect(parseFavoritePages("{")).toEqual([]); - expect( - parseFavoritePages( - '["/admin/users","https://evil.test","/admin/users",null,"/admin?token=x"]', - ), - ).toEqual(["/admin/users"]); -}); diff --git a/src/lib/admin-navigation.ts b/src/lib/admin-navigation.ts index b8fc71c1..084a76e2 100644 --- a/src/lib/admin-navigation.ts +++ b/src/lib/admin-navigation.ts @@ -159,22 +159,3 @@ export function visibleAdminNavigation( }); return organized; } - -export function parseFavoritePages(raw: string | null): string[] { - try { - const value: unknown = JSON.parse(raw ?? "[]"); - return Array.isArray(value) - ? [ - ...new Set( - value.filter( - (entry): entry is string => - typeof entry === "string" && - /^\/admin(?:\/[^?#]*)?$/.test(entry), - ), - ), - ].slice(0, 6) - : []; - } catch { - return []; - } -} diff --git a/src/messages/en.json b/src/messages/en.json index 720db918..d773411f 100644 --- a/src/messages/en.json +++ b/src/messages/en.json @@ -1099,10 +1099,6 @@ "catalogFurniture": "Catalog and furniture", "communityContent": "Community and content", "staffPermissions": "Staff and access", - "favorites": "Favorites", - "addFavorite": "Add favorite", - "removeFavorite": "Remove {name} from favorites", - "favoriteStorageError": "Favorites are available for this session; browser storage is unavailable.", "cmsErrors": "CMS errors", "themeBuilder": "Theme builder", "openSidebar": "Open menu", diff --git a/src/messages/it.json b/src/messages/it.json index 000d80e1..245ea6b2 100644 --- a/src/messages/it.json +++ b/src/messages/it.json @@ -1057,10 +1057,6 @@ "catalogFurniture": "Catalogo e furni", "communityContent": "Community e contenuti", "staffPermissions": "Staff e accessi", - "favorites": "Preferiti", - "addFavorite": "Aggiungi preferito", - "removeFavorite": "Rimuovi {name} dai preferiti", - "favoriteStorageError": "Preferiti disponibili per questa sessione: memoria del browser non disponibile.", "cmsErrors": "Errori CMS", "themeBuilder": "Editor del tema", "catalogMaintenance": "Manutenzione catalogo",