Skip to content

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

Feat: Update API key display settings to show new ones rather than legacy (#40537)

Ali Waseemc05886799907
diff --git a/apps/studio/components/interfaces/App/CommandMenu/ApiKeys.tsx b/apps/studio/components/interfaces/App/CommandMenu/ApiKeys.tsx
index 07ecb3652d1..1b192abf3b4 100644
--- a/apps/studio/components/interfaces/App/CommandMenu/ApiKeys.tsx
+++ b/apps/studio/components/interfaces/App/CommandMenu/ApiKeys.tsx
@@ -36,6 +36,39 @@ export function useApiKeysCommands() {
: {}
return [
+ project &&
+ publishableKey && {
+ id: 'publishable-key',
+ name: `Copy publishable key`,
+ action: () => {
+ copyToClipboard(publishableKey.api_key ?? '')
+ setIsOpen(false)
+ },
+ badge: () => (
+ <span className="flex items-center gap-x-1">
+ <Badge>Project: {project?.name}</Badge>
+ <Badge className="capitalize">{publishableKey.type}</Badge>
+ </span>
+ ),
+ icon: () => <Key />,
+ },
+ ...(project && allSecretKeys
+ ? allSecretKeys.map((key) => ({
+ id: key.id,
+ name: `Copy secret key (${key.name})`,
+ action: () => {
+ copyToClipboard(key.api_key ?? '')
+ setIsOpen(false)
+ },
+ badge: () => (
+ <span className="flex items-center gap-x-1">
+ <Badge>Project: {project?.name}</Badge>
+ <Badge className="capitalize">{key.type}</Badge>
+ </span>
+ ),
+ icon: () => <Key />,
+ }))
+ : []),
project &&
anonKey && {
id: 'anon-key',
@@ -70,39 +103,6 @@ export function useApiKeysCommands() {
),
icon: () => <Key />,
},
- project &&
- publishableKey && {
- id: 'publishable-key',
- name: `Copy publishable key`,
- action: () => {
- copyToClipboard(publishableKey.api_key ?? '')
- setIsOpen(false)
- },
- badge: () => (
- <span className="flex items-center gap-x-1">
- <Badge>Project: {project?.name}</Badge>
- <Badge className="capitalize">{publishableKey.type}</Badge>
- </span>
- ),
- icon: () => <Key />,
- },
- ...(project && allSecretKeys
- ? allSecretKeys.map((key) => ({
- id: key.id,
- name: `Copy secret key (${key.name})`,
- action: () => {
- copyToClipboard(key.api_key ?? '')
- setIsOpen(false)
- },
- badge: () => (
- <span className="flex items-center gap-x-1">
- <Badge>Project: {project?.name}</Badge>
- <Badge className="capitalize">{key.type}</Badge>
- </span>
- ),
- icon: () => <Key />,
- }))
- : []),
!(anonKey || serviceKey) && {
id: 'api-keys-project-settings',
name: 'See API keys in Project Settings',
diff --git a/apps/studio/components/layouts/APIKeys/APIKeysLayout.tsx b/apps/studio/components/layouts/APIKeys/APIKeysLayout.tsx
index a29be33a270..b466ba23c72 100644
--- a/apps/studio/components/layouts/APIKeys/APIKeysLayout.tsx
+++ b/apps/studio/components/layouts/APIKeys/APIKeysLayout.tsx
@@ -8,16 +8,16 @@ const ApiKeysLayout = ({ children }: PropsWithChildren) => {
const { ref: projectRef } = useParams()
const navigationItems = [
- {
- label: 'Legacy API Keys',
- href: `/project/${projectRef}/settings/api-keys`,
- id: 'legacy-keys',
- },
{
label: 'API Keys',
href: `/project/${projectRef}/settings/api-keys/new`,
id: 'new-keys',
},
+ {
+ label: 'Legacy API Keys',
+ href: `/project/${projectRef}/settings/api-keys`,
+ id: 'legacy-keys',
+ },
]
return (
diff --git a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx
index 046adda409b..88b88c5a687 100644
--- a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx
+++ b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx
@@ -84,7 +84,7 @@ export const generateSettingsMenu = (
{
name: 'API Keys',
key: 'api-keys',
- url: `/project/${ref}/settings/api-keys`,
+ url: `/project/${ref}/settings/api-keys/new`,
items: [],
},
{