import { useEffect, useState } from 'react'; import { useParams } from 'react-router-dom'; import { useQueryClient } from '@tanstack/react-query'; import { AlertTriangle, Globe } from 'lucide-react'; import { useBuckets } from '@/hooks/useApi'; import { bucketsApi } from '@/lib/api'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Switch } from '@/components/ui/switch'; import { Badge } from '@/components/ui/badge'; import { EmptyState } from '@/components/ui/empty-state'; import { toast } from 'sonner'; export function BucketWebsite() { const { bucketName = '' } = useParams<{ bucketName: string }>(); const queryClient = useQueryClient(); const { data: buckets = [], isLoading } = useBuckets(); const bucket = buckets.find((b) => b.name === bucketName); const [enabled, setEnabled] = useState(false); const [indexDocument, setIndexDocument] = useState('index.html'); const [errorDocument, setErrorDocument] = useState(''); const [saving, setSaving] = useState(false); // Sync local form state whenever the underlying bucket changes. useEffect(() => { if (!bucket) return; setEnabled(bucket.websiteAccess); setIndexDocument(bucket.websiteConfig?.indexDocument ?? 'index.html'); setErrorDocument(bucket.websiteConfig?.errorDocument ?? ''); }, [bucket?.name, bucket?.websiteAccess, bucket?.websiteConfig?.indexDocument, bucket?.websiteConfig?.errorDocument]); if (isLoading) { return
Website access
Allow public HTTP access to bucket objects
The file served when a directory is requested (e.g. index.html)
The file served when an object is not found (optional)