ruvector/studio/components/interfaces/APIKeys/CreateNewAPIKeysButton.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

72 lines
2.1 KiB
TypeScript

import { useState } from 'react'
import { useParams } from 'common'
import { useAPIKeyCreateMutation } from 'data/api-keys/api-key-create-mutation'
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
Button,
} from 'ui'
export const CreateNewAPIKeysButton = () => {
const { ref: projectRef } = useParams()
const [createKeysDialogOpen, setCreateKeysDialogOpen] = useState(false)
const [isCreatingKeys, setIsCreatingKeys] = useState(false)
const { mutate: createAPIKey } = useAPIKeyCreateMutation()
const handleCreateNewApiKeys = async () => {
if (!projectRef) return
setIsCreatingKeys(true)
try {
// Create publishable key
await createAPIKey({
projectRef,
type: 'publishable',
name: 'default',
})
// Create secret key
await createAPIKey({
projectRef,
type: 'secret',
name: 'default',
})
setCreateKeysDialogOpen(false)
} catch (error) {
console.error('Failed to create API keys:', error)
} finally {
setIsCreatingKeys(false)
}
}
return (
<AlertDialog open={createKeysDialogOpen} onOpenChange={setCreateKeysDialogOpen}>
<Button onClick={() => setCreateKeysDialogOpen(true)}>Create new API keys</Button>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Create new API keys</AlertDialogTitle>
<AlertDialogDescription>
This will create a default publishable key and a default secret key named{' '}
<code>default</code>. These keys are required to connect your application to your
Supabase project.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction onClick={handleCreateNewApiKeys} disabled={isCreatingKeys}>
{isCreatingKeys ? 'Creating...' : 'Create keys'}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
)
}