@props(['active' => 'dashboard']) @php // Workspace-role gate for the top nav. Mirrors the route-level // `workspace.role:*` middleware so the UI never shows a button // that would 403/redirect when clicked. // - agent/viewer: Team Inbox only // - manager: + Chat, Templates, Analytics // - admin/owner: everything $wsRole = auth()->user()?->workspaceRole(); $minTier = match ($wsRole) { 'owner', 'admin' => 'admin', 'manager' => 'manager', 'agent', 'viewer' => 'agent', default => 'admin', // platform-only users with no workspace role: keep legacy view }; $rank = ['agent' => 1, 'manager' => 2, 'admin' => 3]; $userRank = $rank[$minTier] ?? 3; // Meta Ads (Click-to-WhatsApp Ads) is shown in ALL engine modes — // the page collects its own Meta Marketing API credentials, so it // no longer depends on the platform's active send engine. $activeSendMethod = (string) \App\Models\SystemSetting::get('default_send_method', 'baileys'); $allNavItems = [ [ 'key' => 'dashboard', 'tier' => 'manager', 'href' => url('/dashboard'), 'label' => __('Dashboard'), 'icon' => '', 'sw' => 1.6, ], [ // Promoted into the default header (takes Meta Ads' old slot). 'key' => 'team-inbox', 'tier' => 'admin', 'href' => url('/team-inbox'), 'label' => __('Unified Inbox'), 'icon' => '', 'sw' => 1.5, ], [ // Moved OFF the default header into the /more page. Kept in the // catalogue (so an admin can promote it back via menu-order) but // `promo` keeps it out of the top bar unless explicitly placed. 'key' => 'metaads', 'tier' => 'admin', 'href' => url('/meta-ads'), 'label' => __('Meta Ads'), 'icon' => '', 'sw' => 1.5, 'feature' => 'access_ctwa', 'promo' => true, ], [ // OpenAI (ChatGPT) Ads — like Meta Ads, kept off the top bar (promo) // and surfaced as a card on the /more page; admin can promote it. 'key' => 'openaiads', 'tier' => 'admin', 'href' => url('/openai-ads'), 'label' => __('OpenAI Ads'), 'icon' => '', 'sw' => 1.5, 'promo' => true, ], [ 'key' => 'wa-campaigns', 'tier' => 'admin', 'href' => url('/wa-campaigns'), 'label' => __('Campaigns'), 'icon' => '', 'sw' => 1.5, 'feature' => 'campaign', ], [ 'key' => 'flows', 'tier' => 'admin', 'href' => url('/flows'), 'label' => __('Flows'), 'icon' => '', 'sw' => 1.5, 'feature' => 'autoflow', ], [ 'key' => 'templates', 'tier' => 'manager', 'href' => url('/templates'), 'label' => __('Templates'), 'icon' => '', 'sw' => 1.5, 'feature' => 'template', ], [ 'key' => 'devices', 'tier' => 'admin', 'href' => url('/devices'), 'label' => __('Channels'), 'icon' => '', 'sw' => 1.6, ], // Promotable items — NOT in the top bar by default; an admin can move them // up via /admin/settings/menu-order. `promo` keeps them hidden unless the // saved config explicitly places them in the bar (back-compat safe). [ 'key' => 'broadcasts', 'tier' => 'admin', 'href' => url('/broadcasts'), 'label' => __('Broadcasts'), 'icon' => '', 'sw' => 1.5, 'promo' => true, ], [ 'key' => 'contacts', 'tier' => 'manager', 'href' => url('/contacts'), 'label' => __('Contacts'), 'icon' => '', 'sw' => 1.5, 'promo' => true, ], [ 'key' => 'crm', 'tier' => 'admin', 'href' => url('/crm'), 'label' => __('CRM'), 'icon' => '', 'sw' => 1.3, 'promo' => true, 'feature' => 'access_sales_pipeline', ], [ 'key' => 'deals', 'tier' => 'admin', 'href' => url('/deals'), 'label' => __('Deals'), 'icon' => '', 'sw' => 1.5, 'promo' => true, 'feature' => 'access_sales_pipeline', ], [ 'key' => 'ai-crm', 'tier' => 'manager', 'href' => url('/ai-crm'), 'label' => __('CRM Copilot'), 'icon' => '', 'sw' => 1.4, 'promo' => true, 'feature' => 'access_ai_agents', ], [ 'key' => 'companies', 'tier' => 'admin', 'href' => url('/companies'), 'label' => __('Companies'), 'icon' => '', 'sw' => 1.3, 'promo' => true, 'feature' => 'access_sales_pipeline', ], [ 'key' => 'payments', 'tier' => 'admin', 'href' => url('/payments'), 'label' => __('Payments'), 'icon' => '', 'sw' => 1.3, 'promo' => true, 'feature' => 'auto_invoice', ], [ 'key' => 'tasks', 'tier' => 'admin', 'href' => url('/tasks'), 'label' => __('Tasks'), 'icon' => '', 'sw' => 1.4, 'promo' => true, 'feature' => 'access_sales_pipeline', ], [ 'key' => 'projects', 'tier' => 'admin', 'href' => url('/projects'), 'label' => __('Projects'), 'icon' => '', 'sw' => 1.3, 'promo' => true, 'feature' => 'access_sales_pipeline', ], [ 'key' => 'proposals', 'tier' => 'admin', 'href' => url('/proposals'), 'label' => __('Proposals'), 'icon' => '', 'sw' => 1.3, 'promo' => true, 'feature' => 'access_sales_pipeline', ], [ 'key' => 'estimates', 'tier' => 'admin', 'href' => url('/estimates'), 'label' => __('Estimates'), 'icon' => '', 'sw' => 1.3, 'promo' => true, 'feature' => 'access_sales_pipeline', ], [ 'key' => 'calendar', 'tier' => 'admin', 'href' => url('/calendar'), 'label' => __('Calendar'), 'icon' => '', 'sw' => 1.3, 'promo' => true, 'feature' => 'access_sales_pipeline', ], [ 'key' => 'chat', 'tier' => 'manager', 'href' => url('/chat'), 'label' => __('Live Chat'), 'icon' => '', 'sw' => 1.5, 'promo' => true, ], [ 'key' => 'analytics', 'tier' => 'manager', 'href' => url('/analytics'), 'label' => __('Analytics'), 'icon' => '', 'sw' => 1.6, 'promo' => true, ], [ 'key' => 'auto-reply', 'tier' => 'admin', 'href' => url('/auto-reply'), 'label' => __('Auto-reply'), 'icon' => '', 'sw' => 1.5, 'promo' => true, ], [ 'key' => 'scheduled', 'tier' => 'admin', 'href' => url('/scheduled'), 'label' => __('Scheduled'), 'icon' => '', 'sw' => 1.5, 'promo' => true, ], [ 'key' => 'message-history', 'tier' => 'manager', 'href' => url('/message-history'), 'label' => __('History'), 'icon' => '', 'sw' => 1.5, 'promo' => true, ], [ 'key' => 'ai-assistants', 'tier' => 'admin', 'href' => url('/ai-assistants'), 'label' => __('AI Assistants'), 'icon' => '', 'sw' => 1.4, 'promo' => true, 'feature' => 'access_ai_agents', ], [ 'key' => 'ai-training', 'tier' => 'admin', 'href' => url('/ai-training'), 'label' => __('AI Training'), 'icon' => '', 'sw' => 1.5, 'promo' => true, 'feature' => 'access_ai_training', ], [ 'key' => 'wa-links', 'tier' => 'manager', 'href' => url('/wa-links'), 'label' => __('WA Links'), 'icon' => '', 'sw' => 1.4, 'promo' => true, ], [ 'key' => 'chatbot-widgets', 'tier' => 'admin', 'href' => url('/chatbot-widgets'), 'label' => __('Chat Widget'), 'icon' => '', 'sw' => 1.4, 'promo' => true, 'feature' => 'access_chatbot_widgets', ], [ 'key' => 'webhooks', 'tier' => 'admin', 'href' => url('/webhooks'), 'label' => __('Webhooks'), 'icon' => '', 'sw' => 1.3, 'promo' => true, 'feature' => 'access_outbound_webhooks', ], [ 'key' => 'integrations', 'tier' => 'admin', 'href' => url('/integrations'), 'label' => __('Integrations'), 'icon' => '', 'sw' => 1.4, 'promo' => true, ], [ 'key' => 'warmer', 'tier' => 'admin', 'href' => url('/warmer'), 'label' => __('Warmer'), 'icon' => '', 'sw' => 1.4, 'promo' => true, ], [ 'key' => 'call-logs', 'tier' => 'admin', 'href' => url('/call-logs'), 'label' => __('Call Logs'), 'icon' => '', 'sw' => 1.3, 'promo' => true, ], [ 'key' => 'support', 'tier' => 'manager', 'href' => url('/support'), 'label' => __('Support'), 'icon' => '', 'sw' => 1.4, 'promo' => true, ], [ 'key' => 'more', 'tier' => 'admin', 'href' => url('/more'), 'label' => __('More'), 'icon' => '', 'sw' => 1.6, ], ]; $navItems = array_values( array_filter($allNavItems, function ($it) use ($rank, $userRank, $activeSendMethod) { $needed = $rank[$it['tier']] ?? 3; if ($userRank < $needed) { return false; } // Engine gate: items with `requires_provider` only show when // that provider is the active platform engine. if (!empty($it['requires_provider']) && $it['requires_provider'] !== $activeSendMethod) { return false; } // Admin feature toggle (/admin/settings/features): a globally // disabled feature drops from the top bar (and its /more card is // hidden separately). Default ON — only removes explicit off's. if (!\App\Support\FeatureRegistry::visible((string) ($it['key'] ?? ''))) { return false; } return true; }), ); // Admin-configurable nav (/admin/settings/menu-order). Two formats: // NEW {"bar":[keys…]} → ONLY these keys appear in the top bar, in this // order. Everything else is reachable via the /more page. Lets an // admin move an item out of the header AND promote deeper pages up. // OLD [keys…] → legacy "reorder, show all" (kept for back-compat). // `promo` items only ever show when explicitly placed in the bar. $navCfg = json_decode((string) \App\Models\SystemSetting::get('user_nav_order', '[]'), true); if (is_array($navCfg) && isset($navCfg['bar']) && is_array($navCfg['bar'])) { // NEW placement format. $barKeys = array_values(array_filter($navCfg['bar'], 'is_string')); if (!in_array('more', $barKeys, true)) $barKeys[] = 'more'; // gateway always present $pos = array_flip($barKeys); $navItems = array_values(array_filter($navItems, fn ($it) => isset($pos[$it['key']]))); usort($navItems, fn ($a, $b) => ($pos[$a['key']] ?? PHP_INT_MAX) <=> ($pos[$b['key']] ?? PHP_INT_MAX)); } else { // Default / legacy: hide promo-only items so the top bar stays the // original set, then apply any legacy flat-array reorder. $navItems = array_values(array_filter($navItems, fn ($it) => empty($it['promo']))); if (is_array($navCfg) && $navCfg) { $navPos = array_flip(array_values($navCfg)); usort($navItems, fn ($a, $b) => ($navPos[$a['key']] ?? PHP_INT_MAX) <=> ($navPos[$b['key']] ?? PHP_INT_MAX)); } } @endphp @php // Top-nav icons → vendored Lucide ('l') / brand ('b'). Keyed by item key; // unlisted keys keep their inline SVG fallback. $iconMap = [ 'dashboard' => ['l' => 'layout-dashboard'], 'team-inbox' => ['l' => 'inbox'], 'metaads' => ['b' => 'meta'], 'openaiads' => ['l' => 'sparkles'], 'wa-campaigns' => ['l' => 'megaphone'], 'flows' => ['l' => 'workflow'], 'templates' => ['l' => 'layout-template'], 'devices' => ['l' => 'plug'], 'broadcasts' => ['l' => 'send'], 'contacts' => ['l' => 'contact-round'], 'crm' => ['l' => 'kanban'], 'deals' => ['l' => 'handshake'], 'ai-crm' => ['l' => 'bot'], 'companies' => ['l' => 'building-2'], 'payments' => ['l' => 'credit-card'], 'tasks' => ['l' => 'square-check-big'], 'projects' => ['l' => 'folder'], 'proposals' => ['l' => 'file-text'], 'estimates' => ['l' => 'receipt'], 'calendar' => ['l' => 'calendar-days'], 'chat' => ['l' => 'message-circle'], 'analytics' => ['l' => 'chart-column'], 'auto-reply' => ['l' => 'reply'], 'scheduled' => ['l' => 'calendar-clock'], 'message-history' => ['l' => 'history'], 'ai-assistants' => ['l' => 'bot'], 'ai-training' => ['l' => 'brain'], 'wa-links' => ['l' => 'link'], 'chatbot-widgets' => ['l' => 'message-square-text'], 'webhooks' => ['l' => 'webhook'], 'integrations' => ['l' => 'blocks'], 'warmer' => ['l' => 'flame'], 'call-logs' => ['l' => 'phone'], 'support' => ['l' => 'life-buoy'], 'more' => ['l' => 'ellipsis'], ]; @endphp
@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) {{ $logoName }} @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]). --}} @endif
{{-- 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. --}}
@if (\App\Support\PlatformPermissions::userHasPlatformAccess(auth()->user())) @endif @php $au = auth()->user(); $base = $au ? ($au->name ?: $au->email) : ''; $parts = preg_split('/\s+/', trim($base)); $initials = $au ? strtoupper(substr($parts[0] ?? '', 0, 1) . substr($parts[1] ?? '', 0, 1)) : 'WA'; $isAdminUser = $au && method_exists($au, 'isAdmin') ? $au->isAdmin() : false; $avatarUrl = $au?->avatar_url; @endphp
@if ($au) @endif