Skip to content

Commit af5bfc8

Browse files
improvement(emcn): promote ApiKeyReveal to SecretReveal in emcn
1 parent a996b75 commit af5bfc8

6 files changed

Lines changed: 37 additions & 11 deletions

File tree

apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/special-tags/special-tags.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22

33
import { createElement, useMemo, useState } from 'react'
44
import { useParams } from 'next/navigation'
5-
import { ArrowRight, ChevronDown, Expandable, ExpandableContent } from '@/components/emcn'
6-
import { ApiKeyReveal } from '@/components/ui'
5+
import {
6+
ArrowRight,
7+
ChevronDown,
8+
Expandable,
9+
ExpandableContent,
10+
SecretReveal,
11+
} from '@/components/emcn'
712
import { cn } from '@/lib/core/utils/cn'
813
import { OAUTH_PROVIDERS } from '@/lib/oauth/oauth'
914
import { ContextMentionIcon } from '@/app/workspace/[workspaceId]/home/components/context-mention-icon'
@@ -620,7 +625,7 @@ function CredentialDisplay({ data }: { data: CredentialTagData }) {
620625
}
621626

622627
if (data.type === 'sim_key') {
623-
return <ApiKeyReveal value={data.value} redacted={data.redacted || !data.value} />
628+
return <SecretReveal value={data.value} redacted={data.redacted || !data.value} />
624629
}
625630

626631
return null

apps/sim/app/workspace/[workspaceId]/settings/components/api-keys/components/create-api-key-modal/create-api-key-modal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import {
1212
ModalContent,
1313
ModalFooter,
1414
ModalHeader,
15+
SecretReveal,
1516
} from '@/components/emcn'
16-
import { ApiKeyReveal } from '@/components/ui'
1717
import { type ApiKey, useCreateApiKey } from '@/hooks/queries/api-keys'
1818

1919
const logger = createLogger('CreateApiKeyModal')
@@ -214,7 +214,7 @@ export function CreateApiKeyModal({
214214
</span>
215215
</p>
216216

217-
{newKey && <ApiKeyReveal value={newKey.key} className='mt-2.5' />}
217+
{newKey && <SecretReveal value={newKey.key} className='mt-2.5' />}
218218
</ModalBody>
219219
</ModalContent>
220220
</Modal>

apps/sim/app/workspace/[workspaceId]/settings/components/copilot/copilot.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import {
1313
ModalContent,
1414
ModalFooter,
1515
ModalHeader,
16+
SecretReveal,
1617
// Switch,
1718
} from '@/components/emcn'
18-
import { ApiKeyReveal, Input } from '@/components/ui'
19+
import { Input } from '@/components/ui'
1920
// import { useMcpServers, useUpdateMcpServer } from '@/hooks/queries/mcp'
2021
import { CopilotKeySkeleton } from '@/app/workspace/[workspaceId]/settings/components/copilot/copilot-skeleton'
2122
import {
@@ -322,7 +323,7 @@ export function Copilot() {
322323
</span>
323324
</p>
324325

325-
{newKey && <ApiKeyReveal value={newKey} className='mt-2.5' />}
326+
{newKey && <SecretReveal value={newKey} className='mt-2.5' />}
326327
</ModalBody>
327328
</ModalContent>
328329
</Modal>

apps/sim/components/emcn/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export {
126126
SModalTrigger,
127127
} from './s-modal/s-modal'
128128
export { SecretInput, type SecretInputProps } from './secret-input/secret-input'
129+
export { SecretReveal, type SecretRevealProps } from './secret-reveal/secret-reveal'
129130
export { Skeleton } from './skeleton/skeleton'
130131
export { Slider, type SliderProps } from './slider/slider'
131132
export { Switch } from './switch/switch'

apps/sim/components/ui/api-key-reveal.tsx renamed to apps/sim/components/emcn/components/secret-reveal/secret-reveal.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/**
2+
* A read-only display for a one-time secret reveal: the value renders inside
3+
* a bordered code box with a copy button, or as masked dots when redacted.
4+
*
5+
* @remarks
6+
* Use for surfaces that show a freshly-generated credential (API key, signing
7+
* secret, etc.) once and then need to fall back to a redacted state on
8+
* subsequent renders. Pair with `redacted` (or simply omit `value`) to render
9+
* the masked state without a copy affordance.
10+
*
11+
* @example
12+
* ```tsx
13+
* import { SecretReveal } from '@/components/emcn'
14+
*
15+
* <SecretReveal value={apiKey} />
16+
* <SecretReveal redacted />
17+
* ```
18+
*/
119
'use client'
220

321
import { Button, Check, Copy } from '@/components/emcn'
@@ -6,13 +24,15 @@ import { useCopyToClipboard } from '@/hooks/use-copy-to-clipboard'
624

725
const REDACTED_DOTS = '••••••••••••••••••••••••••••••••'
826

9-
interface ApiKeyRevealProps {
27+
export interface SecretRevealProps {
28+
/** Secret value to display. When absent or `redacted` is true, renders masked dots. */
1029
value?: string
11-
className?: string
30+
/** Force the masked state even when `value` is provided. */
1231
redacted?: boolean
32+
className?: string
1333
}
1434

15-
export function ApiKeyReveal({ value, className, redacted = false }: ApiKeyRevealProps) {
35+
export function SecretReveal({ value, className, redacted = false }: SecretRevealProps) {
1636
const { copied, copy } = useCopyToClipboard()
1737
const isHidden = redacted || !value
1838

apps/sim/components/ui/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export { ApiKeyReveal } from './api-key-reveal'
21
export { Button, buttonVariants } from './button'
32
export { Input } from './input'
43
export { Label } from './label'

0 commit comments

Comments
 (0)