import React, { useRef, useState } from 'react'; import { useI18n } from '../../../application/i18n/I18nProvider'; import { Button } from '../../ui/button'; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '../../ui/dialog'; /** Uses the existing renderer and host bridge; opening the manager never starts a plugin. */ export function PluginManagementDialog({ children }: { children: React.ReactNode | ((handoff: (action: () => void) => void) => React.ReactNode); }) { const { t } = useI18n(); const [open, setOpen] = useState(false); const pendingHandoff = useRef<(() => void) | null>(null); const handoff = (action: () => void) => { pendingHandoff.current = action; setOpen(false); }; return ( { const action = pendingHandoff.current; pendingHandoff.current = null; if (action) { event.preventDefault(); // Wait for Radix to release modal pointer/focus ownership before opening // the existing external plugin view host (including exit animations). queueMicrotask(action); } }} className="flex h-[min(88dvh,900px)] w-[calc(100vw-2rem)] max-w-[1180px] flex-col gap-0 overflow-hidden p-0"> {t('settings.plugins.title')}
{typeof children === 'function' ? children(handoff) : children}
); }