Compare commits

..

No commits in common. "e03c900f2061c67ab3ebbd9ec82bb6d6326d3307" and "2304aed2139db5ee87a61d211abc346c67b67274" have entirely different histories.

5 changed files with 77 additions and 31 deletions

View File

@ -0,0 +1,8 @@
{
"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,6 +46,15 @@
"order": 40 "order": 40
} }
}, },
{
"id": "config-redirect",
"routes": [
"/config",
"/config*"
],
"handler": "handleConfigRedirect",
"navId": "nav-config"
},
{ {
"id": "tasks", "id": "tasks",
"routes": [ "routes": [
@ -86,6 +95,24 @@
"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"
} }
] ]
} }

View File

@ -0,0 +1,8 @@
{
"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

@ -0,0 +1,8 @@
{
"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,12 +71,16 @@ 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());
// Legacy /config, /peers, /ssh are handled by _legacyRedirect() at the top this.routes.set('/peers', () => this.handlePeers()); // legacy → /admin/tools/peers
// of navigate() (rewrites to the canonical /admin/* path). this.routes.set('/peers*', () => this.handlePeers());
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()));
} }
@ -219,19 +223,7 @@ 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;
@ -387,22 +379,14 @@ class LibrePortalSPAClean {
} }
} }
// Map a legacy short URL (/ssh, /peers, /config[?=cat]) to its canonical async handlePeers() {
// /admin/* path, or return null if it isn't a legacy redirect. Used at the top // Legacy /peers → Peers under the Admin area.
// of navigate(). Replaces the old config-redirect/peers/ssh handlers. this.navigate('/admin/tools/peers', true);
_legacyRedirect(path) { }
const full = path || '';
const p = full.split('?')[0]; async handleSsh() {
if (p === '/ssh' || p.startsWith('/ssh/')) return '/admin/tools/ssh-access'; // Legacy /ssh → SSH Access under the Admin area.
if (p === '/peers' || p.startsWith('/peers/')) return '/admin/tools/peers'; this.navigate('/admin/tools/ssh-access', true);
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() {
@ -536,6 +520,17 @@ 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...');