mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 23:49:03 +00:00
## Description Part of the work for OAuth apps with the scoped permissions. This PR wires the org and users authorized apps lists to backend.
69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
import { ComponentProps } from 'react'
|
|
import { toast } from 'sonner'
|
|
import {
|
|
Button,
|
|
DialogClose,
|
|
DialogContent,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogSection,
|
|
DialogSectionSeparator,
|
|
DialogTitle,
|
|
} from 'ui'
|
|
|
|
import { OAuthGrant } from '@/data/oauth-apps/oauth-apps-grants-query'
|
|
import { useOAuthGrantRevokeMutation } from '@/data/oauth-apps/oauth-apps-revoke-grant-mutation'
|
|
|
|
interface GrantDisconnectDialogContentProps extends ComponentProps<typeof DialogContent> {
|
|
grant: OAuthGrant
|
|
onClose: () => void
|
|
}
|
|
|
|
export const GrantDisconnectDialogContent = ({
|
|
grant,
|
|
onClose,
|
|
...props
|
|
}: GrantDisconnectDialogContentProps) => {
|
|
const { mutate: revokeGrant, isPending } = useOAuthGrantRevokeMutation({
|
|
onSuccess: () => {
|
|
toast.success(`Revoked access for ${grant?.attributes.app?.name}`)
|
|
onClose()
|
|
},
|
|
})
|
|
|
|
return (
|
|
<DialogContent size="small" {...props}>
|
|
<DialogHeader>
|
|
<DialogTitle>Revoke access for {grant?.attributes.app?.name}</DialogTitle>
|
|
</DialogHeader>
|
|
<DialogSectionSeparator />
|
|
<DialogSection>
|
|
<div className="flex flex-col gap-4 text-sm text-foreground-light">
|
|
<p>
|
|
{grant?.attributes.app.name} will no longer be able to access your projects. To
|
|
reconnect, authorize {grant?.attributes.app.name} again and reselect your projects.
|
|
</p>
|
|
<p>Other organization members won't be affected.</p>
|
|
</div>
|
|
</DialogSection>
|
|
|
|
<DialogFooter>
|
|
<DialogClose asChild>
|
|
<Button variant="default" disabled={isPending}>
|
|
Cancel
|
|
</Button>
|
|
</DialogClose>
|
|
<Button
|
|
variant="danger"
|
|
loading={isPending}
|
|
onClick={() => {
|
|
if (grant) revokeGrant({ grantId: grant.id })
|
|
}}
|
|
>
|
|
Revoke
|
|
</Button>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
)
|
|
}
|