Files
supabase/apps/studio/routes/project/$ref/functions/secrets.tsx
Joshen Lim 434c00cb14 Joshenlim/fe 5196 move off scaffold components for remaining (#53911)
## Context

Final clean up of deprecated Scaffold components, just touches
- Account audit logs
- Project home page
- Database -> Column privileges
- Storage -> Analytics bucket details
- Storage -> Vector bucket details
- Settings -> Infrastructure -> Disk management
- Settings -> Infrastructure -> Read replica details
- Integrations -> Wrappers overview (Only for non supported integration
UI)
- Edge functions -> Empty state
- Auth -> Performance

Also replaces usage of `ScaffoldDivider` with just the `Separator`
component
And also adjusts the page container sizes of database pages from large
to default - these only have visual differences on viewport widths
larger than a laptop

Testing just needs a quick sweep of all these surfaces to make sure
nothing looks weird - will do so on my end too once the builds go
through!

For @supabase/security's review - review requirement was triggered as
`Documents.tsx` was updated in the organization settings page. But it
was just to change the Divider component 🙏
2026-11-26 21:28:17 +07:00

120 lines
4.2 KiB
TypeScript

import { createFileRoute } from '@tanstack/react-router'
import type { PropsWithChildren } from 'react'
import { Admonition } from 'ui-patterns/Admonition'
import { PageContainer } from 'ui-patterns/PageContainer'
import {
PageHeader,
PageHeaderDescription,
PageHeaderMeta,
PageHeaderSummary,
PageHeaderTitle,
} from 'ui-patterns/PageHeader'
import { PageSection, PageSectionContent } from 'ui-patterns/PageSection'
import { DefaultEdgeFunctionSecrets } from '@/components/interfaces/Functions/EdgeFunctionSecrets/DefaultEdgeFunctionSecrets'
import { DEFAULT_EDGE_FUNCTION_SECRETS } from '@/components/interfaces/Functions/EdgeFunctionSecrets/DefaultEdgeFunctionSecrets.utils'
import { EdgeFunctionSecrets } from '@/components/interfaces/Functions/EdgeFunctionSecrets/EdgeFunctionSecrets'
import { DocsButton } from '@/components/ui/DocsButton'
import { useDeploymentMode } from '@/hooks/misc/useDeploymentMode'
import { DOCS_URL, IS_PLATFORM } from '@/lib/constants'
export const Route = createFileRoute('/project/$ref/functions/secrets')({
component: FunctionsSecretsRoute,
staticData: {
functionsLayoutTitle: 'Secrets',
},
})
function FunctionsSecretsRoute() {
return (
<SecretsPageWrapper>
<SecretsPage />
</SecretsPageWrapper>
)
}
function SecretsPage() {
const { isCli, isSelfHosted } = useDeploymentMode()
if (!IS_PLATFORM) {
return (
<PageContainer size="default">
<PageSection>
<PageSectionContent className="space-y-4 md:space-y-8">
{isCli && (
<Admonition
type="default"
title="Local development with the Supabase CLI"
description={
<p>
Add custom secrets to <code>supabase/functions/.env</code>, or pass{' '}
<code>--env-file</code> to <code>supabase functions serve</code>.
</p>
}
actions={<DocsButton href={`${DOCS_URL}/guides/functions/secrets#using-the-cli`} />}
/>
)}
{isSelfHosted && (
<Admonition
type="default"
title="Self-hosted Supabase"
description={<p>Set custom secrets via environment variables.</p>}
actions={
<DocsButton
href={`${DOCS_URL}/guides/self-hosting/self-hosted-functions#custom-environment-variables`}
/>
}
/>
)}
<section className="space-y-4">
<div className="flex flex-col md:flex-row md:items-center justify-between gap-2">
<div className="space-y-1">
<h3 className="text-foreground text-base">Default secrets</h3>
<p className="text-sm text-foreground-light">
Reserved secrets available in every project
</p>
</div>
<DocsButton
href={
isSelfHosted
? `${DOCS_URL}/guides/self-hosting/self-hosted-functions#calling-supabase-services-from-functions`
: `${DOCS_URL}/guides/functions/secrets#default-secrets`
}
/>
</div>
<DefaultEdgeFunctionSecrets
secrets={DEFAULT_EDGE_FUNCTION_SECRETS.filter((secret) => !secret.isRuntime)}
/>
</section>
</PageSectionContent>
</PageSection>
</PageContainer>
)
}
return (
<PageContainer size="default">
<PageSection>
<PageSectionContent className="space-y-4 md:space-y-8">
<EdgeFunctionSecrets />
</PageSectionContent>
</PageSection>
</PageContainer>
)
}
const SecretsPageWrapper = ({ children }: PropsWithChildren) => (
<div className="w-full min-h-full flex flex-col items-stretch">
<PageHeader size="default">
<PageHeaderMeta>
<PageHeaderSummary>
<PageHeaderTitle>Edge Function Secrets</PageHeaderTitle>
<PageHeaderDescription>Manage encrypted values for your functions</PageHeaderDescription>
</PageHeaderSummary>
</PageHeaderMeta>
</PageHeader>
{children}
</div>
)