From eec7f2ada5e304aa0a4e4d877037dda7a7ea5816 Mon Sep 17 00:00:00 2001 From: Steven RYDELL Date: Wed, 29 Jul 2026 11:23:50 +0200 Subject: [PATCH] Redirect to a default page when the URL has no view --- src/pages/AdminPanel.tsx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/pages/AdminPanel.tsx b/src/pages/AdminPanel.tsx index c972b9b..bbc5e66 100644 --- a/src/pages/AdminPanel.tsx +++ b/src/pages/AdminPanel.tsx @@ -220,6 +220,30 @@ export default function AdminPanel() { } if (section) { + if (!viewName) { + // A section URL without a view (e.g. /Settings alone, or an unknown + // section like /admin) should land on a real page instead of the + // dead-end "Select a view" empty state. + const ownLayout = layouts.find((l) => l.name.toLowerCase() === section.toLowerCase()); + if (ownLayout) { + const link = + findFirstAccessibleLinkInLayout(schema, ownLayout, edition, canGet, hasPerm) ?? + findFirstVisibleLinkInLayout(schema, ownLayout, edition, canGet, hasPerm); + if (link) { + setActiveSection(ownLayout.name); + navigate(`/${ownLayout.name}/${link}`, { replace: true }); + return; + } + } + const target = pickDefault(); + if (target) { + setActiveSection(target.layoutName); + if (target.link) { + navigate(`/${target.layoutName}/${target.link}`, { replace: true }); + } + } + return; + } setActiveSection(section); return; }