ruvector/studio/components/interfaces/BranchManagement/DatabaseDiffPanel.tsx
rUv 814f595995 feat(studio): Add complete RuVector Studio application
Major additions:
- Complete Next.js studio application with 1600+ components
- Docker support (Dockerfile.combined, docker-compose.yml)
- GCP deployment documentation and benchmarks
- SQL benchmark scripts for performance testing
- Sentry integration for monitoring
- Comprehensive test suite and mocks

Studio features:
- Dashboard and admin interfaces
- Data visualization components
- Authentication and user management
- API integration with RuVector backend
- Static data and public assets

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 23:04:48 +00:00

98 lines
3.2 KiB
TypeScript

import Link from 'next/link'
import { CircleAlert, Database, Download, Wind } from 'lucide-react'
import { Card, CardContent, CardHeader, CardTitle, Skeleton, Button } from 'ui'
import { toast } from 'sonner'
import DiffViewer from 'components/ui/DiffViewer'
interface DatabaseDiffPanelProps {
diffContent?: string
isLoading: boolean
error?: any
showRefreshButton?: boolean
currentBranchRef?: string
}
const DatabaseDiffPanel = ({
diffContent,
isLoading,
error,
currentBranchRef,
}: DatabaseDiffPanelProps) => {
if (isLoading) return <Skeleton className="h-64" />
if (error)
return (
<div className="p-6 text-center">
<CircleAlert size={32} strokeWidth={1.5} className="text-foreground-muted mx-auto mb-8" />
<h3 className="mb-1">Error loading branch diff</h3>
<p className="text-sm text-foreground-light">
Please try again in a few minutes and contact support if the problem persists.
</p>
</div>
)
if (!diffContent || diffContent.trim() === '') {
return (
<div className="p-6 text-center">
<Wind size={32} strokeWidth={1.5} className="text-foreground-muted mx-auto mb-8" />
<h3 className="mb-1">No changes detected between branches</h3>
<p className="text-sm text-foreground-light">
Any changes to your database schema will be shown here for review
</p>
</div>
)
}
return (
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 py-3">
<CardTitle>
<Link
href={`/project/${currentBranchRef}/database/schema`}
className="flex items-center gap-2"
>
<Database strokeWidth={1.5} size={16} className="text-foreground-muted" />
Schema Changes
</Link>
</CardTitle>
<Button
type="default"
size="tiny"
icon={<Download strokeWidth={1.5} size={14} className="text-foreground-light" />}
className="mt-0"
onClick={() => {
if (!diffContent) return
const now = new Date()
const pad = (n: number) => n.toString().padStart(2, '0')
const timestamp =
now.getFullYear().toString() +
pad(now.getMonth() + 1) +
pad(now.getDate()) +
pad(now.getHours()) +
pad(now.getMinutes()) +
pad(now.getSeconds())
const filename = `${timestamp}_migration.sql`
const blob = new Blob([diffContent], { type: 'text/plain;charset=utf-8;' })
const url = window.URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.setAttribute('download', filename)
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
window.URL.revokeObjectURL(url)
toast.success('Migration file downloaded!')
}}
>
Download as migration
</Button>
</CardHeader>
<CardContent className="p-0 h-96">
<DiffViewer language="sql" original="" modified={diffContent} />
</CardContent>
</Card>
)
}
export default DatabaseDiffPanel