diff --git a/ui/suite/js/base.js b/ui/suite/js/base.js index 0b43021..164a083 100644 --- a/ui/suite/js/base.js +++ b/ui/suite/js/base.js @@ -47,12 +47,15 @@ function applyProductConfig(config) { // Check if we have compiled_features info to filter even further // This ensures we don't show apps that are enabled in config but not compiled in binary if (config.compiled_features && Array.isArray(config.compiled_features)) { - const compiledSet = new Set(config.compiled_features.map(f => f.toLowerCase())); - effectiveApps = effectiveApps.filter(app => - compiledSet.has(app.toLowerCase()) || - app.toLowerCase() === 'settings' || - app.toLowerCase() === 'auth' || - app.toLowerCase() === 'admin' // Admin usually contains settings which is always there + const compiledSet = new Set( + config.compiled_features.map((f) => f.toLowerCase()), + ); + effectiveApps = effectiveApps.filter( + (app) => + compiledSet.has(app.toLowerCase()) || + app.toLowerCase() === "settings" || + app.toLowerCase() === "auth" || + app.toLowerCase() === "admin", // Admin usually contains settings which is always there ); // Also call a helper to hide UI elements for non-compiled features explicitly @@ -61,6 +64,33 @@ function applyProductConfig(config) { } filterAppsByConfig(effectiveApps); + + // Check if there are any visible apps after filtering + const hasVisibleApps = effectiveApps.length > 0; + + // Hide apps menu button if menu launcher is disabled or if there are no apps to show + if (config.menu_launcher_enabled === false || !hasVisibleApps) { + const appsButton = document.getElementById("appsButton"); + if (appsButton) { + appsButton.style.display = "none"; + } + const appsMenuContainer = document.querySelector(".apps-menu-container"); + if (appsMenuContainer) { + appsMenuContainer.style.display = "none"; + } + } + } + + // Hide omnibox if search is disabled + if (config.search_enabled === false) { + const omnibox = document.getElementById("omnibox"); + if (omnibox) { + omnibox.style.display = "none"; + } + const headerCenter = document.querySelector(".header-center"); + if (headerCenter) { + headerCenter.style.display = "none"; + } } // Apply custom logo @@ -95,21 +125,25 @@ function applyProductConfig(config) { // Hide UI elements that require features not compiled in the binary function hideNonCompiledUI(compiledSet) { // Hide elements with data-feature attribute that aren't in compiled set - document.querySelectorAll('[data-feature]').forEach(el => { - const feature = el.getAttribute('data-feature').toLowerCase(); + document.querySelectorAll("[data-feature]").forEach((el) => { + const feature = el.getAttribute("data-feature").toLowerCase(); // Allow settings/admin as they are usually core - if (!compiledSet.has(feature) && feature !== 'settings' && feature !== 'admin') { - el.style.display = 'none'; - el.classList.add('hidden-uncompiled'); + if ( + !compiledSet.has(feature) && + feature !== "settings" && + feature !== "admin" + ) { + el.style.display = "none"; + el.classList.add("hidden-uncompiled"); } }); // Also look for specific sections that might map to features // e.g. .feature-mail, .feature-meet classes - compiledSet.forEach(feature => { - // This loop defines what IS available. + compiledSet.forEach((feature) => { + // This loop defines what IS available. // Logic should be inverse: find all feature- classes and hide if not in set - // But scanning all classes is expensive. + // But scanning all classes is expensive. // Better to rely on data-feature or explicit app hiding which filterAppsByConfig does. }); }