import { useState } from 'react'; import { Github } from 'lucide-react'; import { usePluginGitHubInstall } from '../../../application/state/usePluginGitHubInstall'; import { useI18n } from '../../../application/i18n/I18nProvider'; import { Button } from '../../ui/button'; import { Input } from '../../ui/input'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from '../../ui/dialog'; import { PluginPackageDetails } from './PluginPackageManager'; import { describePluginGitHubInstallError } from '../../../domain/pluginGitHubInstallError'; export function PluginGitHubInstall({ disabled, onInstalled }: { disabled: boolean; onInstalled: () => Promise }) { const { t, resolvedLocale } = useI18n(); const [open, setOpen] = useState(false); const [input, setInput] = useState(''); const [accepted, setAccepted] = useState(false); const flow = usePluginGitHubInstall(async () => { await onInstalled(); setOpen(false); }); const preview = flow.preview; const error = flow.error ? describePluginGitHubInstallError(flow.error) : null; return { if (flow.busy) return; setOpen(next); flow.reset(); setAccepted(false); setInput(''); }}> {t('settings.plugins.github.install')} {t('settings.plugins.github.description')}
{ event.preventDefault(); if (!flow.busy && input.trim() && !preview) void flow.prepare(input); }}>

{t('settings.plugins.github.formats')}

{flow.busy &&

{t('settings.plugins.github.busy')}

} {error &&

{t(error.key, error.values)}

{error.details &&
{t('settings.plugins.github.error.details')}

{error.details}

}
} {preview &&

{preview.manifest.name} · {preview.manifest.version}

{preview.source.origin}

{preview.source.tag} · {preview.source.commit}

{preview.assetName} · {preview.size.toLocaleString(resolvedLocale)} B

{t('settings.plugins.github.review')}

} {preview ? : }
; }