Files
supabase/apps/studio/components/interfaces/Auth/OAuthApps/DeleteOAuthAppModal.tsx
Francesco SansalvadoreandIvan Vasilov bc22be3855 feat: OAuth 2.1 - OAuth apps (#39165)
* oAuth clients index layout

* oAuth apps crud

* is public

* add user count and client secret generation and management

* scaffold oauth server settings

* improve oauth server enablement / disablement

* show cover when oAuth server is disabled

* fix update panel update button

* add site url and authorization path settings values

* move oauth server to it's own nav item

* remove unneeded oauth server settings

* let the user disactivate oauth server even after creating oauth apps

* better delete button

* cleanup

* fix typecheck

* test endpoints

* add EnableOAuth21 feature flag

* update OAUTH_SERVER_ auth config api

* load OAUTH_SERVER_ENABLED in oauth list

* Update the api.d.ts. Remove the custom versions of supa libs.

* Add query for getTemporaryAPIKey.

* Add a hook for initializing a supabase client.

* Add hooks for oAuth Server apps.

* Regenerate pnpm-lock.yaml.

* Revert updates to the platform.d.ts. Not needed for this PR.

* Migrate all code to use the new hooks.

* Try to integrate the mutations and fix some of the sheet and dialogs.

* improve default and saving states

* fix oauth app form validation

* unify components into CreateOrUpdateOAuthAppModal

* create or update oauth app

* Update the OAuth Server page.

* Remove extra files.

* Minor various fixes.

* More fixes to the creation of oauth apps.

* Bump the libs to fix a DELETE oauth app error.

* Clean up the scope feature.

* Move the feature flag in the auth layout.

* Bunch of smaller fixes.

* Regenerate pnpm-lock.

* Revert SidePanel and CardDescription changes.

* Add confirm dialog for regenerating secret.

---------

Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2025-10-30 17:07:07 +00:00

78 lines
2.4 KiB
TypeScript

import type { OAuthClient } from '@supabase/supabase-js'
import { useParams } from 'common'
import { useOAuthServerAppDeleteMutation } from 'data/oauth-server-apps/oauth-server-app-delete-mutation'
import { useSupabaseClientQuery } from 'hooks/use-supabase-client-query'
import { useState } from 'react'
import { toast } from 'sonner'
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
interface DeleteOAuthAppModalProps {
visible: boolean
selectedApp?: OAuthClient
onClose: () => void
}
export const DeleteOAuthAppModal = ({
visible,
selectedApp,
onClose,
}: DeleteOAuthAppModalProps) => {
const { ref: projectRef } = useParams()
const [isDeleting, setIsDeleting] = useState(false)
const { data: supabaseClientData } = useSupabaseClientQuery({ projectRef })
const { mutateAsync: deleteOAuthApp } = useOAuthServerAppDeleteMutation()
const onConfirmDeleteApp = async () => {
if (!selectedApp) return console.error('No OAuth app selected')
setIsDeleting(true)
try {
await deleteOAuthApp({
projectRef,
supabaseClient: supabaseClientData?.supabaseClient,
clientId: selectedApp.client_id,
})
toast.success(`Successfully deleted OAuth app "${selectedApp.client_name}"`)
onClose()
} catch (error) {
toast.error('Failed to delete OAuth app')
console.error('Error deleting OAuth app:', error)
} finally {
setIsDeleting(false)
}
}
return (
<ConfirmationModal
variant={'destructive'}
size="medium"
loading={isDeleting}
visible={visible}
title={
<>
Confirm to delete OAuth app <code className="text-sm">{selectedApp?.client_name}</code>
</>
}
confirmLabel="Confirm delete"
confirmLabelLoading="Deleting..."
onCancel={onClose}
onConfirm={() => onConfirmDeleteApp()}
alert={{
title: 'This action cannot be undone',
description: 'You will need to re-create the OAuth app if you want to revert the deletion.',
}}
>
<p className="text-sm">Before deleting this OAuth app, consider:</p>
<ul className="space-y-2 mt-2 text-sm text-foreground-light">
<li className="list-disc ml-6">Any applications using this OAuth app will lose access</li>
<li className="list-disc ml-6">This OAuth app is no longer in use by any applications</li>
</ul>
</ConfirmationModal>
)
}