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.
This commit is contained in:
jelveh
2026-07-07 09:31:43 -07:00
parent de6cab1f9a
commit 3720034464
2 changed files with 17 additions and 8 deletions
+13 -5
View File
@@ -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 += '<div class="dashboard">';
@@ -96,8 +103,8 @@ async function UIDashboard (options) {
h += '<hr class="dashboard-sidebar-separator">';
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 += `<a class="dashboard-sidebar-item allow-native-ctxmenu${isActive}" href="${tabHref}" data-section="${tab.id}" data-tooltip="${html_encode(tab.label)}">`;
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 += `<div class="dashboard-section dashboard-section-${tab.id}${isActive}" data-section="${tab.id}">`;
h += tab.html();
h += '</div>';
@@ -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
+4 -3
View File
@@ -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