Skip to content

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

Shift view replication action to table level and enable search via URL params in ETL pipeline status page (#40547)

Joshen Lim7d0d9c95fd84
diff --git a/apps/studio/components/interfaces/Database/ETL/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx b/apps/studio/components/interfaces/Database/ETL/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx
index ffaddc47aa8..e6eb18fbf74 100644
--- a/apps/studio/components/interfaces/Database/ETL/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx
+++ b/apps/studio/components/interfaces/Database/ETL/ReplicationPipelineStatus/ReplicationPipelineStatus.tsx
@@ -13,6 +13,7 @@ import {
X,
} from 'lucide-react'
import Link from 'next/link'
+import { parseAsString, useQueryState } from 'nuqs'
import { useEffect, useState } from 'react'
import { toast } from 'sonner'
@@ -52,7 +53,8 @@ import { SlotLagMetricsInline, SlotLagMetricsList } from './SlotLagMetrics'
*/
export const ReplicationPipelineStatus = () => {
const { ref: projectRef, pipelineId: _pipelineId } = useParams()
- const [filterString, setFilterString] = useState<string>('')
+ const [searchString, setSearchString] = useQueryState('search', parseAsString.withDefault(''))
+
const [showUpdateVersionModal, setShowUpdateVersionModal] = useState(false)
const pipelineId = Number(_pipelineId)
@@ -111,10 +113,10 @@ export const ReplicationPipelineStatus = () => {
const tableStatuses = replicationStatusData?.table_statuses || []
const applyLagMetrics = replicationStatusData?.apply_lag
const filteredTableStatuses =
- filterString.length === 0
+ searchString.length === 0
? tableStatuses
: tableStatuses.filter((table) =>
- table.table_name.toLowerCase().includes(filterString.toLowerCase())
+ table.table_name.toLowerCase().includes(searchString.toLowerCase())
)
const tablesWithLag = tableStatuses.filter((table) => Boolean(table.table_sync_lag))
@@ -214,18 +216,18 @@ export const ReplicationPipelineStatus = () => {
icon={<Search size={12} />}
className="pl-7 h-[26px] text-xs"
placeholder="Search for tables"
- value={filterString}
+ value={searchString}
disabled={isPipelineError}
- onChange={(e) => setFilterString(e.target.value)}
+ onChange={(e) => setSearchString(e.target.value)}
actions={
- filterString.length > 0
+ searchString.length > 0
? [
<X
key="close"
className="mx-2 cursor-pointer text-foreground"
size={14}
strokeWidth={2}
- onClick={() => setFilterString('')}
+ onClick={() => setSearchString('')}
/>,
]
: undefined
@@ -365,7 +367,7 @@ export const ReplicationPipelineStatus = () => {
<div className="space-y-1">
<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
+ Your search for "{searchString}" did not return any results
</p>
</div>
</Table.td>
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/BucketHeader.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/BucketHeader.tsx
index 07900b4d9cc..685f8ab9264 100644
--- a/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/BucketHeader.tsx
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/BucketHeader.tsx
@@ -1,5 +1,4 @@
import { noop } from 'lodash'
-import Link from 'next/link'
import { useParams } from 'common'
import { FormattedWrapperTable } from 'components/interfaces/Integrations/Wrappers/Wrappers.utils'
@@ -9,7 +8,6 @@ import {
ScaffoldSectionTitle,
} from 'components/layouts/Scaffold'
import { useReplicationPipelineStatusQuery } from 'data/etl/pipeline-status-query'
-import { Button } from 'ui'
import { ConnectTablesDialog } from './ConnectTablesDialog'
import { useAnalyticsBucketAssociatedEntities } from './useAnalyticsBucketAssociatedEntities'
@@ -45,13 +43,6 @@ export const BucketHeader = ({
</div>
{showActions && (
<div className="flex items-center gap-x-2">
- {!!pipeline && isPipelineRunning && (
- <Button asChild type="default">
- <Link href={`/project/${projectRef}/database/etl/${pipeline.replicator_id}`}>
- View replication
- </Link>
- </Button>
- )}
{namespaces.length > 0 && (
<ConnectTablesDialog onSuccessConnectTables={onSuccessConnectTables} />
)}
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/NamespaceWithTables/TableRowComponent.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/NamespaceWithTables/TableRowComponent.tsx
index 7661747b52f..905641ba86d 100644
--- a/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/NamespaceWithTables/TableRowComponent.tsx
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/NamespaceWithTables/TableRowComponent.tsx
@@ -1,5 +1,5 @@
import { uniq } from 'lodash'
-import { Loader2, MoreVertical, Pause, Play, Trash } from 'lucide-react'
+import { Eye, Loader2, MoreVertical, Pause, Play, Trash } from 'lucide-react'
import Link from 'next/link'
import { useMemo, useState } from 'react'
import { toast } from 'sonner'
@@ -68,7 +68,10 @@ export const TableRowComponent = ({
projectRef,
bucketId,
})
- const { data } = useReplicationPipelineStatusQuery({ projectRef, pipelineId: pipeline?.id })
+ const { data, isLoading: isLoadingPipelineStatus } = useReplicationPipelineStatusQuery({
+ projectRef,
+ pipelineId: pipeline?.id,
+ })
const pipelineStatus = data?.status.name
const { data: tables } = useReplicationTablesQuery({ projectRef, sourceId })
@@ -94,10 +97,10 @@ export const TableRowComponent = ({
// [Joshen] Considers both the replication pipeline status + if the table is in the replication publication
const replicationStatusLabel = useMemo(() => {
- if (isLoading) return 'Checking'
-
if (hasReplication) {
- if (!isPipelineRunning) {
+ if (isLoadingPipelineStatus) {
+ return 'Checking'
+ } else if (!isPipelineRunning) {
return '-'
} else if (isTableUnderReplicationPublication) {
return 'Running'
@@ -105,7 +108,12 @@ export const TableRowComponent = ({
return 'Disabled'
}
}
- }, [hasReplication, isLoading, isPipelineRunning, isTableUnderReplicationPublication])
+ }, [
+ hasReplication,
+ isLoadingPipelineStatus,
+ isPipelineRunning,
+ isTableUnderReplicationPublication,
+ ])
const onConfirmStopReplication = async () => {
if (!projectRef) return console.error('Project ref is required')
@@ -245,7 +253,7 @@ export const TableRowComponent = ({
<Tooltip>
<TooltipTrigger asChild>
<div className="flex items-center gap-x-2">
- {isLoading ? (
+ {isLoadingPipelineStatus ? (
<Loader2 size={12} className="animate-spin text-foreground-lighter" />
) : isPipelineRunning ? (
<DotPing
@@ -288,7 +296,7 @@ export const TableRowComponent = ({
<DropdownMenuContent side="bottom" align="end" className="w-fit min-w-[180px]">
<DropdownMenuItem asChild className="flex items-center gap-x-2">
<Link
- href={`/project/${project?.ref}/sql/new?content=${encodeURIComponent(`select * from ${schema}.${table.name};`)}`}
+ href={`/project/${projectRef}/sql/new?content=${encodeURIComponent(`select * from ${schema}.${table.name};`)}`}
>
<SqlEditor size={12} className="text-foreground-lighter" />
<p>Query in SQL Editor</p>
@@ -297,6 +305,16 @@ export const TableRowComponent = ({
{!!publication && (
<>
+ {!!inferredPostgresTable && (
+ <DropdownMenuItem asChild className="flex items-center gap-x-2">
+ <Link
+ href={`/project/${projectRef}/database/etl/${pipeline?.id}?search=${inferredPostgresTable.schema}.${inferredPostgresTable.name}`}
+ >
+ <Eye size={12} className="text-foreground-lighter" />
+ <p>View replication</p>
+ </Link>
+ </DropdownMenuItem>
+ )}
{isTableUnderReplicationPublication ? (
<DropdownMenuItem
className="flex items-center gap-x-2"
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/NamespaceWithTables/index.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/NamespaceWithTables/index.tsx
index 1556842da14..ac3cb172101 100644
--- a/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/NamespaceWithTables/index.tsx
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/NamespaceWithTables/index.tsx
@@ -239,7 +239,7 @@ export const NamespaceWithTables = ({
<TableHeader>
<TableRow>
<TableHead className={allTables.length === 0 ? 'text-foreground-muted' : undefined}>
- Table name
+ Name
</TableHead>
{!!publication && (
<TableHead className={allTables.length === 0 ? 'hidden' : undefined}>
diff --git a/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/useAnalyticsBucketAssociatedEntities.tsx b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/useAnalyticsBucketAssociatedEntities.tsx
index f864a6862a0..e5161679117 100644
--- a/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/useAnalyticsBucketAssociatedEntities.tsx
+++ b/apps/studio/components/interfaces/Storage/AnalyticsBuckets/AnalyticsBucketDetails/useAnalyticsBucketAssociatedEntities.tsx
@@ -50,10 +50,8 @@ export const useAnalyticsBucketAssociatedEntities = (
)
const sourceId = sourcesData?.sources.find((s) => s.name === projectRef)?.id
- const { data: publications = [] } = useReplicationPublicationsQuery(
- { projectRef, sourceId },
- { enabled: options.enabled }
- )
+ const { data: publications = [], isLoading: isLoadingPublications } =
+ useReplicationPublicationsQuery({ projectRef, sourceId }, { enabled: options.enabled })
const publication = publications.find(
(p) => p.name === getAnalyticsBucketPublicationName(bucketId ?? '')
)
diff --git a/apps/studio/pages/project/[ref]/database/etl/[pipelineId].tsx b/apps/studio/pages/project/[ref]/database/etl/[pipelineId].tsx
index 3dd9fd4922f..c8a075988ff 100644
--- a/apps/studio/pages/project/[ref]/database/etl/[pipelineId].tsx
+++ b/apps/studio/pages/project/[ref]/database/etl/[pipelineId].tsx
@@ -19,7 +19,7 @@ const DatabaseReplicationPage: NextPageWithLayout = () => {
useEffect(() => {
if (hasLoaded && !enablePgReplicate) {
- router.replace(`/project/${projectRef}/database/etl}`)
+ router.replace(`/project/${projectRef}/database/etl`)
}
}, [router, hasLoaded, projectRef, enablePgReplicate])