import { type ReactNode, type PropsWithChildren } from 'react'; import { AlertOctagon, ExternalLink, X, AlertTriangle, Check, Dot, DownloadCloud } from 'lucide-react'; import { type AddonData } from '~main/types'; import { api } from '~renderer/utils/api'; import TextButton from '~renderer/components/styled/TextButton'; import { ColoredText } from '~renderer/components/styled/ColoredText'; import useScrollHint from '~renderer/utils/useScrollHint'; import IconSpinner from '~renderer/components/styled/IconSpinner'; import CloseButton from '~renderer/components/styled/CloseButton'; import { type LocalDependencies } from './AddonListItem'; const AddonDetailItem = ({ name, children }: PropsWithChildren<{ name: string }>) => children ? (
{name}:{' '} {typeof children === 'string' ? ( {children} ) : ( children )}
) : null; type Props = AddonData & { close: () => void; warnings: { full: ReactNode; short: ReactNode }[]; dependencies: LocalDependencies; }; const AddonDetail = ({ close, warnings, dependencies, ...addon }: Props) => { const openLink = api.general.openLink.useMutation(); const update = api.addons.update.useMutation(); const scrollRef = useScrollHint(); return (
{addon.toc?.Title ?? addon.folder}
{addon.error && (

{' '} {addon.error}

)} {warnings.map((w, i) => (

{w.full}

))} {(addon.toc?.Notes || addon.description) && ( {addon.toc?.Notes ?? addon.description ?? ''} )}
{addon.git && ( openLink.mutateAsync(addon.git)} className="s1 -m-2 !inline" > Open on GitHub )} {addon.toc && ( <> {addon.toc.Author} {addon.toc.Version} {!!dependencies.length && (
    {dependencies.map(({ name, optional, status }) => (
  • {status === 'installed' ? ( ) : status === 'available' ? ( update.mutateAsync({ toUpdate: [name] }) } className="-m-2 !inline text-warmGreen" /> ) : status === 'missing' ? ( optional ? ( ) : ( ) ) : ( )}

    {name}

    {!['installed', 'available', 'missing'].includes( status ) ? (

    {status}

    ) : optional ? (

    (optional)

    ) : null}
  • ))}
)}
)}
); }; export default AddonDetail;