fix: Hide search bar and Drive/Tasks nav when logged out, improve theme switching

- Hide omnibox search bar when user is not logged in
- Hide Drive, Tasks, CRM, and Calendar navigation items when logged out
- Update theme manager to use correct CSS path (/suite/public/themes/)
- Improve theme switching to update all color variables including --color1/--color2
- Fix bot config color override logic to respect user's theme selection
- Add disconnect notification flag to prevent duplicate notifications

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Rodrigo Rodriguez 2026-02-15 21:53:50 +00:00
parent ccee337522
commit 8bb8f9d96a
3 changed files with 74 additions and 18 deletions

View file

@ -991,9 +991,26 @@
.then(function(config) {
if (!config) return;
// Check if user has explicitly selected a theme (not the default)
var userTheme = localStorage.getItem("gb-theme");
var useThemeColors = userTheme && userTheme !== "default" && userTheme !== "light";
// Get the theme manager's theme for this bot to check if user selected a different theme
var botId = botName.toLowerCase();
var botTheme = window.ThemeManager ? (
// Get bot-specific theme from theme manager's mapping
(window.ThemeManager.getAvailableThemes &&
window.ThemeManager.getAvailableThemes().find(t => t.id === botId)) ||
// Fallback to localStorage
localStorage.getItem("gb-theme")
) : localStorage.getItem("gb-theme");
// Check if bot config has a theme-base setting
var configThemeBase = config.theme_base || config["theme-base"] || "light";
// Only use bot config colors if:
// 1. No theme has been explicitly selected by user (localStorage empty or default)
// 2. AND the bot config's theme-base matches the current theme
var localStorageTheme = localStorage.getItem("gb-theme");
var useBotConfigColors = !localStorageTheme ||
localStorageTheme === "default" ||
localStorageTheme === configThemeBase;
// Apply colors from config (API returns snake_case)
var color1 = config.theme_color1 || config["theme-color1"] || config["Theme Color"] || "#3b82f6";
@ -1001,8 +1018,8 @@
var title = config.theme_title || config["theme-title"] || botName;
var logo = config.theme_logo || config["theme-logo"] || "";
// Only set bot config colors if user hasn't selected a custom theme
if (!useThemeColors) {
// Only set bot config colors if user hasn't selected a different theme
if (useBotConfigColors) {
document.documentElement.style.setProperty("--chat-color1", color1);
document.documentElement.style.setProperty("--chat-color2", color2);
document.documentElement.style.setProperty("--suggestion-color", color1);
@ -1011,6 +1028,9 @@
document.documentElement.style.setProperty("--color2", color2);
document.documentElement.style.setProperty("--primary", color1);
document.documentElement.style.setProperty("--accent", color1);
console.log("Bot config colors applied:", {color1: color1, color2: color2});
} else {
console.log("Bot config colors skipped - user selected custom theme:", localStorageTheme);
}
// Update logo if provided

View file

@ -1286,6 +1286,21 @@ document.addEventListener("DOMContentLoaded", () => {
if (settingsBtn) settingsBtn.style.display = "";
if (appsButton) appsButton.style.display = "";
if (notificationsBtn) notificationsBtn.style.display = "";
// Show omnibox (search bar) when signed in
const omnibox = document.getElementById("omnibox");
if (omnibox) omnibox.style.display = "";
// Show Drive, Tasks, CRM, and Calendar navigation when signed in (all instances)
const driveTabs = document.querySelectorAll('[data-section="drive"]');
const tasksTabs = document.querySelectorAll('[data-section="tasks"]');
const crmTabs = document.querySelectorAll('[data-section="crm"]');
const calendarTabs = document.querySelectorAll('[data-section="calendar"]');
driveTabs.forEach(tab => tab.style.display = "");
tasksTabs.forEach(tab => tab.style.display = "");
crmTabs.forEach(tab => tab.style.display = "");
calendarTabs.forEach(tab => tab.style.display = "");
}
function loadUserProfile() {
@ -1360,6 +1375,21 @@ document.addEventListener("DOMContentLoaded", () => {
if (settingsBtn) settingsBtn.style.display = "none";
if (appsButton) appsButton.style.display = "none";
if (notificationsBtn) notificationsBtn.style.display = "none";
// Hide omnibox (search bar) when signed out
const omnibox = document.getElementById("omnibox");
if (omnibox) omnibox.style.display = "none";
// Hide Drive, Tasks, CRM, and Calendar navigation when signed out (all instances)
const driveTabs = document.querySelectorAll('[data-section="drive"]');
const tasksTabs = document.querySelectorAll('[data-section="tasks"]');
const crmTabs = document.querySelectorAll('[data-section="crm"]');
const calendarTabs = document.querySelectorAll('[data-section="calendar"]');
driveTabs.forEach(tab => tab.style.display = "none");
tasksTabs.forEach(tab => tab.style.display = "none");
crmTabs.forEach(tab => tab.style.display = "none");
calendarTabs.forEach(tab => tab.style.display = "none");
}
// Try to load cached user first

View file

@ -7,7 +7,7 @@ const ThemeManager = (() => {
const botThemeMap = {
// Default bot uses light theme with brown accents
"default": "light",
// Cristo bot uses mellowgold theme with earth tones
// Cristo bot uses mellowgold theme with earth tones (perfect for sanctuary/church)
"cristo": "mellowgold",
// Salesianos bot uses light theme with blue accents
"salesianos": "light",
@ -81,21 +81,27 @@ const ThemeManager = (() => {
currentThemeId = id;
localStorage.setItem("gb-theme", id);
// Get the theme's primary color from CSS variables
const rootStyle = getComputedStyle(document.documentElement);
const primaryColor = rootStyle.getPropertyValue("--primary")?.trim() || "#3b82f6";
const cardColor = rootStyle.getPropertyValue("--card")?.trim() || "#fafafa";
// Small delay to ensure CSS variables are applied
setTimeout(() => {
// Get the theme's primary color from CSS variables
const rootStyle = getComputedStyle(document.documentElement);
const primaryColor = rootStyle.getPropertyValue("--primary")?.trim() || "#3b82f6";
const cardColor = rootStyle.getPropertyValue("--card")?.trim() || "#fafafa";
// Update chat-specific CSS variables to match the theme
document.documentElement.style.setProperty("--chat-color1", primaryColor);
document.documentElement.style.setProperty("--chat-color2", cardColor);
document.documentElement.style.setProperty("--suggestion-color", primaryColor);
document.documentElement.style.setProperty("--suggestion-bg", cardColor);
// Update ALL color-related CSS variables to match the theme
// This overrides any bot config colors
document.documentElement.style.setProperty("--chat-color1", primaryColor);
document.documentElement.style.setProperty("--chat-color2", cardColor);
document.documentElement.style.setProperty("--suggestion-color", primaryColor);
document.documentElement.style.setProperty("--suggestion-bg", cardColor);
document.documentElement.style.setProperty("--color1", primaryColor);
document.documentElement.style.setProperty("--color2", cardColor);
console.log("✓ Chat colors updated to match theme:", { primary: primaryColor, card: cardColor });
console.log("✓ Chat colors updated to match theme:", { primary: primaryColor, card: cardColor });
updateDropdown();
subscribers.forEach((cb) => cb({ themeId: id, themeName: theme.name }));
updateDropdown();
subscribers.forEach((cb) => cb({ themeId: id, themeName: theme.name }));
}, 50);
};
link.onerror = () => console.error("✗ Failed:", theme.name);
document.head.appendChild(link);