DeleteOAuthAppModal.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import type { OAuthClient } from '@supabase/supabase-js'
  2. import { useParams } from 'common'
  3. import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
  4. import { useProjectApiUrl } from '@/data/config/project-endpoint-query'
  5. import type { OAuthServerAppDeleteVariables } from '@/data/oauth-server-apps/oauth-server-app-delete-mutation'
  6. interface DeleteOAuthAppModalProps {
  7. visible: boolean
  8. selectedApp?: OAuthClient
  9. setVisible: (value: string | null) => void
  10. onDelete: (params: OAuthServerAppDeleteVariables) => void
  11. isLoading: boolean
  12. }
  13. export const DeleteOAuthAppModal = ({
  14. visible,
  15. selectedApp,
  16. setVisible,
  17. onDelete,
  18. isLoading,
  19. }: DeleteOAuthAppModalProps) => {
  20. const { ref: projectRef } = useParams()
  21. const { hostEndpoint: clientEndpoint } = useProjectApiUrl({ projectRef })
  22. const onConfirmDeleteApp = () => {
  23. onDelete({
  24. projectRef,
  25. clientEndpoint,
  26. clientId: selectedApp?.client_id,
  27. })
  28. }
  29. return (
  30. <ConfirmationModal
  31. variant={'destructive'}
  32. size="medium"
  33. loading={isLoading}
  34. visible={visible}
  35. title={
  36. <>
  37. Confirm to delete OAuth app{' '}
  38. <code className="text-code-inline">{selectedApp?.client_name}</code>
  39. </>
  40. }
  41. confirmLabel="Confirm delete"
  42. confirmLabelLoading="Deleting..."
  43. onCancel={() => setVisible(null)}
  44. onConfirm={() => onConfirmDeleteApp()}
  45. alert={{
  46. title: 'This action cannot be undone',
  47. description: 'You will need to re-create the OAuth app if you want to revert the deletion.',
  48. }}
  49. >
  50. <p className="text-sm">Before deleting this OAuth app, consider:</p>
  51. <ul className="space-y-2 mt-2 text-sm text-foreground-light">
  52. <li className="list-disc ml-6">Any applications using this OAuth app will lose access</li>
  53. <li className="list-disc ml-6">This OAuth app is no longer in use by any applications</li>
  54. </ul>
  55. </ConfirmationModal>
  56. )
  57. }