From 3720034464f4199b98a2c1cbd310193d5bf90672 Mon Sep 17 00:00:00 2001 From: jelveh Date: Tue, 7 Jul 2026 09:31:43 -0700 Subject: [PATCH] Make Apps the default dashboard tab Treat the Apps tab as the default (root URL) instead of Home. UIDashboard now reads an initial route from window.dashboard_initial_route?.tab and falls back to 'apps' for unknown/absent routes. Sidebar and section active class logic and tab href/hash generation were updated so 'apps' uses the clean root URL while all other tabs (including home) use #tab. The history.pushState logic was adjusted accordingly. parseDashboardRoute in initgui.js was updated to default to 'apps' and its comment clarified the new behavior. --- src/gui/src/UI/Dashboard/UIDashboard.js | 18 +++++++++++++----- src/gui/src/initgui.js | 7 ++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/gui/src/UI/Dashboard/UIDashboard.js b/src/gui/src/UI/Dashboard/UIDashboard.js index 8fdedf1b9..f01c9bbe2 100644 --- a/src/gui/src/UI/Dashboard/UIDashboard.js +++ b/src/gui/src/UI/Dashboard/UIDashboard.js @@ -69,6 +69,13 @@ async function UIDashboard (options) { // Dispatch 'dashboard-will-open' event to allow extensions to add tabs window.dispatchEvent(new CustomEvent('dashboard-will-open', { detail: { tabs } })); + // Tab to render active on open. Apps is the default (root URL / no hash); + // Home is reached via #home. Fall back to Apps for an unknown/absent route. + const routeTab = window.dashboard_initial_route?.tab; + const initialTabId = tabs.some(t => t !== '-' && t.id === routeTab) + ? routeTab + : 'apps'; + let h = ''; h += '
'; @@ -96,8 +103,8 @@ async function UIDashboard (options) { h += '
'; continue; } - const isActive = i === 0 ? ' active' : ''; - const tabHash = tab.id === 'home' ? '' : `#${tab.id}`; + const isActive = tab.id === initialTabId ? ' active' : ''; + const tabHash = tab.id === 'apps' ? '' : `#${tab.id}`; const tabHref = tabHash || window.location.pathname; h += ``; h += tab.icon; @@ -121,7 +128,7 @@ async function UIDashboard (options) { for ( let i = 0; i < tabs.length; i++ ) { const tab = tabs[i]; if ( tab === '-' ) continue; - const isActive = i === 0 ? ' active' : ''; + const isActive = tab.id === initialTabId ? ' active' : ''; h += `
`; h += tab.html(); h += '
'; @@ -314,8 +321,9 @@ async function UIDashboard (options) { document.querySelector('.dashboard-content').setAttribute('class', 'dashboard-content'); document.querySelector('.dashboard-content').classList.add(section); - // Update hash to reflect current tab - const newHash = section === 'home' ? '' : section; + // Update hash to reflect current tab. Apps is the default tab, so it + // uses the clean root URL; every other tab (including home) uses #tab. + const newHash = section === 'apps' ? '' : section; history.pushState(null, '', newHash ? `#${newHash}` : window.location.pathname); // Scroll content area to top diff --git a/src/gui/src/initgui.js b/src/gui/src/initgui.js index 0e7ca5605..88922279c 100644 --- a/src/gui/src/initgui.js +++ b/src/gui/src/initgui.js @@ -184,15 +184,16 @@ if ( jQuery ) { /** * Parses the dashboard URL hash into a route object. - * Hash format: #usage or #account etc. + * Apps is the default tab (root URL / no hash); Home is reached via #home. + * Hash format: #home or #usage or #account etc. * @returns {{ tab: string }} Route object with tab name */ function parseDashboardRoute () { const hash = decodeURIComponent(window.location.hash.slice(1)); - if ( ! hash ) return { tab: 'home' }; + if ( ! hash ) return { tab: 'apps' }; const tab = hash.split('/').filter(Boolean)[0]; - return { tab: tab || 'home' }; + return { tab: tab || 'apps' }; } // Make parseDashboardRoute available globally for hashchange handler