@php
// Resolve brand logo for the current user's selected theme.
// Same fallback chain as the admin sidebar.
$brandTheme = \App\Support\Brand::activeTheme();
$brandLogo = \App\Support\Brand::logoUrl($brandTheme);
$brandName = (string) brand_name();
// Per-workspace white-label: the workspace's own uploaded logo (Settings →
// Branding) OVERRIDES the platform logo for that workspace. data-ws-logo tells
// wadesk.js NOT to swap it on theme change (it's a single image, not per-theme).
$__bw = auth()->user()?->currentWorkspace;
$wsLogo = $__bw && $__bw->brand_logo_path ? asset('storage/' . $__bw->brand_logo_path) : null;
$logoSrc = $wsLogo ?: $brandLogo;
$logoName = $wsLogo ? ($__bw->name ?: $brandName) : $brandName;
@endphp
@if ($logoSrc)
@else
{{ $brandName }}
@endif
{{-- (Removed) The "Switch to Instagram" header icon used to render whenever
the Instagram add-on was installed. It's gone — Instagram is used
inside WaDesk (Unified Inbox, dashboard card, flows), so there's no
separate app to switch to, and the icon in the header was unwanted. --}}
@php
$authUser = auth()->user();
// White-label tenant domain: the user is LOCKED to this one workspace,
// so there are no other workspaces to switch to and no "create" link.
$__lockWs = ($isTenantDomain ?? false);
$allWorkspaces = ($authUser && !$__lockWs) ? $authUser->workspaces()->orderByDesc('last_active_at')->get() : collect();
$currentWs = $authUser ? $authUser->current_workspace : null;
// Plan gate — hide every "Create new workspace" affordance once the
// owner has hit their plan's workspaces_per_owner_limit (admins bypass).
// Role gate — an invited AGENT / VIEWER / MANAGER must not create new
// workspaces (matches the workspace.role:admin gate on the route), so
// only an owner/admin of the current workspace (or a platform super
// admin) sees the "Create new workspace" link at all.
$__wsRole = $authUser?->workspaceRole();
$__isWsAdmin = in_array($__wsRole, ['owner', 'admin'], true)
|| in_array($authUser->role ?? null, ['admin', 'super-admin', 'super_admin', 'platform-admin'], true);
$canCreateWorkspace = ($authUser && !$__lockWs) ? ($authUser->canCreateWorkspace() && $__isWsAdmin) : false;
@endphp
@if ($authUser && $currentWs)
{{-- Hidden on mobile/tablet — the lone avatar circle confused users
("what is this?"). Below lg the workspace switcher lives inside
the hamburger menu instead (see [data-mobile-nav-pane]). --}}
{{-- Workspace switcher: BO tile + workspace name + chevron.
The name is capped (max-w + truncate) so a long workspace
name clips with an ellipsis instead of overflowing the
header / pushing the nav off its row. --}}
@php
$wsColor = workspace_brand_color($currentWs, '');
// The default workspace name is "{owner}'s workspace" (e.g.
// "Bohecil's workspace"). On the compact button we drop that
// possessive owner prefix → just "Workspace". Custom names
// (no "'s ") show unchanged. Full real name stays in the
// tooltip + dropdown so workspaces are still distinguishable.
$wsStripped = preg_replace('/^.+?[\'\x{2019}]s\s+/u', '', (string) $currentWs->name);
$wsLabel =
$wsStripped !== '' && $wsStripped !== (string) $currentWs->name
? \Illuminate\Support\Str::ucfirst($wsStripped)
: $currentWs->name;
@endphp
@unless ($__lockWs)
{{-- Workspace switcher — moved here from the header so phones
don't show a mystery avatar circle. Labelled clearly. --}}
@if ($authUser && $currentWs)
{{-- Language switcher dropdown. Single source: lang/.json.
POSTs to /locale → persists to users.locale + session. --}}
{{-- Notification bell + dropdown. Feed is fetched from
/notifications/recent on toggle and refreshed every 60s
in the background. Mark-all-read + clear hit the
existing controller endpoints. --}}
{{-- Mobile: pin to the viewport so the panel can't clip off the
screen edge. Desktop: the normal anchored dropdown. --}}