From 15f92a6996cfdac2a279a876c629367d32cd57bf Mon Sep 17 00:00:00 2001 From: Stan Wohlwend Date: Mon, 4 Mar 2024 15:07:53 +0100 Subject: [PATCH] Improve EnvKeys component --- .../[projectId]/onboarding-dialog.tsx | 2 +- .../settings/api-keys/page-client.tsx | 4 +- .../stack-server/src/components/env-keys.tsx | 92 +++++++++++++++---- 3 files changed, 80 insertions(+), 18 deletions(-) diff --git a/packages/stack-server/src/app/(main)/(protected)/projects/[projectId]/onboarding-dialog.tsx b/packages/stack-server/src/app/(main)/(protected)/projects/[projectId]/onboarding-dialog.tsx index b10fc12a4..74f846dea 100644 --- a/packages/stack-server/src/app/(main)/(protected)/projects/[projectId]/onboarding-dialog.tsx +++ b/packages/stack-server/src/app/(main)/(protected)/projects/[projectId]/onboarding-dialog.tsx @@ -65,7 +65,7 @@ export function OnboardingDialog() { {/* TODO: Add document link */} - Congratulations on creating your new project! We have automatically created an API key for you. Please copy it to your .env.local file; please see the Getting Started guide. + Congratulations on creating your new project! We have automatically created an API key for you. Please copy it to your .env.local file; please see the Getting Started guide. diff --git a/packages/stack-server/src/app/(main)/(protected)/projects/[projectId]/settings/api-keys/page-client.tsx b/packages/stack-server/src/app/(main)/(protected)/projects/[projectId]/settings/api-keys/page-client.tsx index b7140abc7..67eb14985 100644 --- a/packages/stack-server/src/app/(main)/(protected)/projects/[projectId]/settings/api-keys/page-client.tsx +++ b/packages/stack-server/src/app/(main)/(protected)/projects/[projectId]/settings/api-keys/page-client.tsx @@ -13,6 +13,8 @@ import { useAdminApp } from "../../useAdminInterface"; import { runAsynchronously } from "@stackframe/stack-shared/src/utils/promises"; import EnvKeys from "@/components/env-keys"; import Link from "next/link"; +import { SmartLink } from "@/components/smart-link"; +import { throwErr } from "@stackframe/stack-shared/dist/utils/errors"; export default function ApiKeysDashboardClient() { @@ -101,7 +103,7 @@ function CreateNewDialog(props: { open: boolean, onClose(): void, onInvalidate() - Success! Your new API keys have been created. Note that you will not be able to view this again and you will need to create a new one if you lose it. Detailed setup instructions can be found here + Success! Your new API keys have been created. Note that you will not be able to view this again and you will need to create a new one if you lose it. Visit the documentation for detailed setup instructions. - - NEXT_PUBLIC_STACK_PROJECT_ID={props.projectId} - - {props.publishableClientKey && - NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY={props.publishableClientKey} - } - {props.secretServerKey && - STACK_SECRET_SERVER_KEY={props.secretServerKey} - } - {props.superSecretAdminKey && - STACK_SUPER_SECRET_ADMIN_KEY={props.superSecretAdminKey} - } - + + + API Keys + Next.js + + + + {props.publishableClientKey && ( + + )} + {props.secretServerKey && ( + + )} + {props.superSecretAdminKey && ( + This key is for administrative use only. Anyone owning this key will be able to create unlimited new keys and revoke any other keys. Be careful!} + /> + )} + + + + v).map(([k, v]) => `${k}=${v}`).join("\n")} + label="Environment variables" + helper={<>Copy these variables into your .env.local file.} + /> + + ); -} \ No newline at end of file +} + + +function CopyField(props: { value: string, label?: React.ReactNode, helper?: React.ReactNode }) { + return ( + + {props.label && ( + + {props.label} + + )} + +