Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: dead code cleanup (#47294)

Gildas Garciaf34aa108d531
diff --git a/apps/studio/components/interfaces/BranchManagement/ReviewRow.tsx b/apps/studio/components/interfaces/BranchManagement/ReviewRow.tsx
deleted file mode 100644
index 8d2382dbc3d..00000000000
--- a/apps/studio/components/interfaces/BranchManagement/ReviewRow.tsx
+++ /dev/null
@@ -1,97 +0,0 @@
-import { useQueryClient } from '@tanstack/react-query'
-import dayjs from 'dayjs'
-import { MoreVertical, X } from 'lucide-react'
-import { useRouter } from 'next/router'
-import { toast } from 'sonner'
-import {
- Button,
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
-} from 'ui'
-
-import { useBranchUpdateMutation } from '@/data/branches/branch-update-mutation'
-import type { Branch } from '@/data/branches/branches-query'
-import { branchKeys } from '@/data/branches/keys'
-
-interface ReviewRowProps {
- branch: Branch
-}
-
-export const ReviewRow = ({ branch }: ReviewRowProps) => {
- const router = useRouter()
- const queryClient = useQueryClient()
- const { project_ref: branchRef, parent_project_ref: projectRef } = branch
-
- const { mutate: updateBranch, isPending: isUpdating } = useBranchUpdateMutation({
- onSuccess: () => {
- toast.success('Branch marked as not ready for review')
- queryClient.invalidateQueries({
- queryKey: branchKeys.list(projectRef),
- })
- },
- onError: (error) => {
- toast.error(`Failed to update branch: ${error.message}`)
- },
- })
-
- const handleRowClick = () => {
- router.push(`/project/${branchRef}/merge`)
- }
-
- const handleNotReadyForReview = (e?: Event) => {
- e?.preventDefault()
- e?.stopPropagation()
-
- updateBranch({
- branchRef,
- projectRef,
- requestReview: false,
- })
- }
-
- const formattedReviewDate = branch.review_requested_at
- ? dayjs(branch.review_requested_at).format('MMM DD, YYYY HH:mm')
- : ''
-
- return (
- <div
- className="w-full flex items-center justify-between px-6 py-3 hover:bg-surface-100 cursor-pointer transition-colors"
- onClick={handleRowClick}
- >
- <div className="flex items-center gap-x-4">
- <div className="flex gap-4">
- <h4 className="text-sm text-foreground" title={branch.name}>
- {branch.name}
- </h4>
- <p className="text-foreground-light">{formattedReviewDate}</p>
- </div>
- </div>
-
- <div className="flex items-center gap-x-2">
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button
- variant="text"
- icon={<MoreVertical />}
- className="px-1"
- onClick={(e) => e.stopPropagation()}
- />
- </DropdownMenuTrigger>
- <DropdownMenuContent className="w-56" side="bottom" align="end">
- <DropdownMenuItem
- className="gap-x-2"
- disabled={isUpdating}
- onClick={(e) => e.stopPropagation()}
- onSelect={handleNotReadyForReview}
- >
- <X size={14} />
- Not ready for review
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
- </div>
- )
-}
diff --git a/apps/studio/components/interfaces/ConnectSheet/FrameworkSelector.tsx b/apps/studio/components/interfaces/ConnectSheet/FrameworkSelector.tsx
deleted file mode 100644
index 0039e5bc6bc..00000000000
--- a/apps/studio/components/interfaces/ConnectSheet/FrameworkSelector.tsx
+++ /dev/null
@@ -1,93 +0,0 @@
-import { Box, Check, ChevronDown } from 'lucide-react'
-import { useState } from 'react'
-import {
- Button,
- cn,
- Command,
- CommandEmpty,
- CommandGroup,
- CommandInput,
- CommandItem,
- CommandList,
- Popover,
- PopoverContent,
- PopoverTrigger,
-} from 'ui'
-
-import { ConnectionType } from '@/components/interfaces/ConnectSheet/Connect.constants'
-import { ConnectionIcon } from '@/components/interfaces/ConnectSheet/ConnectionIcon'
-
-interface FrameworkSelectorProps {
- value: string
- onChange: (value: string) => void
- items: ConnectionType[]
- className?: string
- size?: 'tiny' | 'small'
-}
-
-export const FrameworkSelector = ({
- value,
- onChange,
- items,
- className,
- size = 'tiny',
-}: FrameworkSelectorProps) => {
- const [open, setOpen] = useState(false)
-
- const selectedItem = items.find((item) => item.key === value)
-
- function handleSelect(key: string) {
- onChange(key)
- setOpen(false)
- }
-
- return (
- <Popover open={open} onOpenChange={setOpen} modal={false}>
- <div className={cn('flex', className)}>
- <PopoverTrigger asChild>
- <Button
- size={size}
- variant="default"
- className={cn('gap-0 justify-between', className?.includes('w-full') && 'w-full')}
- iconRight={<ChevronDown strokeWidth={1.5} />}
- >
- <div className="flex items-center gap-2">
- {selectedItem?.icon ? <ConnectionIcon icon={selectedItem.icon} /> : <Box size={12} />}
- {selectedItem?.label}
- </div>
- </Button>
- </PopoverTrigger>
- </div>
- <PopoverContent
- className="p-0 w-radix-popover-trigger-width min-w-48"
- side="bottom"
- align="start"
- onOpenAutoFocus={(e) => e.preventDefault()}
- >
- <Command>
- <CommandInput placeholder="Search..." />
- <CommandList>
- <CommandEmpty>No results found.</CommandEmpty>
- <CommandGroup>
- {items.map((item) => (
- <CommandItem
- key={item.key}
- value={item.key}
- onSelect={() => handleSelect(item.key)}
- className="flex gap-2 items-center"
- >
- {item.icon ? <ConnectionIcon icon={item.icon} /> : <Box size={12} />}
- {item.label}
- <Check
- size={15}
- className={cn('ml-auto', item.key === value ? 'opacity-100' : 'opacity-0')}
- />
- </CommandItem>
- ))}
- </CommandGroup>
- </CommandList>
- </Command>
- </PopoverContent>
- </Popover>
- )
-}
diff --git a/apps/studio/components/interfaces/DiskManagement/ui/DiskManagementCoolDownSection.tsx b/apps/studio/components/interfaces/DiskManagement/ui/DiskManagementCoolDownSection.tsx
deleted file mode 100644
index 0f5c648cf4d..00000000000
--- a/apps/studio/components/interfaces/DiskManagement/ui/DiskManagementCoolDownSection.tsx
+++ /dev/null
@@ -1,86 +0,0 @@
-import { AnimatePresence, motion } from 'framer-motion'
-import { useEffect, useState } from 'react'
-import { DialogSection } from 'ui'
-
-import CountdownTimerRadial from '@/components/ui/CountdownTimer/CountdownTimerRadial'
-
-export const DiskMangementCoolDownSection = ({ visible }: { visible: boolean }) => {
- const [progress, setProgress] = useState(100)
- const [showCountdown, setShowCountdown] = useState(false)
- const [isJumping, setIsJumping] = useState(false)
-
- useEffect(() => {
- const startCountdown = () => {
- setShowCountdown(true)
- setProgress(100)
- const interval = setInterval(() => {
- setProgress((prevProgress) => {
- if (prevProgress <= 0) {
- clearInterval(interval)
- setIsJumping(true)
- setTimeout(() => {
- setIsJumping(false)
- setProgress(100)
- startCountdown() // Restart the countdown
- }, 300) // Duration of the jump animation
- return 0
- }
- return prevProgress - 1
- })
- }, 100)
-
- return () => clearInterval(interval)
- }
-
- const initialDelay = setTimeout(startCountdown, 1000)
-
- return () => clearTimeout(initialDelay)
- }, [])
-
- return (
- <AnimatePresence>
- {visible && (
- <motion.div
- initial={{ opacity: 1, height: 'auto' }}
- exit={{ opacity: 0, height: 0 }}
- transition={{ duration: 0.15 }}
- className="w-full"
- >
- <DialogSection className="bg-surface-100 text-sm text-foreground-light flex items-center gap-4 relative w-full border rounded-md">
- <div className="w-12 h-12">
- <AnimatePresence>
- {showCountdown && (
- <motion.div
- key="countdown-timer"
- initial={{ scale: 0.8, opacity: 0, y: -8 }}
- animate={{
- scale: isJumping ? 1.2 : 1,
- opacity: 1,
- y: isJumping ? -8 : 0,
- }}
- exit={{ scale: 0.8, opacity: 0, y: -8 }}
- transition={{
- duration: isJumping ? 0.3 : 0.8,
- type: 'spring',
- bounce: 0.6,
- }}
- >
- <CountdownTimerRadial progress={progress} />
- </motion.div>
- )}
- </AnimatePresence>
- </div>
- <div className="flex flex-col gap-0 grow">
- <p className="text-sm text-foreground">
- For 4 hours you will not be able to change any disk attributes.
- </p>
- <p className="text-sm text-foreground-light">
- There is a cooldown period enforced for any disk attribute modifications
- </p>
- </div>
- </DialogSection>
- </motion.div>
- )}
- </AnimatePresence>
- )
-}
diff --git a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobsTab.EstimateErrorNotice.tsx b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobsTab.EstimateErrorNotice.tsx
deleted file mode 100644
index fa732dd735a..00000000000
--- a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobsTab.EstimateErrorNotice.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import { Button } from 'ui'
-import { Admonition } from 'ui-patterns/admonition'
-
-interface CronJobRunDetailsEstimateErrorNoticeProps {
- error?: Error | null
- isRetrying?: boolean
- onRetry?: () => void
-}
-
-export const CronJobRunDetailsEstimateErrorNotice = ({
- error,
- isRetrying,
- onRetry,
-}: CronJobRunDetailsEstimateErrorNoticeProps) => {
- return (
- <Admonition
- type="warning"
- title="Error displaying cron jobs"
- description="There was an error displaying cron jobs. Please try again."
- className="max-w-3xl w-full"
- >
- <div className="space-y-3 text-sm">
- {error?.message && (
- <p className="text-foreground-light wrap-break-word">
- Error message: <code className="text-xs">{error.message}</code>
- </p>
- )}
- {onRetry && (
- <Button
- variant="default"
- loading={isRetrying}
- disabled={isRetrying}
- className="mt-1"
- onClick={onRetry}
- >
- Retry check
- </Button>
- )}
- </div>
- </Admonition>
- )
-}
diff --git a/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTabV2/index.tsx b/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTabV2/index.tsx
deleted file mode 100644
index d67884ead4a..00000000000
--- a/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTabV2/index.tsx
+++ /dev/null
@@ -1,99 +0,0 @@
-import { useParams } from 'common'
-import { PropsWithChildren } from 'react'
-import { cn } from 'ui'
-
-import { useAvailableIntegrations } from '../../Landing/useAvailableIntegrations'
-import { FilesViewer } from './FilesViewer'
-import { MarkdownContent } from './MarkdownContent'
-import { InlineLinkClassName } from '@/components/ui/InlineLink'
-
-const getSiteUrlLabel = (url: string | undefined | null) => {
- if (!url) return undefined
-
- try {
- return new URL(url).origin
- } catch (error) {
- return undefined
- }
-}
-
-const isGithubHost = (url: string | undefined | null) => {
- if (!url) return false
- try {
- const hostname = new URL(url).hostname.toLowerCase()
- return hostname === 'github.com' || hostname.endsWith('.github.com')
- } catch (error) {
- return false
- }
-}
-
-/**
- * [Joshen] This will serve as the overview tab for remotely fetched integrations
- */
-export const IntegrationOverviewTabV2 = ({ children }: PropsWithChildren) => {
- const { id } = useParams()
-
- const { data: allIntegrations } = useAvailableIntegrations()
- const integration = allIntegrations.find((i) => i.id === id)
-
- if (!integration) {
- return <div>Unsupported integration type</div>
- }
-
- const { type, content, docsUrl, siteUrl, files = [] } = integration
-
- const docsUrlLabel = docsUrl?.includes('supabase.com/docs')
- ? 'Supabase Docs'
- : isGithubHost(docsUrl)
- ? 'GitHub Docs'
- : 'Documentation'
- const siteUrlLabel = getSiteUrlLabel(siteUrl)
-
- return (
- <div className="grid grid-cols-3 gap-x-8 px-10 py-8">
- <div className="col-span-2 flex flex-col gap-y-8">
- {files.length > 0 && <FilesViewer files={files} />}
- <MarkdownContent integrationId={id} content={content} />
- {children}
- </div>
-
- <div className="text-sm col-span-1 flex flex-col gap-y-8">
- <div className="flex flex-col gap-y-4">
- <p>Details</p>
-
- <div className="flex flex-col gap-y-1">
- <p className="font-mono uppercase text-foreground-light">Type</p>
- <p className="capitalize">{type === 'oauth' ? 'OAuth' : type.replaceAll('_', ' ')}</p>
- </div>
-
- <div className="flex flex-col gap-y-1">
- <p className="font-mono uppercase text-foreground-light">Built by</p>
- <p className={cn(!integration.author.name && 'text-foreground-lighter')}>
- {integration.author.name || 'Unknown Author'}
- </p>
- </div>
-
- {docsUrl && (
- <div className="flex flex-col gap-y-1">
- <p className="font-mono uppercase text-foreground-light">Docs</p>
- <a target="_blank" rel="noreferrer" href={docsUrl} className={InlineLinkClassName}>
- {docsUrlLabel}
- </a>
- </div>
- )}
-
- {siteUrl && (
- <div className="flex flex-col gap-y-1">
- <p className="font-mono uppercase text-foreground-light">Website</p>
- <a target="_blank" rel="noreferrer" href={siteUrl} className={InlineLinkClassName}>
- {siteUrlLabel}
- </a>
- </div>
- )}
- </div>
-
- {/* Subsequent other actions here */}
- </div>
- </div>
- )
-}
diff --git a/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTabWrapper.tsx b/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTabWrapper.tsx
deleted file mode 100644
index 5369bef2347..00000000000
--- a/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTabWrapper.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * [Joshen] This is just to dynamically render either the V1 or V2 Overview tab based
- * on the marketplace feature flag
- */
-
-import { PropsWithChildren } from 'react'
-
-import { IntegrationOverviewTab, IntegrationOverviewTabProps } from './IntegrationOverviewTab'
-import { useIsMarketplaceEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
-
-export const IntegrationOverviewTabWrapper = (
- props: PropsWithChildren<IntegrationOverviewTabProps>
-) => {
- const isMarketplaceEnabled = useIsMarketplaceEnabled()
-
- if (isMarketplaceEnabled) {
- return null
- }
-
- return <IntegrationOverviewTab {...props} />
-}
diff --git a/apps/studio/components/interfaces/Integrations/Landing/AvailableIntegrations.tsx b/apps/studio/components/interfaces/Integrations/Landing/AvailableIntegrations.tsx
deleted file mode 100644
index 64dea3eec13..00000000000
--- a/apps/studio/components/interfaces/Integrations/Landing/AvailableIntegrations.tsx
+++ /dev/null
@@ -1,137 +0,0 @@
-import { Search } from 'lucide-react'
-import { parseAsString, useQueryState } from 'nuqs'
-import { buttonVariants, cn, Tabs_Shadcn_, TabsList_Shadcn_, TabsTrigger_Shadcn_ } from 'ui'
-import { Admonition } from 'ui-patterns/admonition'
-import { Input } from 'ui-patterns/DataInputs/Input'
-
-import { IntegrationCard, IntegrationLoadingCard } from './IntegrationCard'
-import { useAvailableIntegrations } from './useAvailableIntegrations'
-import { useInstalledIntegrations } from './useInstalledIntegrations'
-import AlertError from '@/components/ui/AlertError'
-import { NoSearchResults } from '@/components/ui/NoSearchResults'
-import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
-
-type IntegrationCategory = 'all' | 'wrapper' | 'postgres_extensions' | 'custom'
-const CATEGORIES = [
- { key: 'all', label: 'All Integrations' },
- { key: 'wrapper', label: 'Wrappers' },
- { key: 'postgres_extension', label: 'Postgres Modules' },
-] as const
-
-export const AvailableIntegrations = () => {
- const { integrationsWrappers } = useIsFeatureEnabled(['integrations:wrappers'])
-
- const [selectedCategory, setSelectedCategory] = useQueryState(
- 'category',
- parseAsString.withDefault('all').withOptions({ clearOnDefault: true })
- )
- const [search, setSearch] = useQueryState(
- 'search',
- parseAsString.withDefault('').withOptions({ clearOnDefault: true })
- )
-
- const { data: allIntegrations = [] } = useAvailableIntegrations()
- const { installedIntegrations, error, isError, isLoading, isSuccess } = useInstalledIntegrations()
-
- const installedIds = installedIntegrations.map((i) => i.id)
-
- // available integrations for install
- const availableIntegrations = integrationsWrappers
- ? allIntegrations
- : allIntegrations.filter((x) => !x.id.endsWith('_wrapper'))
- const integrationsByCategory =
- selectedCategory === 'all'
- ? availableIntegrations
- : availableIntegrations.filter((i) => i.type === selectedCategory)
-
- const filteredIntegrations = (
- search.length > 0
- ? integrationsByCategory.filter((i) => i.name.toLowerCase().includes(search.toLowerCase()))
- : integrationsByCategory
- ).sort((a, b) => a.name.localeCompare(b.name))
-
- return (
- <>
- <Tabs_Shadcn_
- className="mt-4"
- value={selectedCategory}
- onValueChange={(value) => setSelectedCategory(value as IntegrationCategory)}
- >
- <TabsList_Shadcn_ className="px-4 md:px-10 gap-2 border-b-0 border-t pt-5">
- {CATEGORIES.map((category) => (
- <TabsTrigger_Shadcn_
- key={category.key}
- value={category.key}
- onClick={() => setSelectedCategory(category.key as IntegrationCategory)}
- className={cn(
- buttonVariants({
- size: 'tiny',
- variant: selectedCategory === category.key ? 'default' : 'outline',
- }),
- selectedCategory === category.key ? 'text-foreground' : 'text-foreground-lighter',
- 'rounded-full! px-3'
- )}
- >
- {category.label}
- </TabsTrigger_Shadcn_>
- ))}
- <Input
- value={search}
- onChange={(e) => {
- setSearch(e.target.value)
- setSelectedCategory('all')
- }}
- containerClassName="group w-40 ml-5"
- icon={
- <Search
- size={14}
- className="transition text-foreground-lighter group-hover:text-foreground"
- />
- }
- iconContainerClassName="p-0"
- className="pl-7 rounded-none border-0! border-transparent bg-transparent shadow-none! ring-0! ring-offset-0!"
- placeholder="Search..."
- />
- </TabsList_Shadcn_>
- </Tabs_Shadcn_>
- <div className="p-4 md:p-10 md:py-8 flex flex-col gap-y-5">
- <div className="grid xl:grid-cols-3 2xl:grid-cols-4 gap-x-4 gap-y-3">
- {isLoading &&
- Array.from({ length: 3 }).map((_, idx) => (
- <IntegrationLoadingCard key={`integration-loading-${idx}`} />
- ))}
- {isError && (
- <AlertError
- className="xl:col-span-3 2xl:col-span-4"
- subject="Failed to retrieve available integrations"
- error={error}
- />
- )}
- {isSuccess &&
- filteredIntegrations.map((i) => (
- <IntegrationCard key={i.id} {...i} isInstalled={installedIds.includes(i.id)} />
- ))}
- {isSuccess && search.length > 0 && filteredIntegrations.length === 0 && (
- <NoSearchResults
- className="xl:col-span-3 2xl:col-span-4"
- searchString={search}
- onResetFilter={() => setSearch('')}
- />
- )}
- {isSuccess &&
- selectedCategory !== 'all' &&
- search.length === 0 &&
- filteredIntegrations.length === 0 && (
- <Admonition
- showIcon={false}
- className="xl:col-span-3 2xl:col-span-4"
- type="default"
- title="All integrations in this category are currently in use"
- description="Manage your installed integrations in the section above"
- />
- )}
- </div>
- </div>
- </>
- )
-}
diff --git a/apps/studio/components/interfaces/Integrations/Landing/InstalledIntegrations.tsx b/apps/studio/components/interfaces/Integrations/Landing/InstalledIntegrations.tsx
deleted file mode 100644
index 7069900b68f..00000000000
--- a/apps/studio/components/interfaces/Integrations/Landing/InstalledIntegrations.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import { IntegrationCard, IntegrationLoadingCard } from './IntegrationCard'
-import { useInstalledIntegrations } from './useInstalledIntegrations'
-import AlertError from '@/components/ui/AlertError'
-
-export const InstalledIntegrations = () => {
- const { installedIntegrations, error, isLoading, isSuccess, isError } = useInstalledIntegrations()
-
- return (
- <div className="px-4 md:px-10 py-6 flex flex-col gap-y-5">
- <h2>Installed integrations</h2>
- <div className="grid xl:grid-cols-3 2xl:grid-cols-4 gap-x-4 gap-y-3">
- {isLoading &&
- new Array(3)
- .fill(0)
- .map((_, idx) => <IntegrationLoadingCard key={`integration-loading-${idx}`} />)}
- {isError && (
- <AlertError
- className="xl:col-span-3 2xl:col-span-4"
- subject="Failed to retrieve installed integrations"
- error={error}
- />
- )}
- {isSuccess && (
- <>
- {installedIntegrations.length === 0 ? (
- <div className="xl:col-span-3 2xl:col-span-4 w-full h-[110px] border rounded-sm flex items-center justify-center">
- {/* [Joshen] Not high priority imo - very low chance this state will be seen cause Vault is always installed */}
- {/* Some placeholder image when no integrations are installed */}
- <p className="text-sm text-foreground-light">No integrations installed yet</p>
- </div>
- ) : (
- installedIntegrations.map((i) => <IntegrationCard key={i.id} {...i} />)
- )}
- </>
- )}
- </div>
- </div>
- )
-}
diff --git a/apps/studio/components/interfaces/Integrations/Marketplace/MarketplaceFeaturedHero.tsx b/apps/studio/components/interfaces/Integrations/Marketplace/MarketplaceFeaturedHero.tsx
deleted file mode 100644
index 33ec2b241d5..00000000000
--- a/apps/studio/components/interfaces/Integrations/Marketplace/MarketplaceFeaturedHero.tsx
+++ /dev/null
@@ -1,240 +0,0 @@
-import { ArrowRight, Pause, Play } from 'lucide-react'
-import Link from 'next/link'
-import { useEffect, useRef, useState } from 'react'
-import { Badge, Button, cn } from 'ui'
-
-import { IntegrationLogo } from '../Integration/IntegrationLogo'
-import {
- formatCategoryLabel,
- getMarketplaceSource,
- MarketplaceSourceBadge,
-} from './Marketplace.constants'
-import type { IntegrationDefinition } from '@/components/interfaces/Integrations/Landing/Integrations.constants'
-import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
-
-const ROTATION_INTERVAL_MS = 7000
-interface MarketplaceFeaturedHeroProps {
- integrations: IntegrationDefinition[]
- installedIds: string[]
- categoryOptions: Array<{ slug: string; name: string }>
-}
-
-export const MarketplaceFeaturedHero = ({
- integrations,
- installedIds,
- categoryOptions,
-}: MarketplaceFeaturedHeroProps) => {
- const { data: project } = useSelectedProjectQuery()
-
- const [activeIndex, setActiveIndex] = useState(0)
- const [isPaused, setIsPaused] = useState(false)
- const [progressKey, setProgressKey] = useState(0)
- const hoveringRef = useRef(false)
- const cardRef = useRef<HTMLDivElement>(null)
-
- useEffect(() => {
- if (integrations.length <= 1) return
- if (isPaused) return
-
- const interval = setInterval(() => {
- if (hoveringRef.current) return
- setActiveIndex((idx) => (idx + 1) % integrations.length)
- }, ROTATION_INTERVAL_MS)
-
- return () => clearInterval(interval)
- }, [integrations.length, isPaused])
-
- useEffect(() => {
- const node = cardRef.current
- if (!node) return
- const enter = () => {
- hoveringRef.current = true
- }
- const leave = () => {
- hoveringRef.current = false
- }
- node.addEventListener('pointerenter', enter)
- node.addEventListener('pointerleave', leave)
- return () => {
- node.removeEventListener('pointerenter', enter)
- node.removeEventListener('pointerleave', leave)
- }
- }, [])
-
- if (integrations.length === 0) return null
-
- const coverColSpan = integrations.length >= 6 ? 2 : 1
-
- const active = integrations[Math.min(activeIndex, integrations.length - 1)]
- const activeCategorySlug = active.categories?.[0]
- const activeCategoryName = activeCategorySlug
- ? formatCategoryLabel(activeCategorySlug, categoryOptions)
- : null
- const isActiveInstalled = installedIds.includes(active.id)
- const source = getMarketplaceSource(active)
-
- const handleTabClick = (idx: number) => {
- setActiveIndex(idx)
- }
-
- return (
- <section>
- <div className="mb-2 flex items-center justify-between">
- <div className="flex items-center gap-2">
- <h2 className="text-sm">Featured integrations</h2>
- </div>
- <Button
- aria-label={isPaused ? 'Resume auto-rotation' : 'Pause auto-rotation'}
- variant="default"
- size="tiny"
- className="px-1.5"
- icon={isPaused ? <Play size={10} /> : <Pause size={10} />}
- onClick={() =>
- setIsPaused((p) => {
- // When resuming, reset the progress animation so it starts from
- // zero and stays in sync with the fresh JS interval.
- if (p) setProgressKey((k) => k + 1)
- return !p
- })
- }
- />
- </div>
- <div
- ref={cardRef}
- className="overflow-hidden rounded-lg border bg-surface-100"
- style={
- {
- '--cover-width': `calc(${coverColSpan * 100}% / ${integrations.length})`,
- } as React.CSSProperties
- }
- >
- <Link
- href={`/project/${project?.ref}/integrations/${active.id}/overview`}
- className="grid gap-0 @3xl:grid-cols-[var(--cover-width)_minmax(0,1fr)] hover:bg-selection/20 transition-colors"
- >
- <div className="relative hidden @3xl:block">
- <FeaturedCover integration={active} categoryLabel={activeCategoryName} />
- </div>
-
- <div className="flex flex-col gap-4 p-5 @3xl:p-6">
- <div className="flex items-start @lg:items-center justify-between gap-4">
- <div className="flex items-center gap-2">
- <div className="flex flex-wrap flex-col @lg:flex-row @lg:items-center gap-2">
- <div className="flex items-center gap-2">
- <IntegrationLogo integration={active} size="h-7 w-7" />
- <span className="text-lg font-medium text-foreground">{active.name}</span>
- </div>
- <div className="flex items-center gap-2">
- <MarketplaceSourceBadge source={source} />
- {active.status && <Badge variant="warning">{active.status}</Badge>}
- </div>
- </div>
- </div>
- {isActiveInstalled && (
- <Badge variant="success" className="mt-2 @lg:mt-0 px-1.5 py-0 text-[10px]">
- Installed
- </Badge>
- )}
- </div>
-
- <div className="grow flex flex-col gap-2">
- <p className="text-base text-foreground-light">{active.description}</p>
- </div>
-
- <div className="mt-1 flex items-center gap-4">
- <span className="inline-flex items-center gap-1.5 text-xs text-foreground">
- {isActiveInstalled ? 'Manage integration' : 'View integration'}
- <ArrowRight size={12} />
- </span>
- </div>
- </div>
- </Link>
-
- <div
- className="grid border-t"
- style={{ gridTemplateColumns: `repeat(${integrations.length}, minmax(0, 1fr))` }}
- >
- {integrations.map((integration, idx) => {
- const isActive = idx === activeIndex
- const slug = integration.categories?.[0]
- const categoryLabel = slug ? formatCategoryLabel(slug, categoryOptions) : null
- return (
- <button
- key={integration.id}
- type="button"
- onClick={() => handleTabClick(idx)}
- className={cn(
- 'group relative flex items-center gap-2.5 border-r p-3 text-left transition-colors last:border-r-0',
- isActive ? 'bg-surface-200' : 'bg-transparent hover:bg-surface-200/60'
- )}
- aria-pressed={isActive}
- >
- <IntegrationLogo
- integration={integration}
- size="h-7 w-7"
- className="hidden sm:flex"
- />
- <div className="min-w-0 flex-1">
- <div
- className={cn(
- 'truncate text-sm',
- isActive ? 'text-foreground' : 'text-foreground-light'
- )}
- >
- {integration.name}
- </div>
- {categoryLabel && (
- <div className="truncate text-xs text-foreground-lighter">{categoryLabel}</div>
- )}
- </div>
- {isActive && (
- <span
- key={`${activeIndex}-${progressKey}`}
- aria-hidden
- className="pointer-events-none absolute inset-x-0 bottom-0 h-0.5 origin-left animate-marketplace-featured-progress bg-brand"
- style={{
- animationDuration: `${ROTATION_INTERVAL_MS}ms`,
- animationPlayState: isPaused ? 'paused' : 'running',
- }}
- />
- )}
- </button>
- )
- })}
- </div>
- </div>
- </section>
- )
-}
-
-interface FeaturedCoverProps {
- integration: IntegrationDefinition
- categoryLabel: string | null
-}
-
-const FeaturedCover = ({ integration, categoryLabel }: FeaturedCoverProps) => (
- <div
- key={integration.id}
- className="relative h-full min-h-[200px] w-full overflow-hidden bg-linear-to-br from-surface-200 via-surface-100 to-surface-300"
- >
- <div
- aria-hidden
- className="absolute inset-0 opacity-60"
- style={{
- backgroundImage:
- 'radial-gradient(circle at 1px 1px, hsl(var(--border-default)/0.6) 1px, transparent 0)',
- backgroundSize: '14px 14px',
- }}
- />
- <div className="absolute inset-0 flex items-center justify-center">
- <div className="relative flex h-24 w-24 items-center justify-center overflow-hidden rounded-2xl border bg-white shadow-sm">
- {integration.icon({ className: 'h-16 w-16' })}
- </div>
- </div>
- {categoryLabel && (
- <span className="absolute bottom-3 left-3 text-[10px] font-medium uppercase tracking-wider text-foreground-lighter">
- {categoryLabel}
- </span>
- )}
- </div>
-)
diff --git a/apps/studio/components/interfaces/Integrations/Queues/QueuesRows.tsx b/apps/studio/components/interfaces/Integrations/Queues/QueuesRows.tsx
deleted file mode 100644
index b5aa5e781e4..00000000000
--- a/apps/studio/components/interfaces/Integrations/Queues/QueuesRows.tsx
+++ /dev/null
@@ -1,115 +0,0 @@
-import dayjs from 'dayjs'
-import { includes, sortBy } from 'lodash'
-import { Check, ChevronRight, Loader2, X } from 'lucide-react'
-import { useRouter } from 'next/router'
-
-import { pgmqQueueTable } from './Queues.utils'
-import Table from '@/components/to-be-cleaned/Table'
-import { useQueuesMetricsQuery } from '@/data/database-queues/database-queues-metrics-query'
-import { PostgresQueue } from '@/data/database-queues/database-queues-query'
-import { useTablesQuery } from '@/data/tables/tables-query'
-import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
-import { DATETIME_FORMAT } from '@/lib/constants'
-
-interface QueuesRowsProps {
- queues: PostgresQueue[]
- filterString: string
-}
-
-const QueueRow = ({ queue }: { queue: PostgresQueue }) => {
- const router = useRouter()
- const { data: selectedProject } = useSelectedProjectQuery()
-
- const { data: queueTables } = useTablesQuery({
- projectRef: selectedProject?.ref,
- connectionString: selectedProject?.connectionString,
- schema: 'pgmq',
- })
- const queueTable = queueTables?.find((x) => x.name === pgmqQueueTable(queue.queue_name))
- const isRlsEnabled = !!queueTable?.rls_enabled
-
- const { data: metrics, isPending: isLoading } = useQueuesMetricsQuery(
- {
- queueName: queue.queue_name,
- projectRef: selectedProject?.ref,
- connectionString: selectedProject?.connectionString,
- },
- {
- staleTime: 30 * 1000, // 30 seconds, talk with Oli whether this is ok to call every minute
- }
- )
-
- const type = queue.is_partitioned ? 'Partitioned' : queue.is_unlogged ? 'Unlogged' : 'Basic'
-
- return (
- <Table.tr
- key={queue.queue_name}
- onClick={() => {
- router.push(
- `/project/${selectedProject?.ref}/integrations/queues/queues/${queue.queue_name}`
- )
- }}
- >
- <Table.td className="truncate">
- <p title={queue.queue_name}>{queue.queue_name}</p>
- </Table.td>
- <Table.td className="table-cell overflow-auto">
- <p title={type.toLocaleLowerCase()} className="truncate">
- {type}
- </p>
- </Table.td>
- <Table.td className="table-cell">
- <div className="flex justify-center">
- {isRlsEnabled ? <Check size={14} className="text-brand" /> : <X size={14} />}
- </div>
- </Table.td>
- <Table.td className="table-cell">
- <p title={queue.created_at}>{dayjs(queue.created_at).format(DATETIME_FORMAT)}</p>
- </Table.td>
- <Table.td className="table-cell">
- <div className="flex justify-center">
- {isLoading ? (
- <Loader2 className="animate-spin" size={16} />
- ) : (
- <p>
- {metrics?.queue_length} {metrics?.method === 'estimated' ? '(Approximate)' : null}
- </p>
- )}
- </div>
- </Table.td>
- <Table.td>
- <div className="flex items-center justify-end">
- <ChevronRight size="18" />
- </div>
- </Table.td>
- </Table.tr>
- )
-}
-
-export const QueuesRows = ({ queues: fetchedQueues, filterString }: QueuesRowsProps) => {
- const filteredQueues = fetchedQueues.filter((x) =>
- includes(x.queue_name.toLowerCase(), filterString.toLowerCase())
- )
- const queues = sortBy(filteredQueues, (func) => func.queue_name.toLocaleLowerCase())
-
- if (queues.length === 0 && filterString.length > 0) {
- return (
- <Table.tr>
- <Table.td colSpan={5}>
- <p className="text-sm text-foreground">No results found</p>
- <p className="text-sm text-foreground-light">
- Your search for "{filterString}" did not return any results
- </p>
- </Table.td>
- </Table.tr>
- )
- }
-
- return (
- <>
- {queues.map((q) => (
- <QueueRow key={q.queue_name} queue={q} />
- ))}
- </>
- )
-}
diff --git a/apps/studio/components/interfaces/QueryPerformance/IndexAdvisor/IndexAdvisorNotice.tsx b/apps/studio/components/interfaces/QueryPerformance/IndexAdvisor/IndexAdvisorNotice.tsx
deleted file mode 100644
index f2443402989..00000000000
--- a/apps/studio/components/interfaces/QueryPerformance/IndexAdvisor/IndexAdvisorNotice.tsx
+++ /dev/null
@@ -1,61 +0,0 @@
-import { LOCAL_STORAGE_KEYS } from 'common'
-import { useParams } from 'common/hooks'
-import { Button } from 'ui'
-import { Admonition } from 'ui-patterns'
-
-import { EnableIndexAdvisorButton } from './EnableIndexAdvisorButton'
-import { useIndexAdvisorStatus } from '@/components/interfaces/QueryPerformance/hooks/useIsIndexAdvisorStatus'
-import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
-import { BASE_PATH } from '@/lib/constants'
-
-export const IndexAdvisorNotice = () => {
- const { ref } = useParams()
- const { isIndexAdvisorAvailable, isIndexAdvisorEnabled } = useIndexAdvisorStatus()
- const [isDismissed, setIsDismissed] = useLocalStorageQuery(
- LOCAL_STORAGE_KEYS.INDEX_ADVISOR_NOTICE_DISMISSED(ref ?? ''),
- false
- )
-
- if (!isIndexAdvisorAvailable || isIndexAdvisorEnabled || isDismissed) return null
-
- return (
- <div className="px-6">
- <Admonition showIcon={false} type="tip" className="relative overflow-hidden mb-4">
- <div className="absolute -inset-16 z-0 opacity-50">
- <img
- src={`${BASE_PATH}/img/reports/bg-grafana-dark.svg`}
- alt="Index Advisor"
- className="w-full h-full object-cover object-right hidden dark:block"
- />
- <img
- src={`${BASE_PATH}/img/reports/bg-grafana-light.svg`}
- alt="Index Advisor"
- className="w-full h-full object-cover object-right dark:hidden"
- />
- <div className="absolute inset-0 bg-linear-to-r from-background-alternative to-transparent" />
- </div>
- <div className="relative z-10 flex flex-col md:flex-row md:items-center gap-y-2 md:gap-x-8 justify-between px-2 py-1">
- <div className="flex flex-col gap-y-0.5">
- <div className="flex flex-col gap-y-2 items-start">
- <p className="text-sm font-medium">Enable Index Advisor</p>
- </div>
- <p className="text-sm text-foreground-lighter text-balance">
- Recommends indexes to improve query performance.
- </p>
- </div>
- <div className="flex items-center gap-x-2">
- <Button
- variant="default"
- size="tiny"
- onClick={() => setIsDismissed(true)}
- aria-label="Dismiss notification"
- >
- Dismiss
- </Button>
- <EnableIndexAdvisorButton />
- </div>
- </div>
- </Admonition>
- </div>
- )
-}
diff --git a/apps/studio/components/interfaces/QueryPerformance/QueryPerformanceChart.tsx b/apps/studio/components/interfaces/QueryPerformance/QueryPerformanceChart.tsx
deleted file mode 100644
index 281786220ec..00000000000
--- a/apps/studio/components/interfaces/QueryPerformance/QueryPerformanceChart.tsx
+++ /dev/null
@@ -1,361 +0,0 @@
-import { Loader2 } from 'lucide-react'
-import { useMemo, useState } from 'react'
-import { Tabs_Shadcn_, TabsContent_Shadcn_, TabsList_Shadcn_, TabsTrigger_Shadcn_ } from 'ui'
-
-import type { ChartDataPoint } from '../QueryInsights/QueryInsights.types'
-import { QUERY_PERFORMANCE_CHART_TABS } from './QueryPerformance.constants'
-import { ComposedChart } from '@/components/ui/Charts/ComposedChart'
-import type { MultiAttribute } from '@/components/ui/Charts/ComposedChart.utils'
-
-interface QueryPerformanceChartProps {
- dateRange?: {
- period_start: { date: string; time_period: string }
- period_end: { date: string; time_period: string }
- interval: string
- }
- onDateRangeChange?: (from: string, to: string) => void
- chartData: ChartDataPoint[]
- isLoading: boolean
- error: any
- currentSelectedQuery: string | null
- parsedLogs: any[]
-}
-
-const QueryMetricBlock = ({
- label,
- value,
-}: {
- label: string
- value: string | number | undefined
-}) => {
- return (
- <div className="flex flex-col gap-0.5 text-xs">
- <span className="font-mono text-xs text-foreground-lighter uppercase">{label}</span>
- <span className="text-lg tabular-nums">{value}</span>
- </div>
- )
-}
-
-const formatTimeValue = (value: number): string => {
- if (value >= 1000) {
- return `${(value / 1000).toFixed(1)}s`
- }
- return `${value.toFixed(1)}ms`
-}
-
-const formatNumberValue = (value: number): string => {
- return value.toLocaleString()
-}
-
-export const QueryPerformanceChart = ({
- onDateRangeChange,
- chartData,
- isLoading,
- error,
- currentSelectedQuery,
- parsedLogs,
-}: QueryPerformanceChartProps) => {
- const [selectedMetric, setSelectedMetric] = useState('query_latency')
-
- const currentMetrics = useMemo(() => {
- if (!chartData || chartData.length === 0) return []
-
- switch (selectedMetric) {
- case 'query_latency': {
- const totalCalls = chartData.reduce((sum, d) => sum + d.calls, 0)
- const trueP95 =
- totalCalls > 0
- ? chartData.reduce((sum, d) => sum + d.p95_time * d.calls, 0) / totalCalls
- : 0
-
- return [
- {
- label: 'Average p95',
- value: `${Math.round(trueP95)}ms`,
- },
- ]
- }
- case 'rows_read': {
- const totalRowsRead = chartData.reduce((sum, d) => sum + d.rows_read, 0)
-
- return [
- {
- label: 'Total Rows Read',
- value: totalRowsRead.toLocaleString(),
- },
- ]
- }
- case 'calls': {
- const totalCalls = chartData.reduce((sum, d) => sum + d.calls, 0)
-
- return [
- {
- label: 'Total Calls',
- value: totalCalls.toLocaleString(),
- },
- ]
- }
- case 'cache_hits': {
- const totalHits = chartData.reduce((sum, d) => sum + d.cache_hits, 0)
- const totalMisses = chartData.reduce((sum, d) => sum + d.cache_misses, 0)
- const total = totalHits + totalMisses
- const hitRate = total > 0 ? (totalHits / total) * 100 : 0
-
- return [
- {
- label: 'Cache Hit Rate',
- value: `${hitRate.toFixed(2)}%`,
- },
- ]
- }
- default:
- return []
- }
- }, [chartData, selectedMetric])
-
- const transformedChartData = useMemo(() => {
- if (selectedMetric !== 'query_latency') return chartData
-
- const transformed = chartData.map((dataPoint) => ({
- ...dataPoint,
- p50_time: parseFloat((dataPoint.p50_time / 1000).toFixed(3)),
- p95_time: parseFloat((dataPoint.p95_time / 1000).toFixed(3)),
- }))
-
- return transformed
- }, [chartData, selectedMetric])
-
- const querySpecificData = useMemo(() => {
- if (!currentSelectedQuery || !parsedLogs.length) return null
-
- const normalizedSelected = currentSelectedQuery.replace(/\s+/g, ' ').trim()
- const queryLogs = parsedLogs.filter((log) => {
- const normalized = (log.query || '').replace(/\s+/g, ' ').trim()
- return normalized === normalizedSelected
- })
-
- const queryDataMap = new Map<
- number,
- {
- time: number
- rows_read: number
- calls: number
- cache_hits: number
- }
- >()
-
- queryLogs.forEach((log) => {
- const time = new Date(log.timestamp).getTime()
- const meanTime = log.mean_time ?? log.mean_exec_time ?? log.mean_query_time ?? 0
- const rowsRead = log.rows_read ?? log.rows ?? 0
- const calls = log.calls ?? 0
- const cacheHits = log.shared_blks_hit ?? log.cache_hits ?? 0
-
- queryDataMap.set(time, {
- time: parseFloat(String(meanTime)),
- rows_read: parseFloat(String(rowsRead)),
- calls: parseFloat(String(calls)),
- cache_hits: parseFloat(String(cacheHits)),
- })
- })
-
- return queryDataMap
- }, [currentSelectedQuery, parsedLogs])
-
- const mergedChartData = useMemo(() => {
- if (!querySpecificData || !currentSelectedQuery) {
- return transformedChartData
- }
-
- return transformedChartData.map((dataPoint) => {
- const queryData = querySpecificData.get(dataPoint.period_start)
-
- return {
- ...dataPoint,
- selected_query_time:
- queryData?.time !== undefined
- ? selectedMetric === 'query_latency'
- ? queryData.time / 1000
- : queryData.time
- : null,
- selected_query_rows_read: queryData?.rows_read !== undefined ? queryData.rows_read : null,
- selected_query_calls: queryData?.calls !== undefined ? queryData.calls : null,
- selected_query_cache_hits:
- queryData?.cache_hits !== undefined ? queryData.cache_hits : null,
- }
- })
- }, [transformedChartData, querySpecificData, currentSelectedQuery, selectedMetric])
-
- const getChartAttributes = useMemo((): MultiAttribute[] => {
- const attributeMap: Record<string, MultiAttribute[]> = {
- query_latency: [
- {
- attribute: 'p50_time',
- label: 'p50',
- provider: 'logs',
- type: 'line',
- color: { light: '#8B5CF6', dark: '#8B5CF6' },
- },
- {
- attribute: 'p95_time',
- label: 'p95',
- provider: 'logs',
- type: 'line',
- color: { light: '#65BCD9', dark: '#65BCD9' },
- },
- ],
- rows_read: [
- {
- attribute: 'rows_read',
- label: 'Rows Read',
- provider: 'logs',
- },
- ],
- calls: [
- {
- attribute: 'calls',
- label: 'Calls',
- provider: 'logs',
- },
- ],
- cache_hits: [
- {
- attribute: 'cache_hits',
- label: 'Cache Hits',
- provider: 'logs',
- type: 'line',
- color: { light: '#10B981', dark: '#10B981' },
- },
- ],
- }
-
- const baseAttributes = attributeMap[selectedMetric] || []
-
- if (currentSelectedQuery && querySpecificData) {
- const dimmedBaseAttributes = baseAttributes.map((attr) => ({
- ...attr,
- color: attr.color
- ? { light: attr.color.light + '4D', dark: attr.color.dark + '4D' }
- : attr.color,
- }))
-
- const selectedQueryAttributes: Record<string, MultiAttribute> = {
- query_latency: {
- attribute: 'selected_query_time',
- label: 'Selected Query',
- provider: 'logs',
- type: 'line',
- color: { light: '#10B981', dark: '#10B981' },
- strokeWidth: 3,
- },
- rows_read: {
- attribute: 'selected_query_rows_read',
- label: 'Selected Query',
- provider: 'logs',
- type: 'line',
- color: { light: '#F59E0B', dark: '#F59E0B' },
- strokeWidth: 3,
- },
- calls: {
- attribute: 'selected_query_calls',
- label: 'Selected Query',
- provider: 'logs',
- type: 'line',
- color: { light: '#EC4899', dark: '#EC4899' },
- strokeWidth: 3,
- },
- cache_hits: {
- attribute: 'selected_query_cache_hits',
- label: 'Selected Query',
- provider: 'logs',
- type: 'line',
- color: { light: '#8B5CF6', dark: '#8B5CF6' },
- strokeWidth: 3,
- },
- }
-
- const selectedQueryAttr = selectedQueryAttributes[selectedMetric]
- if (selectedQueryAttr) {
- return [...dimmedBaseAttributes, selectedQueryAttr]
- }
- }
-
- return baseAttributes
- }, [selectedMetric, currentSelectedQuery, querySpecificData])
-
- const updateDateRange = (from: string, to: string) => {
- onDateRangeChange?.(from, to)
- }
-
- const getYAxisFormatter = useMemo(() => {
- if (selectedMetric === 'query_latency') {
- return formatTimeValue
- }
- return formatNumberValue
- }, [selectedMetric])
-
- return (
- <div className="bg-surface-200 border-t">
- <Tabs_Shadcn_
- value={selectedMetric}
- onValueChange={(value) => setSelectedMetric(value as string)}
- className="w-full"
- >
- <TabsList_Shadcn_ className="flex justify-start rounded-none gap-x-4 border-b mt-0! pt-0 px-6">
- {QUERY_PERFORMANCE_CHART_TABS.map((tab) => (
- <TabsTrigger_Shadcn_
- key={tab.id}
- value={tab.id}
- className="flex items-center gap-2 text-xs py-3 border-b font-mono uppercase"
- >
- {tab.label}
- </TabsTrigger_Shadcn_>
- ))}
- </TabsList_Shadcn_>
-
- <TabsContent_Shadcn_ value={selectedMetric} className="bg-surface-200 mt-0 h-inherit">
- <div className="w-full flex items-center justify-center min-h-[282px]">
- {isLoading ? (
- <Loader2 size={20} className="animate-spin text-foreground-lighter" />
- ) : error ? (
- <p className="text-sm text-foreground-light text-center h-full flex items-center justify-center">
- Error loading chart data
- </p>
- ) : (
- <div className="w-full flex flex-col h-full px-6 py-4">
- <div className="flex gap-6 mb-4">
- {currentMetrics.map((metric, index) => (
- <QueryMetricBlock key={index} label={metric.label} value={metric.value} />
- ))}
- </div>
- <ComposedChart
- data={mergedChartData as any}
- attributes={getChartAttributes}
- yAxisKey={getChartAttributes[0]?.attribute || ''}
- xAxisKey="period_start"
- title=""
- customDateFormat="MMM D, YYYY hh:mm A"
- hideChartType={true}
- hideHighlightArea={true}
- showTooltip={true}
- showGrid={true}
- showLegend={true}
- showTotal={false}
- showMaxValue={false}
- updateDateRange={updateDateRange}
- YAxisProps={{
- tick: true,
- width: 60,
- tickFormatter: getYAxisFormatter,
- }}
- xAxisIsDate={true}
- className="mt-2"
- />
- </div>
- )}
- </div>
- </TabsContent_Shadcn_>
- </Tabs_Shadcn_>
- </div>
- )
-}
diff --git a/apps/studio/components/interfaces/Settings/Logs/PreviewFilterPanelWithUniversal.tsx b/apps/studio/components/interfaces/Settings/Logs/PreviewFilterPanelWithUniversal.tsx
deleted file mode 100644
index 7fdc180da73..00000000000
--- a/apps/studio/components/interfaces/Settings/Logs/PreviewFilterPanelWithUniversal.tsx
+++ /dev/null
@@ -1,352 +0,0 @@
-import { useParams } from 'common'
-import dayjs from 'dayjs'
-import { Eye, EyeOff, RefreshCw, Terminal } from 'lucide-react'
-import Link from 'next/link'
-import { useRouter } from 'next/router'
-import { useMemo, useState } from 'react'
-import { Button, Calendar, cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
-import type {
- CustomOptionProps,
- FilterCondition,
- FilterGroup,
- FilterProperty,
-} from 'ui-patterns/FilterBar'
-import { FilterBar } from 'ui-patterns/FilterBar'
-
-import { FILTER_OPTIONS, LOG_ROUTES_WITH_REPLICA_SUPPORT, LogsTableName } from './Logs.constants'
-import { DatePickerValue } from './Logs.DatePickers'
-import type { Filters, LogSearchCallback, LogTemplate } from './Logs.types'
-import { DatabaseSelector } from '@/components/ui/DatabaseSelector'
-import { useLoadBalancersQuery } from '@/data/read-replicas/load-balancers-query'
-import { IS_PLATFORM } from '@/lib/constants'
-
-function isBooleanMap(v: unknown): v is Record<string, boolean> {
- return typeof v === 'object' && v !== null && !Array.isArray(v)
-}
-
-function CustomDateRangePicker({ onChange, onCancel }: CustomOptionProps) {
- const [dateRange, setDateRange] = useState<any | undefined>()
-
- return (
- <div className="w-full space-y-4">
- <Calendar
- initialFocus
- mode="range"
- defaultMonth={dateRange?.from}
- selected={dateRange}
- onSelect={setDateRange}
- numberOfMonths={2}
- />
- <div className="flex justify-end gap-2 py-3 px-4 border-t">
- <Button variant="default" onClick={onCancel}>
- Cancel
- </Button>
- <Button
- variant="primary"
- onClick={() => {
- if (dateRange?.from) {
- const from = dayjs(dateRange.from).toISOString()
- const to = dateRange.to ? dayjs(dateRange.to).toISOString() : dayjs().toISOString()
- onChange(`${from}|${to}`)
- }
- }}
- >
- Apply
- </Button>
- </div>
- </div>
- )
-}
-
-interface PreviewFilterPanelProps {
- defaultSearchValue?: string
- defaultToValue?: string
- defaultFromValue?: string
- templates?: any
- isLoading: boolean
- newCount: number
- onRefresh?: () => void
- onSearch?: LogSearchCallback
- onExploreClick?: () => void
- queryUrl: string
- onSelectTemplate: (template: LogTemplate) => void
- table: LogsTableName
- condensedLayout: Boolean
- isShowingEventChart: boolean
- onToggleEventChart: () => void
- csvData?: unknown[]
- onFiltersChange: (filters: Filters) => void
- filters: Filters
- onSelectedDatabaseChange: (id: string) => void
- className?: string
- selectedDatePickerValue: DatePickerValue
- setSelectedDatePickerValue: (value: DatePickerValue) => void
-}
-
-export const PreviewFilterPanelWithUniversal = ({
- isLoading,
- newCount,
- onRefresh,
- onSearch = () => {},
- defaultSearchValue = '',
- defaultFromValue,
- defaultToValue,
- onExploreClick,
- queryUrl,
- condensedLayout,
- isShowingEventChart,
- onToggleEventChart,
- csvData: _csvData,
- onFiltersChange,
- filters,
- table,
- onSelectedDatabaseChange,
- className,
- selectedDatePickerValue: _selectedDatePickerValue,
- setSelectedDatePickerValue: _setSelectedDatePickerValue,
-}: PreviewFilterPanelProps) => {
- const router = useRouter()
- const { ref } = useParams()
-
- const { data: loadBalancers } = useLoadBalancersQuery({ projectRef: ref })
-
- const showDatabaseSelector =
- IS_PLATFORM && LOG_ROUTES_WITH_REPLICA_SUPPORT.includes(router.pathname)
-
- const filterProperties = useMemo(() => {
- const tableFilters = FILTER_OPTIONS[table]
- if (!tableFilters) return []
-
- const properties: FilterProperty[] = []
-
- // Add date range filter
- properties.push({
- label: 'Time Range',
- name: 'timerange',
- type: 'string' as const,
- operators: ['='],
- options: [
- {
- label: 'Last 15 minutes',
- value: `${dayjs().subtract(15, 'minute').toISOString()}|${dayjs().toISOString()}`,
- },
- {
- label: 'Last 30 minutes',
- value: `${dayjs().subtract(30, 'minute').toISOString()}|${dayjs().toISOString()}`,
- },
- {
- label: 'Last hour',
- value: `${dayjs().subtract(1, 'hour').toISOString()}|${dayjs().toISOString()}`,
- },
- {
- label: 'Last 3 hours',
- value: `${dayjs().subtract(3, 'hour').toISOString()}|${dayjs().toISOString()}`,
- },
- {
- label: 'Last 24 hours',
- value: `${dayjs().subtract(24, 'hour').toISOString()}|${dayjs().toISOString()}`,
- },
- {
- label: 'Custom Range...',
- component: (props: CustomOptionProps) => <CustomDateRangePicker {...props} />,
- },
- ],
- })
-
- // Add table-specific filters
- Object.entries(tableFilters).forEach(([_key, filterSet]) => {
- properties.push({
- label: filterSet.label,
- name: filterSet.key,
- type: 'string' as const,
- operators: ['='],
- options: filterSet.options.map((option) => ({
- label: option.label,
- value: option.key,
- description: option.description,
- })),
- })
- })
-
- return properties
- }, [table])
-
- // Convert Logs.Filters to FilterBar.FilterGroup
- const filterBarFilters = useMemo(() => {
- const conditions: FilterCondition[] = []
-
- // Handle date range - only add from defaultValues if no timerange filter exists
- if ((defaultFromValue || defaultToValue) && !filters.timerange) {
- conditions.push({
- propertyName: 'timerange',
- operator: '=',
- value: `${defaultFromValue || ''}|${defaultToValue || ''}`,
- })
- }
-
- // Convert other filters
- Object.entries(filters).forEach(([key, value]) => {
- if (key === 'search_query') return // Skip search_query as it's handled in freeform text
-
- if (typeof value === 'object' && value !== null) {
- // If the filter object is empty, add a condition with no value
- if (Object.keys(value).length === 0) {
- conditions.push({
- propertyName: key,
- operator: '=',
- value: '',
- })
- return
- }
-
- // Handle active filters
- Object.entries(value as Record<string, boolean>).forEach(([subKey, isEnabled]) => {
- if (isEnabled) {
- conditions.push({
- propertyName: key,
- operator: '=',
- value: subKey,
- })
- }
- })
- } else if (value !== undefined && value !== null) {
- conditions.push({
- propertyName: key,
- operator: '=',
- value: String(value),
- })
- }
- })
-
- return {
- logicalOperator: 'AND',
- conditions,
- } as FilterGroup
- }, [filters, defaultFromValue, defaultToValue])
-
- const handleFilterChange = (filterGroup: FilterGroup) => {
- const newFilters: Filters = {}
- let hasTimeRange = false
-
- filterGroup.conditions.forEach((condition) => {
- if (!('propertyName' in condition)) return
-
- const propertyName = condition.propertyName
- if (!propertyName) return
-
- if (propertyName === 'timerange') {
- hasTimeRange = true
- if (condition.value) {
- const value = String(condition.value)
- const [from, to] = value.split('|')
- newFilters.timerange = { [value]: true }
- onSearch('datepicker-change', { from, to })
- } else {
- newFilters.timerange = {}
- onSearch('datepicker-change', { from: '', to: '' })
- }
- } else {
- if (!newFilters[propertyName]) {
- newFilters[propertyName] = {}
- }
-
- if (!condition.value) {
- return
- }
-
- if (typeof condition.value === 'string') {
- const current = newFilters[propertyName]
- const next = isBooleanMap(current) ? { ...current } : {}
- next[condition.value] = true
- newFilters[propertyName] = next
- }
- }
- })
-
- // If timerange was completely removed from the filter group
- if (!hasTimeRange) {
- onSearch('datepicker-change', { from: '', to: '' })
- }
-
- onFiltersChange(newFilters)
- }
-
- return (
- <div className={cn('flex w-full flex-col gap-2', condensedLayout ? ' p-3' : '', className)}>
- <div className="flex items-center justify-between gap-x-2">
- <div className="flex-1">
- <FilterBar
- filterProperties={filterProperties}
- filters={filterBarFilters}
- onFilterChange={handleFilterChange}
- freeformText={defaultSearchValue}
- onFreeformTextChange={(value) => onSearch('search-input-change', { query: value })}
- />
- </div>
-
- <div className="flex items-center gap-x-2">
- <Button
- title="refresh"
- variant="default"
- className="px-1.5"
- icon={
- <div className="relative">
- {newCount > 0 && (
- <div className="absolute -top-3 -right-3 flex items-center justify-center">
- <div className="absolute h-4 w-4 animate-ping rounded-full bg-brand opacity-60"></div>
- <div className="relative z-10 flex h-4 min-w-4 items-center justify-center rounded-full bg-brand-500 px-1 text-[10px] font-medium leading-none text-white">
- {newCount > 1000 ? `${Math.floor(newCount / 100) / 10}K` : newCount}
- </div>
- </div>
- )}
- <RefreshCw />
- </div>
- }
- loading={isLoading}
- disabled={isLoading}
- onClick={onRefresh}
- />
-
- <Button
- variant="default"
- onClick={() => onToggleEventChart()}
- icon={isShowingEventChart ? <Eye /> : <EyeOff />}
- >
- Chart
- </Button>
-
- {/* <CSVButton data={csvData} disabled={!Boolean(csvData)} title="Download data" /> */}
-
- {showDatabaseSelector ? (
- <>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button asChild className="px-1.5" variant="default" icon={<Terminal />}>
- <Link href={queryUrl} />
- </Button>
- </TooltipTrigger>
- <TooltipContent side="bottom" className="text-xs">
- Open query in Logs Explorer
- </TooltipContent>
- </Tooltip>
- <DatabaseSelector
- onSelectId={onSelectedDatabaseChange}
- additionalOptions={
- table === LogsTableName.EDGE
- ? (loadBalancers ?? []).length > 0
- ? [{ id: `${ref}-all`, name: 'API Load Balancer' }]
- : []
- : []
- }
- />
- </>
- ) : (
- <Button asChild variant="default" onClick={onExploreClick}>
- <Link href={queryUrl}>Explore via query</Link>
- </Button>
- )}
- </div>
- </div>
- </div>
- )
-}
diff --git a/apps/studio/components/interfaces/Support/SupportSuccessSection.tsx b/apps/studio/components/interfaces/Support/SupportSuccessSection.tsx
deleted file mode 100644
index d8178166152..00000000000
--- a/apps/studio/components/interfaces/Support/SupportSuccessSection.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-import type { ReactNode } from 'react'
-import { cn } from 'ui'
-
-interface SupportSuccessSectionProps {
- icon?: ReactNode
- title: string
- description: ReactNode
- action?: ReactNode
- children?: ReactNode
- className?: string
- headerClassName?: string
-}
-
-export function SupportSuccessSection({
- icon,
- title,
- description,
- action,
- children,
- className,
- headerClassName,
-}: SupportSuccessSectionProps) {
- const hasIcon = icon !== undefined
-
- return (
- <div className={cn('w-full py-1', className)}>
- <div className="flex flex-col gap-4">
- <div
- className={cn(
- 'flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between',
- headerClassName
- )}
- >
- <div className={cn('flex min-w-0 flex-1 items-start', hasIcon ? 'gap-3' : 'gap-0')}>
- {hasIcon && (
- <div className="mt-0.5 flex h-10 w-10 shrink-0 items-center justify-center rounded-md border bg-background">
- {icon}
- </div>
- )}
- <div className="min-w-0 space-y-1">
- <h4 className="text-sm font-medium text-foreground">{title}</h4>
- <div className="text-sm text-foreground-light">{description}</div>
- </div>
- </div>
- {action && <div className="shrink-0 sm:ml-4">{action}</div>}
- </div>
- {children && <div className={cn(hasIcon && 'sm:pl-[52px]')}>{children}</div>}
- </div>
- </div>
- )
-}
diff --git a/apps/studio/components/interfaces/TableGridEditor/IndexAdvisorPopover.tsx b/apps/studio/components/interfaces/TableGridEditor/IndexAdvisorPopover.tsx
deleted file mode 100644
index 4c00de4812c..00000000000
--- a/apps/studio/components/interfaces/TableGridEditor/IndexAdvisorPopover.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import { Lightbulb } from 'lucide-react'
-import { Button, Popover, PopoverContent, PopoverTrigger } from 'ui'
-
-import { EnableIndexAdvisorButton } from '../QueryPerformance/IndexAdvisor/EnableIndexAdvisorButton'
-
-export const IndexAdvisorPopover = () => {
- return (
- <Popover modal={false}>
- <PopoverTrigger asChild>
- <Button variant="default" icon={<Lightbulb strokeWidth={1.5} />}>
- Index Advisor
- </Button>
- </PopoverTrigger>
- <PopoverContent className="w-80 text-sm" align="end">
- <h4 className="flex items-center gap-2">
- <Lightbulb size={16} /> Index Advisor
- </h4>
- <div className="grid gap-2 mt-4 text-foreground-light text-xs">
- <p>Index Advisor recommends indexes to improve query performance on this table.</p>
- <p>Enable Index Advisor to get recommendations based on your actual query patterns.</p>
- <div className="mt-2">
- <EnableIndexAdvisorButton />
- </div>
- </div>
- </PopoverContent>
- </Popover>
- )
-}
diff --git a/apps/studio/components/layouts/AppLayout/EnableBranchingButton/BranchingPlanNotice.tsx b/apps/studio/components/layouts/AppLayout/EnableBranchingButton/BranchingPlanNotice.tsx
deleted file mode 100644
index 430a08c131d..00000000000
--- a/apps/studio/components/layouts/AppLayout/EnableBranchingButton/BranchingPlanNotice.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-import { AlertCircleIcon } from 'lucide-react'
-import Link from 'next/link'
-import { Alert, AlertDescription, AlertTitle, Button } from 'ui'
-
-import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
-import { useAppStateSnapshot } from '@/state/app-state'
-
-export const BranchingPlanNotice = () => {
- const snap = useAppStateSnapshot()
- const { data: selectedOrg } = useSelectedOrganizationQuery()
-
- return (
- <Alert className="rounded-none px-7 py-6 [&>svg]:top-6 [&>svg]:left-6 border-0 border-t">
- <AlertCircleIcon />
- <AlertTitle>Database branching is only available on the Pro Plan and above</AlertTitle>
- <AlertDescription>
- Go to your organization's billing settings and upgrade your plan to enable branching for
- this project
- </AlertDescription>
- <AlertDescription>
- <Button size="tiny" variant="default" className="mt-4">
- <Link
- href={`/org/${selectedOrg?.slug}/billing?panel=subscriptionPlan&source=enableBranchingButton`}
- onClick={() => snap.setShowCreateBranchModal(false)}
- >
- Upgrade to Pro
- </Link>
- </Button>
- </AlertDescription>
- </Alert>
- )
-}
diff --git a/apps/studio/components/layouts/AppLayout/EnableBranchingButton/BranchingPostgresVersionNotice.tsx b/apps/studio/components/layouts/AppLayout/EnableBranchingButton/BranchingPostgresVersionNotice.tsx
deleted file mode 100644
index 79b96ac88a1..00000000000
--- a/apps/studio/components/layouts/AppLayout/EnableBranchingButton/BranchingPostgresVersionNotice.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import { useParams } from 'common'
-import { AlertCircleIcon } from 'lucide-react'
-import Link from 'next/link'
-import { Alert, AlertDescription, AlertTitle, Button } from 'ui'
-
-import { useAppStateSnapshot } from '@/state/app-state'
-
-export const BranchingPostgresVersionNotice = () => {
- const { ref } = useParams()
- const snap = useAppStateSnapshot()
-
- return (
- <Alert className="rounded-none px-7 py-6 [&>svg]:top-6 [&>svg]:left-6 border-t-0! border-l-0! border-r-0!">
- <AlertCircleIcon />
- <AlertTitle className="text-base">
- Your project needs to be on Postgres 15 to enable branching
- </AlertTitle>
- <AlertDescription>
- Head over to your project's infrastructure settings to upgrade to the latest version of
- Postgres before enabling branching.
- </AlertDescription>
- <AlertDescription>
- <Button size="tiny" variant="default" className="mt-4">
- <Link
- href={`/project/${ref}/settings/infrastructure`}
- onClick={() => snap.setShowCreateBranchModal(false)}
- >
- Head to project settings
- </Link>
- </Button>
- </AlertDescription>
- </Alert>
- )
-}
diff --git a/apps/studio/components/layouts/ProjectLayout/RestorePaidPlanProjectNotice.tsx b/apps/studio/components/layouts/ProjectLayout/RestorePaidPlanProjectNotice.tsx
deleted file mode 100644
index 129d171a004..00000000000
--- a/apps/studio/components/layouts/ProjectLayout/RestorePaidPlanProjectNotice.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import { ExternalLink } from 'lucide-react'
-import { Alert, AlertDescription, AlertTitle, Button, WarningIcon } from 'ui'
-
-import { DOCS_URL } from '@/lib/constants'
-
-export const RestorePaidPlanProjectNotice = () => {
- return (
- <Alert>
- <WarningIcon />
- <AlertTitle>Project will count towards compute usage once restored</AlertTitle>
- <AlertDescription>
- For every hour your instance is active, we will bill you based on the compute size of your
- project.
- </AlertDescription>
- <AlertDescription className="mt-3">
- <Button asChild variant="default" icon={<ExternalLink />}>
- <a
- href={`${DOCS_URL}/guides/platform/manage-your-usage/compute`}
- target="_blank"
- rel="noreferrer"
- >
- More information
- </a>
- </Button>
- </AlertDescription>
- </Alert>
- )
-}
diff --git a/apps/studio/components/layouts/Tabs/MigrateToPostgres.tsx b/apps/studio/components/layouts/Tabs/MigrateToPostgres.tsx
deleted file mode 100644
index 8bd139d1f17..00000000000
--- a/apps/studio/components/layouts/Tabs/MigrateToPostgres.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import { motion } from 'framer-motion'
-import { BaggageClaim, BookOpen } from 'lucide-react'
-import { Button } from 'ui'
-
-// not in use yet
-export const MigrateToPostgres = () => (
- <motion.div
- className="w-full rounded-lg overflow-hidden relative border border-muted"
- variants={{
- hidden: { opacity: 0, scale: 0.96, y: 15 },
- show: {
- opacity: 1,
- scale: 1,
- y: 0,
- transition: {
- type: 'spring',
- stiffness: 600,
- damping: 50,
- staggerChildren: 0.08,
- delayChildren: 0.03,
- },
- },
- }}
- >
- <div className="absolute inset-0 bg-linear-to-r from-background-surface-200 via-background-surface-200 to-transparent"></div>
- <div className="relative z-10 px-5 py-4 h-full flex gap-5 items-center justify-between">
- <div className="flex flex-col gap-3">
- <div className="flex gap-4">
- <div className="inline-flex items-center justify-center w-7 h-7 rounded-lg bg-surface-300 border">
- <BaggageClaim size={14} className="text-foreground-light" strokeWidth={1.5} />
- </div>
- <div className="flex flex-col gap-1">
- <h2 className="text-base text-foreground">Migrate your Database to Postgres</h2>
- <p className="text-xs text-foreground-light max-w-md">
- Already have a database? Migrate any database to Supabase to access backups, RESTful
- auto APIs, Authentication and more.
- </p>
- </div>
- </div>
- </div>
- <Button variant="default" className="rounded-full" iconRight={<BookOpen />}>
- Migrate to Postgres
- </Button>
- </div>
- </motion.div>
-)
diff --git a/apps/studio/components/to-be-cleaned/KeyMap.tsx b/apps/studio/components/to-be-cleaned/KeyMap.tsx
deleted file mode 100644
index a68221cabb2..00000000000
--- a/apps/studio/components/to-be-cleaned/KeyMap.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Render keyMap
- *
- * @param {String} keyMap ex: Command+Enter ; separate key using +
- */
-
-const customKeyChars: any = {
- command: '⌘',
- control: '⌃',
- option: '⌥',
- enter: '↵',
-}
-
-const KeyMap = ({ keyMap }: any) => {
- if (!keyMap) return null
-
- const keys = keyMap.split('+')
- const keymapRender = keys.map((key: any) => {
- let keyChar = key
- if (key.toLowerCase() in customKeyChars) keyChar = customKeyChars[key.toLowerCase()]
- return (
- <span key={key} className={`btn-keymap ${keyChar.length > 1 ? 'px-2' : ''}`}>
- {keyChar}
- </span>
- )
- })
- return <p className="inline-flex space-x-1.5">{keymapRender}</p>
-}
-
-export default KeyMap
diff --git a/apps/studio/hooks/misc/useInterval.ts b/apps/studio/hooks/misc/useInterval.ts
deleted file mode 100644
index 3e72cd2aca2..00000000000
--- a/apps/studio/hooks/misc/useInterval.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { useEffect, useRef } from 'react'
-
-export function useInterval(callback: () => void, delay: number | false) {
- const savedCallback = useRef(callback)
-
- useEffect(() => {
- savedCallback.current = callback
- }, [callback])
-
- useEffect(() => {
- if (delay === false) {
- return
- }
-
- const id = setInterval(() => {
- savedCallback.current()
- }, delay)
-
- return () => {
- clearInterval(id)
- }
- }, [delay])
-}
diff --git a/apps/studio/hooks/misc/useSchemasForAi.ts b/apps/studio/hooks/misc/useSchemasForAi.ts
deleted file mode 100644
index 6bc31602c38..00000000000
--- a/apps/studio/hooks/misc/useSchemasForAi.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { LOCAL_STORAGE_KEYS } from 'common'
-import { Dispatch, SetStateAction } from 'react'
-
-import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
-
-/**
- * Returns which schemas are ok to be sent to AI.
- */
-export function useSchemasForAi(
- ref: string
-): readonly [string[], Dispatch<SetStateAction<string[]>>] {
- const [enabledSchemas, setEnabledSchemas] = useLocalStorageQuery(
- LOCAL_STORAGE_KEYS.SQL_EDITOR_AI_SCHEMA(ref),
- ['public']
- )
-
- if (!ref) return [[], () => {}]
-
- return [enabledSchemas, setEnabledSchemas]
-}