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:
parent
2304aed213
commit
e30c20fde6
@ -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."
|
|
||||||
}
|
|
||||||
@ -46,15 +46,6 @@
|
|||||||
"order": 40
|
"order": 40
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "config-redirect",
|
|
||||||
"routes": [
|
|
||||||
"/config",
|
|
||||||
"/config*"
|
|
||||||
],
|
|
||||||
"handler": "handleConfigRedirect",
|
|
||||||
"navId": "nav-config"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "tasks",
|
"id": "tasks",
|
||||||
"routes": [
|
"routes": [
|
||||||
@ -95,24 +86,6 @@
|
|||||||
"label": "Backups",
|
"label": "Backups",
|
||||||
"order": 50
|
"order": 50
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "peers",
|
|
||||||
"routes": [
|
|
||||||
"/peers",
|
|
||||||
"/peers*"
|
|
||||||
],
|
|
||||||
"handler": "handlePeers",
|
|
||||||
"navId": "nav-config"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "ssh",
|
|
||||||
"routes": [
|
|
||||||
"/ssh",
|
|
||||||
"/ssh*"
|
|
||||||
],
|
|
||||||
"handler": "handleSsh",
|
|
||||||
"navId": "nav-config"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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."
|
|
||||||
}
|
|
||||||
@ -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."
|
|
||||||
}
|
|
||||||
@ -71,16 +71,12 @@ class LibrePortalSPAClean {
|
|||||||
this.routes.set('/app*', () => this.handleAppDetail());
|
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()); // Admin area (path-based: /admin/config/<x>, /admin/tools/<x>)
|
||||||
this.routes.set('/admin*', () => this.handleAdmin());
|
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 without query
|
||||||
this.routes.set('/tasks*', () => this.handleTasks()); // Handle /tasks with 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('/backup*', () => this.handleBackup());
|
this.routes.set('/backup*', () => this.handleBackup());
|
||||||
this.routes.set('/peers', () => this.handlePeers()); // legacy → /admin/tools/peers
|
// Legacy /config, /peers, /ssh are handled by _legacyRedirect() at the top
|
||||||
this.routes.set('/peers*', () => this.handlePeers());
|
// of navigate() (rewrites to the canonical /admin/* path).
|
||||||
this.routes.set('/ssh', () => this.handleSsh()); // legacy → /admin/tools/ssh-access
|
|
||||||
this.routes.set('/ssh*', () => this.handleSsh());
|
|
||||||
|
|
||||||
//console.log('📍 Routes registered:', Array.from(this.routes.keys()));
|
//console.log('📍 Routes registered:', Array.from(this.routes.keys()));
|
||||||
}
|
}
|
||||||
@ -223,7 +219,19 @@ class LibrePortalSPAClean {
|
|||||||
|
|
||||||
async navigate(path, addToHistory = true) {
|
async navigate(path, addToHistory = true) {
|
||||||
// console.log('🚀 SPA: navigate called with:', path, 'addToHistory:', addToHistory);
|
// 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) {
|
if (this.isLoading) {
|
||||||
// console.log('⏳ Navigation already in progress, ignoring:', path);
|
// console.log('⏳ Navigation already in progress, ignoring:', path);
|
||||||
return;
|
return;
|
||||||
@ -379,14 +387,22 @@ class LibrePortalSPAClean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async handlePeers() {
|
// Map a legacy short URL (/ssh, /peers, /config[?=cat]) to its canonical
|
||||||
// Legacy /peers → Peers under the Admin area.
|
// /admin/* path, or return null if it isn't a legacy redirect. Used at the top
|
||||||
this.navigate('/admin/tools/peers', true);
|
// of navigate(). Replaces the old config-redirect/peers/ssh handlers.
|
||||||
}
|
_legacyRedirect(path) {
|
||||||
|
const full = path || '';
|
||||||
async handleSsh() {
|
const p = full.split('?')[0];
|
||||||
// Legacy /ssh → SSH Access under the Admin area.
|
if (p === '/ssh' || p.startsWith('/ssh/')) return '/admin/tools/ssh-access';
|
||||||
this.navigate('/admin/tools/ssh-access', true);
|
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() {
|
async handleApps() {
|
||||||
@ -520,17 +536,6 @@ class LibrePortalSPAClean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Legacy /config and /config?=<x> → the path-based /admin equivalent.
|
// 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() {
|
async handleTasks() {
|
||||||
//console.log('📋 Loading tasks...');
|
//console.log('📋 Loading tasks...');
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user