Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix(studio): show legacy API keys toggle for project-level admins (#44382)

Cemal Kılıçca5f8d66f1dc
diff --git a/apps/studio/components/ui/ProjectSettings/ToggleLegacyApiKeys.tsx b/apps/studio/components/ui/ProjectSettings/ToggleLegacyApiKeys.tsx
index 7b2fe7a3afe..c965b5991cf 100644
--- a/apps/studio/components/ui/ProjectSettings/ToggleLegacyApiKeys.tsx
+++ b/apps/studio/components/ui/ProjectSettings/ToggleLegacyApiKeys.tsx
@@ -44,13 +44,46 @@ export const ToggleLegacyApiKeysPanel = () => {
{ enabled: canReadAPIKeys }
)
- const { data: authorizedApps = [], isSuccess: isAuthorizedAppsSuccess } = useAuthorizedAppsQuery({
+ const { data: authorizedApps = [], isError: isAuthorizedAppsError } = useAuthorizedAppsQuery({
slug: org?.slug,
})
const { enabled: isLegacyKeysEnabled } = legacyAPIKeysStatusData || {}
- if (!(isLegacyAPIKeysStatusSuccess && isPermissionsSuccess && isAuthorizedAppsSuccess)) {
+ const oauthAppsLink = (
+ <a
+ href={`/dashboard/org/${org?.slug}/apps`}
+ target="_blank"
+ rel="noreferrer"
+ className="underline"
+ >
+ OAuth apps
+ </a>
+ )
+
+ const appsWarning = isAuthorizedAppsError
+ ? {
+ title: 'Check your OAuth apps before continuing',
+ description: (
+ <>
+ Disabling legacy API keys can break apps that integrate with Supabase. Before
+ continuing, check your organization's {oauthAppsLink} to ensure none of them depend on
+ the legacy API keys.
+ </>
+ ),
+ }
+ : {
+ title: 'Apps using Supabase may break',
+ description: (
+ <>
+ Your project uses apps that integrate with Supabase. Disabling the legacy API keys is a
+ brand new feature and the apps you're using may not have added support for this yet. It
+ can cause them to stop functioning. Check your {oauthAppsLink} before continuing.
+ </>
+ ),
+ }
+
+ if (!(isLegacyAPIKeysStatusSuccess && isPermissionsSuccess)) {
return null
}
@@ -73,7 +106,7 @@ export const ToggleLegacyApiKeysPanel = () => {
<ButtonTooltip
type="default"
onClick={
- authorizedApps?.length
+ isLegacyKeysEnabled && (authorizedApps?.length || isAuthorizedAppsError)
? () => setIsAppsWarningOpen(true)
: () => setIsConfirmOpen(true)
}
@@ -110,12 +143,8 @@ export const ToggleLegacyApiKeysPanel = () => {
<AlertDialog open={isAppsWarningOpen} onOpenChange={(value) => setIsAppsWarningOpen(value)}>
<AlertDialogContent>
<AlertDialogHeader>
- <AlertDialogTitle>Apps using Supabase may break</AlertDialogTitle>
- <AlertDialogDescription>
- Your project uses apps that integrate with Supabase. Disabling the legacy API keys is
- a brand new feature and the apps you’re using may not have added support for this yet.
- It can cause them to stop functioning. Check before continuing.
- </AlertDialogDescription>
+ <AlertDialogTitle>{appsWarning.title}</AlertDialogTitle>
+ <AlertDialogDescription>{appsWarning.description}</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>