feat: per-row copy button and sample code block on API Keys page - #84
Open
gdccyuen wants to merge 1 commit into
Open
feat: per-row copy button and sample code block on API Keys page#84gdccyuen wants to merge 1 commit into
gdccyuen wants to merge 1 commit into
Conversation
- Keep the one-time reveal popup as the only source of the full key - Add a Copy button next to each masked API key row (copies key_prefix) - Add a sample-code block below the API keys table with tabs (cURL/Python/Node.js/Go) using a YOUR_API_KEY placeholder - Extract buildCodeByTab into shared lib/sample-code.ts; Usage welcome modal now imports it (no behavior change) - i18n (en/zh): copyKeyPrefix/codeTitle/codeTabs/copyCode* keys
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Improves the API Keys page UX:
key_prefix, so a full-key row copy is impossible by design)key_prefixfor quick reference/identification)Changes
Shared sample-code util
lib/sample-code.ts:buildCodeByTab,sampleCodeTabConfig,SAMPLE_PDF_URL,SampleCodeTabtype — extracted verbatim from the Usage welcome modalapp/(dashboard)/usage/_components/usage-welcome-modal.tsx: now imports fromlib/sample-code.ts(no behavior change)API Keys page
app/(dashboard)/api-keys/_components/api-key-sample-code.tsx: tabbed code panel (Python/Node.js/cURL/Go) with syntax highlighting + per-tab Copy button; uses aYOUR_API_KEYplaceholder since the page doesn't hold a plaintext key persistentlyapp/(dashboard)/api-keys/_components/api-keys-page.tsx: renders the sample-code block below the keys tableapp/(dashboard)/api-keys/_components/api-keys-table.tsx: per-row copy button next to the masked key (reusescopyToClipboard+DashboardCopyIcon+ toast)i18n (en/zh)
ApiKeysnamespace:copyKeyPrefix,codeTitle,codeTabs,copyCode,copyCodeSuccess,copyCodeFailedNotes
api-key-created-dialog.tsx) is untouched — it remains the only place the full key is ever shown, matching the upstream security model (keys are stored as SHA-256 hashes, full key is unrecoverable after creation)pnpm type-check,pnpm test(108 passed),pnpm build