Skip to content

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

Fix edge functions secrets permissions state (#34506)

Joshen Lime88595be8673
diff --git a/apps/studio/components/interfaces/Advisors/CreateRuleSheet.tsx b/apps/studio/components/interfaces/Advisors/CreateRuleSheet.tsx
index e7cb8dee848..155ca18a6cc 100644
--- a/apps/studio/components/interfaces/Advisors/CreateRuleSheet.tsx
+++ b/apps/studio/components/interfaces/Advisors/CreateRuleSheet.tsx
@@ -7,7 +7,6 @@ import * as z from 'zod'
import { useParams } from 'common'
import { useLintRuleCreateMutation } from 'data/lint/create-lint-rule-mutation'
-import { LintName } from 'data/lint/lint-rules-query'
import { useOrganizationMembersQuery } from 'data/organizations/organization-members-query'
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
import { useRouter } from 'next/router'
@@ -112,7 +111,7 @@ export const CreateRuleSheet = ({ lint, open, onOpenChange }: CreateRuleSheetPro
exception: {
...values,
lint_category: undefined,
- lint_name: values.lint_name as LintName,
+ lint_name: values.lint_name,
assigned_to: values.assigned_to === 'all' ? undefined : values.assigned_to,
},
})
diff --git a/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/EdgeFunctionSecrets.tsx b/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/EdgeFunctionSecrets.tsx
index 774807393e6..98c2e51e065 100644
--- a/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/EdgeFunctionSecrets.tsx
+++ b/apps/studio/components/interfaces/Functions/EdgeFunctionSecrets/EdgeFunctionSecrets.tsx
@@ -1,9 +1,9 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
-import { useParams } from 'common'
import { Search } from 'lucide-react'
import { useState } from 'react'
import { toast } from 'sonner'
+import { useParams } from 'common'
import Table from 'components/to-be-cleaned/Table'
import AlertError from 'components/ui/AlertError'
import NoPermission from 'components/ui/NoPermission'
@@ -46,76 +46,77 @@ const EdgeFunctionSecrets = () => {
<>
{isLoading && <GenericSkeletonLoader />}
{isError && <AlertError error={error} subject="Failed to retrieve project secrets" />}
-
- {isSuccess && canUpdateSecrets && (
+ {isSuccess && (
<>
- <div className="grid gap-5">
- <AddNewSecretForm />
- <Separator />
- </div>
- <div className="space-y-4 mt-4">
- {!canReadSecrets ? (
- <NoPermission resourceText="view this project's edge function secrets" />
- ) : (
- <>
- <div className="flex flex-col md:flex-row md:items-center justify-between gap-2">
- <Input
- size="small"
- className="w-full md:w-80"
- placeholder="Search for a secret"
- value={searchString}
- onChange={(e: any) => setSearchString(e.target.value)}
- icon={<Search size={14} />}
- />
- </div>
+ {!canUpdateSecrets ? (
+ <NoPermission resourceText="manage this project's edge function secrets" />
+ ) : (
+ <div className="grid gap-5">
+ <AddNewSecretForm />
+ <Separator />
+ </div>
+ )}
+ {canUpdateSecrets && !canReadSecrets ? (
+ <NoPermission resourceText="view this project's edge function secrets" />
+ ) : canReadSecrets ? (
+ <div className="space-y-4 mt-4">
+ <div className="flex flex-col md:flex-row md:items-center justify-between gap-2">
+ <Input
+ size="small"
+ className="w-full md:w-80"
+ placeholder="Search for a secret"
+ value={searchString}
+ onChange={(e: any) => setSearchString(e.target.value)}
+ icon={<Search size={14} />}
+ />
+ </div>
- <div className="w-full overflow-hidden overflow-x-auto">
- <Table
- head={[
- <Table.th key="secret-name">Name</Table.th>,
- <Table.th key="secret-value" className="flex items-center gap-x-2">
- Digest{' '}
- <Badge color="scale" className="font-mono">
- SHA256
- </Badge>
- </Table.th>,
- <Table.th key="secret-updated-at">Updated at</Table.th>,
- <Table.th key="actions" />,
- ]}
- body={
- secrets.length > 0 ? (
- secrets.map((secret) => (
- <EdgeFunctionSecret
- key={secret.name}
- secret={secret}
- onSelectDelete={() => setSelectedSecret(secret)}
- />
- ))
- ) : secrets.length === 0 && searchString.length > 0 ? (
- <Table.tr>
- <Table.td colSpan={3}>
- <p className="text-sm text-foreground">No results found</p>
- <p className="text-sm text-foreground-light">
- Your search for "{searchString}" did not return any results
- </p>
- </Table.td>
- </Table.tr>
- ) : (
- <Table.tr>
- <Table.td colSpan={3}>
- <p className="text-sm text-foreground">No secrets created</p>
- <p className="text-sm text-foreground-light">
- There are no secrets associated with your project yet
- </p>
- </Table.td>
- </Table.tr>
- )
- }
- />
- </div>
- </>
- )}
- </div>
+ <div className="w-full overflow-hidden overflow-x-auto">
+ <Table
+ head={[
+ <Table.th key="secret-name">Name</Table.th>,
+ <Table.th key="secret-value" className="flex items-center gap-x-2">
+ Digest{' '}
+ <Badge color="scale" className="font-mono">
+ SHA256
+ </Badge>
+ </Table.th>,
+ <Table.th key="secret-updated-at">Updated at</Table.th>,
+ <Table.th key="actions" />,
+ ]}
+ body={
+ secrets.length > 0 ? (
+ secrets.map((secret) => (
+ <EdgeFunctionSecret
+ key={secret.name}
+ secret={secret}
+ onSelectDelete={() => setSelectedSecret(secret)}
+ />
+ ))
+ ) : secrets.length === 0 && searchString.length > 0 ? (
+ <Table.tr>
+ <Table.td colSpan={3}>
+ <p className="text-sm text-foreground">No results found</p>
+ <p className="text-sm text-foreground-light">
+ Your search for "{searchString}" did not return any results
+ </p>
+ </Table.td>
+ </Table.tr>
+ ) : (
+ <Table.tr>
+ <Table.td colSpan={3}>
+ <p className="text-sm text-foreground">No secrets created</p>
+ <p className="text-sm text-foreground-light">
+ There are no secrets associated with your project yet
+ </p>
+ </Table.td>
+ </Table.tr>
+ )
+ }
+ />
+ </div>
+ </div>
+ ) : null}
</>
)}
diff --git a/apps/studio/data/lint/create-lint-rule-mutation.ts b/apps/studio/data/lint/create-lint-rule-mutation.ts
index b4672962141..cc5cd20d04e 100644
--- a/apps/studio/data/lint/create-lint-rule-mutation.ts
+++ b/apps/studio/data/lint/create-lint-rule-mutation.ts
@@ -6,7 +6,8 @@ import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
import { lintKeys } from './keys'
-type ExceptionPayload = components['schemas']['CreateNotificationExceptionsDto']['exceptions'][0]
+type ExceptionPayload =
+ components['schemas']['CreateNotificationExceptionsBodyDto']['exceptions'][0]
export type LintRuleCreateVariables = {
projectRef: string
diff --git a/apps/studio/data/lint/lint-rules-query.ts b/apps/studio/data/lint/lint-rules-query.ts
index 0cd9295bc6b..f4d4a7d4a8b 100644
--- a/apps/studio/data/lint/lint-rules-query.ts
+++ b/apps/studio/data/lint/lint-rules-query.ts
@@ -13,11 +13,6 @@ type ProjectLintRulesVariables = {
type LintDismissalResponse = components['schemas']['ListNotificationExceptionsResponseDto']
export type LintException = LintDismissalResponse['exceptions'][0]
-export type LintCategory =
- components['schemas']['CreateNotificationExceptionsDto']['exceptions'][0]['lint_category']
-export type LintName =
- components['schemas']['CreateNotificationExceptionsDto']['exceptions'][0]['lint_name']
-
export async function getProjectLintRules(
{ projectRef }: ProjectLintRulesVariables,
signal?: AbortSignal