import { Building2, Check, Settings } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { switchWorkspaceAndReload, useCurrentWorkspace, useWorkspaceBootstrap, } from '@/app/infra/http'; import { Button } from '@/components/ui/button'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { cn } from '@/lib/utils'; export const OPEN_WORKSPACE_SETTINGS_EVENT = 'langbot:open-workspace-settings'; export function requestWorkspaceSettings(): void { window.dispatchEvent(new Event(OPEN_WORKSPACE_SETTINGS_EVENT)); } export default function WorkspaceSwitcher({ className, }: { className?: string; }) { const { t } = useTranslation(); const currentWorkspace = useCurrentWorkspace(); const workspaces = useWorkspaceBootstrap(); if (!currentWorkspace) return null; return ( {t('workspace.switchWorkspace')} {workspaces.map((entry) => { const selected = entry.workspace.uuid === currentWorkspace.workspace.uuid; return ( { if (!selected) void switchWorkspaceAndReload(entry.workspace.uuid); }} > {entry.workspace.name} {entry.workspace.source === 'cloud_projection' && ( {entry.plan_name || t('workspace.planUnavailable')} )} {selected && } {selected && ( )} ); })} ); }