import { useState } from 'react'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Skeleton } from '@/components/ui/skeleton'; import { toast } from '@/components/ui/toast-store'; import { apiFetch } from '@/lib/api'; import { RefreshCw } from 'lucide-react'; import type { PatchableSettings } from './types'; interface AppStoreSectionProps { settings: PatchableSettings; onSettingChange: (key: K, value: PatchableSettings[K]) => void; isLoading: boolean; /** Called after a successful save so the parent can update serverSettingsRef */ onSaved: (key: keyof PatchableSettings, value: string) => void; } function SettingsSkeleton() { return (
); } export function AppStoreSection({ settings, onSettingChange, isLoading, onSaved }: AppStoreSectionProps) { const [isSavingRegistry, setIsSavingRegistry] = useState(false); const saveRegistrySettings = async () => { setIsSavingRegistry(true); try { const res = await apiFetch('/settings', { method: 'PATCH', body: JSON.stringify({ template_registry_url: settings.template_registry_url ?? '' }), }); if (!res.ok) { const err = await res.json().catch(() => ({})); toast.error(err?.error || err?.message || 'Failed to save registry settings.'); return; } onSaved('template_registry_url', settings.template_registry_url ?? ''); await apiFetch('/templates/refresh-cache', { method: 'POST' }); toast.success('Registry saved. App Store will reload from the new source.'); } catch (e: unknown) { toast.error((e as Error)?.message || 'Failed to save registry settings.'); } finally { setIsSavingRegistry(false); } }; return (

App Store Registry

Configure the template source used by the App Store.

{isLoading ? : ( <>

LinuxServer.io - https://api.linuxserver.io/api/v1/images

Used when no custom registry is set.

Provide a URL pointing to a Portainer v2 compatible template JSON file. Overrides the default registry.

onSettingChange('template_registry_url', e.target.value)} />

Leave empty to use the default LinuxServer.io registry.

)}
); }