DisableCustomProviderModal.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import type { CustomOAuthProvider } from '@supabase/auth-js'
  2. import { useParams } from 'common'
  3. import { toast } from 'sonner'
  4. import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
  5. import { useProjectApiUrl } from '@/data/config/project-endpoint-query'
  6. import { useOAuthCustomProviderUpdateMutation } from '@/data/oauth-custom-providers/oauth-custom-provider-update-mutation'
  7. interface DisableCustomProviderModalProps {
  8. visible: boolean
  9. selectedProvider?: CustomOAuthProvider
  10. onClose: () => void
  11. }
  12. export const DisableCustomProviderModal = ({
  13. visible,
  14. selectedProvider,
  15. onClose,
  16. }: DisableCustomProviderModalProps) => {
  17. const { ref: projectRef } = useParams()
  18. const { hostEndpoint: clientEndpoint } = useProjectApiUrl({ projectRef })
  19. const { mutate, isPending } = useOAuthCustomProviderUpdateMutation({
  20. onSuccess: () => {
  21. toast.success('Custom provider disabled')
  22. onClose()
  23. },
  24. })
  25. const onConfirmDisable = () => {
  26. mutate({
  27. identifier: selectedProvider?.identifier,
  28. projectRef,
  29. clientEndpoint,
  30. enabled: false,
  31. })
  32. }
  33. return (
  34. <ConfirmationModal
  35. variant="warning"
  36. size="medium"
  37. loading={isPending}
  38. visible={visible}
  39. title={
  40. <>
  41. Confirm to disable custom provider{' '}
  42. <code className="text-sm">{selectedProvider?.name}</code>
  43. </>
  44. }
  45. confirmLabel="Confirm disable"
  46. confirmLabelLoading="Disabling..."
  47. onCancel={() => onClose()}
  48. onConfirm={() => onConfirmDisable()}
  49. alert={{
  50. title: 'Users will not be able to sign in with this provider',
  51. description:
  52. 'You can re-enable it at any time. Existing sessions are not affected, but new sign-ins will fail until the provider is re-enabled.',
  53. }}
  54. >
  55. <p className="text-sm">Before disabling this custom provider, consider:</p>
  56. <ul className="space-y-2 mt-2 text-sm text-foreground-light">
  57. <li className="list-disc ml-6">
  58. Users authenticating with this provider will be unable to sign in
  59. </li>
  60. <li className="list-disc ml-6">
  61. Applications relying on this provider should be updated or paused
  62. </li>
  63. </ul>
  64. </ConfirmationModal>
  65. )
  66. }