mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-24 22:15:18 +00:00
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>
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
|
import { useMemo } from 'react'
|
|
|
|
import { useParams } from 'common'
|
|
import { useAPIKeysQuery } from 'data/api-keys/api-keys-query'
|
|
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
|
|
|
|
interface ApiKeysVisibilityState {
|
|
hasApiKeys: boolean
|
|
isLoading: boolean
|
|
canReadAPIKeys: boolean
|
|
canInitApiKeys: boolean
|
|
shouldDisableUI: boolean
|
|
}
|
|
|
|
/**
|
|
* A hook that provides visibility states for API keys UI components
|
|
* Consolidates logic for determining access to API keys functionality
|
|
*/
|
|
export function useApiKeysVisibility(): ApiKeysVisibilityState {
|
|
const { ref: projectRef } = useParams()
|
|
const { can: canReadAPIKeys, isLoading: isLoadingPermissions } = useAsyncCheckPermissions(
|
|
PermissionAction.SECRETS_READ,
|
|
'*'
|
|
)
|
|
|
|
const { data: apiKeysData, isLoading: isLoadingApiKeys } = useAPIKeysQuery(
|
|
{
|
|
projectRef,
|
|
reveal: false,
|
|
},
|
|
{ enabled: canReadAPIKeys }
|
|
)
|
|
|
|
const publishableApiKeys = useMemo(
|
|
() => apiKeysData?.filter(({ type }) => type === 'publishable') ?? [],
|
|
[apiKeysData]
|
|
)
|
|
|
|
// Check if there are any publishable API keys
|
|
// we don't check for secret keys because they can be optionally deleted
|
|
const hasApiKeys = publishableApiKeys.length > 0
|
|
|
|
// Can initialize API keys when in rollout, has permissions, not loading, and no API keys yet
|
|
const canInitApiKeys = canReadAPIKeys && !isLoadingApiKeys && !hasApiKeys
|
|
|
|
// Disable UI for publishable keys and secrets keys if flag is not enabled OR no API keys created yet
|
|
const shouldDisableUI = !hasApiKeys
|
|
|
|
return {
|
|
hasApiKeys,
|
|
isLoading: isLoadingPermissions || (canReadAPIKeys && isLoadingApiKeys),
|
|
canReadAPIKeys,
|
|
canInitApiKeys,
|
|
shouldDisableUI,
|
|
}
|
|
}
|