import { useParams } from 'common' import { Lock } from 'lucide-react' import { toast } from 'sonner' import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from 'ui' import { Admonition } from 'ui-patterns/admonition' import { useAuthorizedAppRevokeMutation } from '@/data/oauth/authorized-app-revoke-mutation' import type { AuthorizedApp } from '@/data/oauth/authorized-apps-query' export interface RevokeAppModalProps { selectedApp?: AuthorizedApp /** Optional Organization slug override for routes without a `slug` param (e.g. project integrations). */ orgSlug?: string onClose: () => void } export const RevokeAppModal = ({ selectedApp, orgSlug: slugOverride, onClose, }: RevokeAppModalProps) => { const { slug: slugParam } = useParams() const orgSlug = slugOverride ?? slugParam const { mutateAsync: revokeAuthorizedApp } = useAuthorizedAppRevokeMutation({ onSuccess: () => { toast.success(`Successfully revoked the app "${selectedApp?.name}"`) onClose() }, }) const onConfirmDelete = async () => { if (!orgSlug) return console.error('Organization slug is required') if (!selectedApp?.id) return console.error('App ID is required') await revokeAuthorizedApp({ orgSlug, id: selectedApp?.id }) } return ( {`Revoke access for ${selectedApp?.name}?`}
  • Before you remove this app, consider:
    • The application will no longer have access to your organization after being revoked.
    • This will remove the application for all members in your organization.
    • Restoring access will require an organization administrator to re-authorize the application.
Cancel Confirm
) }