11'use client'
22
33import { useState } from 'react'
4+ import Link from 'next/link'
45import styles from '@/platform/app/(shell)/_components/chat/cards/cards.module.css'
56import type {
67 CredentialCardProps ,
78 UsageNoticeProps ,
89} from '@/platform/app/(shell)/_components/chat/message/message-segments'
910import type { PlatformCredentialRequest } from '@/platform/app/(shell)/_components/chat/model'
10- import { Button , InlineNotice } from '@/platform/design-system/components'
11- import { Input } from '@/platform/design-system/components/field/inputs '
11+ import { Button , InlineNotice , SecretField } from '@/platform/design-system/components'
12+ import { ControlRow } from '@/platform/design-system/components/button/control-row '
1213import {
1314 CredentialWorkspaceProvider ,
1415 useCredentialWorkspace ,
@@ -31,31 +32,35 @@ interface RowProps {
3132 onConnected : ( ) => void
3233}
3334
34- function LinkRow ( { item, controlId, onConnected } : RowProps ) {
35+ function LinkRow ( { item, url , controlId, onConnected } : RowProps & { url : string } ) {
3536 const name = serviceName ( item )
3637 const connection = useOAuthChipConnection ( {
37- connectUrl : item . value ?? '' ,
38+ connectUrl : url ,
3839 provider : item . provider ?? '' ,
3940 displayName : name ,
4041 controlId,
4142 onConnected,
4243 } )
4344 if ( connection . connected ) return < p data-type = 'T048' > Connected { name } </ p >
4445 return (
45- < a
46- className = { styles . link }
47- data-type = 'T048'
48- href = { item . value }
49- target = '_blank'
50- rel = 'noopener noreferrer'
51- onClick = { connection . onConnectClick }
52- >
53- { connection . status === 'pending'
54- ? `Waiting for ${ name } connection`
55- : connection . reconnectCredentialId
56- ? `Reconnect ${ name } `
57- : `Connect ${ name } ` }
58- </ a >
46+ < ControlRow
47+ render = {
48+ < Link
49+ href = { url }
50+ target = '_blank'
51+ rel = 'noopener noreferrer'
52+ onClick = { connection . onConnectClick }
53+ />
54+ }
55+ label = {
56+ connection . status === 'pending'
57+ ? `Waiting for ${ name } connection`
58+ : connection . reconnectCredentialId
59+ ? `Reconnect ${ name } `
60+ : `Connect ${ name } `
61+ }
62+ trailingIcon = 'I030'
63+ />
5964 )
6065}
6166
@@ -200,10 +205,11 @@ export function LiveCredentialCard({
200205 controlId = { controlId }
201206 onConnected = { markConnected }
202207 />
203- ) : canEdit ? (
208+ ) : canEdit && item . safeUrl ? (
204209 < LinkRow
205210 key = { controlId }
206211 item = { item }
212+ url = { item . safeUrl }
207213 controlId = { controlId }
208214 onConnected = { markConnected }
209215 />
@@ -216,35 +222,30 @@ export function LiveCredentialCard({
216222 { item . name } added
217223 </ p >
218224 ) : (
219- < Input
225+ < SecretField
220226 key = { controlId }
221227 label = { item . name ?? 'Secret' }
222228 placeholder = { item . name }
223- type = 'password'
224229 value = { drafts [ index ] ?? '' }
225230 onChange = { ( value ) => setDrafts ( ( current ) => ( { ...current , [ index ] : value } ) ) }
226231 />
227232 )
228233 case 'service_account' :
229234 return canEdit ? (
230- < a
235+ < ControlRow
231236 key = { controlId }
232- className = { styles . link }
233- data-type = 'T048'
234- href = { integrationsHref }
235- target = '_blank'
236- rel = 'noopener noreferrer'
237- >
238- Connect { serviceName ( item ) } in Integrations
239- </ a >
237+ render = {
238+ < Link href = { integrationsHref } target = '_blank' rel = 'noopener noreferrer' />
239+ }
240+ label = { `Connect ${ serviceName ( item ) } in Integrations` }
241+ trailingIcon = 'I030'
242+ />
240243 ) : null
241244 case 'folder_access' :
242245 return < FolderRow key = { controlId } item = { item } />
243246 case 'sim_key' :
244247 return item . value ? (
245- < code key = { controlId } data-type = 'T009' >
246- { item . value }
247- </ code >
248+ < SecretField key = { controlId } label = 'Sim key' value = { item . value } readOnly copyable />
248249 ) : null
249250 default :
250251 return null
@@ -284,9 +285,11 @@ export function LiveUsageNotice({ action, reason, message }: UsageNoticeProps) {
284285 }
285286 action = {
286287 canManage ? (
287- < a className = { styles . link } data-type = 'T048' href = { href } >
288- { upgrade ? 'Upgrade Plan' : 'Increase Limit' }
289- </ a >
288+ < ControlRow
289+ render = { < Link href = { href } /> }
290+ label = { upgrade ? 'Upgrade Plan' : 'Increase Limit' }
291+ trailingIcon = 'I030'
292+ />
290293 ) : undefined
291294 }
292295 />
0 commit comments