refactor(webui): remove leftover redirect components; one working kernel redirect

config-redirect/, peers/, ssh/ were redirect-only shim components (just a
feature.json each) whose handlers re-entered navigate() and were silently
no-op'd by the isLoading guard — i.e. the legacy /config /peers /ssh URLs were
broken, and nothing in the UI links to them. Replace all three with a single
_legacyRedirect() at the top of navigate() (before the guard, so it actually
works) that rewrites them to the canonical /admin/* path. Removed the 3
folders, their manifest entries, the 3 dead spa.js handlers, and their
setupRoutes() lines. components/ is now exactly the 6 real pages; the real
SSH/Peers pages live (as before) under admin/ssh and admin/peers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
This commit is contained in:
librelad 2026-05-30 15:47:37 +01:00
parent 2304aed213
commit e30c20fde6
5 changed files with 31 additions and 77 deletions

View File

@ -1,8 +0,0 @@
{
"id": "config-redirect",
"routes": ["/config", "/config*"],
"handler": "handleConfigRedirect",
"navId": "nav-config",
"order": 45,
"note": "Legacy /config* -> /admin redirect. No module; routes to the legacy handler."
}

View File

@ -46,15 +46,6 @@
"order": 40
}
},
{
"id": "config-redirect",
"routes": [
"/config",
"/config*"
],
"handler": "handleConfigRedirect",
"navId": "nav-config"
},
{
"id": "tasks",
"routes": [
@ -95,24 +86,6 @@
"label": "Backups",
"order": 50
}
},
{
"id": "peers",
"routes": [
"/peers",
"/peers*"
],
"handler": "handlePeers",
"navId": "nav-config"
},
{
"id": "ssh",
"routes": [
"/ssh",
"/ssh*"
],
"handler": "handleSsh",
"navId": "nav-config"
}
]
}

View File

@ -1,8 +0,0 @@
{
"id": "peers",
"routes": ["/peers", "/peers*"],
"handler": "handlePeers",
"navId": "nav-config",
"order": 70,
"note": "Legacy /peers* -> /admin/tools/peers redirect. No module; routes to the legacy handler."
}

View File

@ -1,8 +0,0 @@
{
"id": "ssh",
"routes": ["/ssh", "/ssh*"],
"handler": "handleSsh",
"navId": "nav-config",
"order": 80,
"note": "Legacy /ssh* -> /admin/tools/ssh-access redirect. No module; routes to the legacy handler."
}

View File

@ -71,16 +71,12 @@ class LibrePortalSPAClean {
this.routes.set('/app*', () => this.handleAppDetail());
this.routes.set('/admin', () => this.handleAdmin()); // Admin area (path-based: /admin/config/<x>, /admin/tools/<x>)
this.routes.set('/admin*', () => this.handleAdmin());
this.routes.set('/config', () => this.handleConfigRedirect()); // legacy → /admin
this.routes.set('/config*', () => this.handleConfigRedirect());
this.routes.set('/tasks', () => this.handleTasks()); // Handle /tasks without query
this.routes.set('/tasks*', () => this.handleTasks()); // Handle /tasks with query
this.routes.set('/backup', () => this.handleBackup());
this.routes.set('/backup*', () => this.handleBackup());
this.routes.set('/peers', () => this.handlePeers()); // legacy → /admin/tools/peers
this.routes.set('/peers*', () => this.handlePeers());
this.routes.set('/ssh', () => this.handleSsh()); // legacy → /admin/tools/ssh-access
this.routes.set('/ssh*', () => this.handleSsh());
// Legacy /config, /peers, /ssh are handled by _legacyRedirect() at the top
// of navigate() (rewrites to the canonical /admin/* path).
//console.log('📍 Routes registered:', Array.from(this.routes.keys()));
}
@ -224,6 +220,18 @@ class LibrePortalSPAClean {
async navigate(path, addToHistory = true) {
// console.log('🚀 SPA: navigate called with:', path, 'addToHistory:', addToHistory);
// Legacy URL redirects (the old /ssh, /peers, /config short URLs → the Admin
// area). Rewritten here, at the top of navigate() and BEFORE the isLoading
// guard, so the canonical /admin/* path is what mounts + shows in the address
// bar. This replaces the former config-redirect/peers/ssh redirect
// components (whose handlers re-entered navigate() and were silently no-op'd
// by the guard below).
const redirected = this._legacyRedirect(path);
if (redirected && redirected !== path) {
path = redirected;
try { history.replaceState({ route: path }, '', path); } catch (_) {}
}
if (this.isLoading) {
// console.log('⏳ Navigation already in progress, ignoring:', path);
return;
@ -379,14 +387,22 @@ class LibrePortalSPAClean {
}
}
async handlePeers() {
// Legacy /peers → Peers under the Admin area.
this.navigate('/admin/tools/peers', true);
}
async handleSsh() {
// Legacy /ssh → SSH Access under the Admin area.
this.navigate('/admin/tools/ssh-access', true);
// Map a legacy short URL (/ssh, /peers, /config[?=cat]) to its canonical
// /admin/* path, or return null if it isn't a legacy redirect. Used at the top
// of navigate(). Replaces the old config-redirect/peers/ssh handlers.
_legacyRedirect(path) {
const full = path || '';
const p = full.split('?')[0];
if (p === '/ssh' || p.startsWith('/ssh/')) return '/admin/tools/ssh-access';
if (p === '/peers' || p.startsWith('/peers/')) return '/admin/tools/peers';
if (p === '/config' || p.startsWith('/config/') || full.startsWith('/config?')) {
let cat = 'overview';
if (full.includes('?=')) cat = full.split('?=')[1] || 'overview';
else if (full.includes('?')) cat = new URLSearchParams(full.split('?')[1]).get('config') || 'overview';
else { const seg = p.replace(/^\/config\/?/, ''); if (seg) cat = seg; }
return (typeof window.adminPath === 'function') ? window.adminPath(cat) : '/admin';
}
return null;
}
async handleApps() {
@ -520,17 +536,6 @@ class LibrePortalSPAClean {
}
// Legacy /config and /config?=<x> → the path-based /admin equivalent.
async handleConfigRedirect() {
const search = window.location.search || '';
let cat = 'overview';
if (search.includes('?=')) {
cat = (window.location.pathname + search).split('?=')[1] || 'overview';
} else {
cat = new URLSearchParams(search).get('config') || 'overview';
}
this.navigate(window.adminPath(cat), true);
}
async handleTasks() {
//console.log('📋 Loading tasks...');