Files
supabase/apps/studio/components/interfaces/Database/Replication/DisablePipelinesDialog.tsx
Joshen Lim 78957bcd68 Replace disable pipelines cta with enable pipelines if pipelines not enabled yet (#48518)
## Context

Addresses 2 issues found for the Replication UI

- "Disable Pipelines" CTA was still being shown despite Pipelines not
being enabled yet
- Opting to show the "Enable Pipelines" CTA instead in this case, which
will open the `EnablePipelinesModal`
<img width="269" height="162" alt="image"
src="https://github.com/user-attachments/assets/41e5ec7d-11b1-4008-ae9d-64def00329eb"
/>
- Fixes "Disable Pipelines" being incorrectly disabled


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added options to enable or disable Pipelines directly from the
replication destinations menu.
* Added an enablement modal with messaging and upgrade actions based on
available access.
* Added support for opening the Pipelines modal through external
controls.

* **Bug Fixes**
  * Corrected action disabled states and destination-removal guidance.
* Improved error handling when disabling Pipelines, including a reliable
fallback message.
* Refined modal and dialog layout spacing for a more consistent
presentation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-07-31 11:43:02 +07:00

86 lines
2.6 KiB
TypeScript

import { useParams } from 'common'
import { useState } from 'react'
import { toast } from 'sonner'
import {
AlertDialog,
AlertDialogAction,
AlertDialogBody,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from 'ui'
import { Admonition } from 'ui-patterns/Admonition'
import { useDeleteReplicationTenantMutation } from '@/data/replication/delete-tenant-mutation'
interface DisablePipelinesDialogProps {
open: boolean
setOpen: (value: boolean) => void
}
export const DisablePipelinesDialog = ({ open, setOpen }: DisablePipelinesDialogProps) => {
const { ref: projectRef } = useParams()
const [error, setError] = useState<string | null>(null)
const { mutateAsync: deleteReplicationTenant, isPending: isSubmitting } =
useDeleteReplicationTenantMutation({
onSuccess: () => {
toast.success('Pipelines has been disabled')
setOpen(false)
},
onError: () => {},
})
const onConfirm = async () => {
setError(null)
try {
if (!projectRef) throw new Error('Project ref is required')
await deleteReplicationTenant({ projectRef })
} catch (error) {
setError(
error instanceof Error
? error.message
: 'An unknown error occurred while disabling Pipelines'
)
throw error
}
}
return (
<AlertDialog open={open} onOpenChange={(open) => !isSubmitting && setOpen(open)}>
<AlertDialogContent size="small">
<AlertDialogHeader>
<AlertDialogTitle>Disable Pipelines</AlertDialogTitle>
<AlertDialogDescription className="flex flex-col gap-y-2 text-sm">
<span>
This will remove the <code className="text-code-inline">etl</code> schema and all
Pipelines-managed resources from your database. Data already written to destination
systems is not deleted.
</span>
<span>Read replicas are not affected.</span>
</AlertDialogDescription>
</AlertDialogHeader>
{error && (
<AlertDialogBody>
<Admonition
type="destructive"
title="Unable to disable Pipelines"
description={error}
/>
</AlertDialogBody>
)}
<AlertDialogFooter>
<AlertDialogCancel disabled={isSubmitting}>Cancel</AlertDialogCancel>
<AlertDialogAction variant="danger" loading={isSubmitting} onClick={onConfirm}>
Disable
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
)
}