fixed wrong warning with single tenant

This commit is contained in:
2026-03-12 12:22:36 +01:00
parent eb748b2fa4
commit 39a113c5fc
2 changed files with 13 additions and 4 deletions

View File

@@ -37,7 +37,7 @@ $allowUserTheme = allowUserTheme();
<div class="app-topbar-center" aria-hidden="true"></div>
<ul class="app-topbar-right">
<?php if ($canSwitchTenant): ?>
<li class="app-topbar-tenant-slot" data-tooltip="<?php e(t('Tenant')); ?>" data-tooltip-pos="bottom">
<li class="app-topbar-tenant-slot" data-tenant-switcher data-tooltip="<?php e(t('Tenant')); ?>" data-tooltip-pos="bottom">
<details class="dropdown app-topbar-tenant-menu">
<summary class="app-topbar-tenant-chip" aria-label="<?php e(t('Switch tenant')); ?>" title="<?php e($tenantLabel); ?>">
<span class="app-topbar-tenant-name"><?php e($tenantLabel); ?></span>

View File

@@ -1,5 +1,8 @@
import { showAsyncFlash } from './app-async-flash.js';
import { warnOnce } from '../core/app-dom.js';
import { optionalEl, warnOnce } from '../core/app-dom.js';
const SWITCHER_ROOT_SELECTOR = '[data-tenant-switcher]';
const TENANT_LINK_SELECTOR = '[data-switch-tenant]';
const setPending = (link, pending) => {
link.style.pointerEvents = pending ? 'none' : '';
@@ -66,9 +69,15 @@ const switchTenant = async (link) => {
};
const initTenantSwitcher = () => {
const tenantLinks = document.querySelectorAll('[data-switch-tenant]');
const switcherRoot = optionalEl(SWITCHER_ROOT_SELECTOR);
if (!switcherRoot) {
// Single-tenant users do not render a switcher; this is expected.
return;
}
const tenantLinks = Array.from(switcherRoot.querySelectorAll(TENANT_LINK_SELECTOR));
if (!tenantLinks.length) {
warnOnce('UI_EL_MISSING', 'Missing tenant switch links', { module: 'tenant-switcher' });
warnOnce('UI_EL_MISSING', 'Tenant switcher root exists but contains no switch links', { module: 'tenant-switcher' });
return;
}