@@ -19,6 +19,7 @@ import { Button } from '@/ui/primitives/button'
1919import {
2020 Dialog ,
2121 DialogContent ,
22+ DialogDescription ,
2223 DialogFooter ,
2324 DialogHeader ,
2425 DialogTitle ,
@@ -52,8 +53,6 @@ export const EditSecretDialog = ({
5253 const queryClient = useQueryClient ( )
5354 const [ open , setOpen ] = useState ( false )
5455
55- const webhookName = webhook . name
56-
5756 const listQueryKey = trpc . webhooks . list . queryOptions ( {
5857 teamSlug : team . slug ,
5958 } ) . queryKey
@@ -70,13 +69,13 @@ export const EditSecretDialog = ({
7069 const updateSecretMutation = useMutation (
7170 trpc . webhooks . updateSecret . mutationOptions ( {
7271 onSuccess : ( ) => {
73- toast ( defaultSuccessToast ( 'Webhook secret rotated successfully' ) )
72+ toast ( defaultSuccessToast ( 'Webhook secret edited successfully' ) )
7473 void queryClient . invalidateQueries ( { queryKey : listQueryKey } )
7574 handleDialogChange ( false )
7675 } ,
7776 onError : ( err ) => {
7877 toast (
79- defaultErrorToast ( err . message || 'Failed to rotate webhook secret' )
78+ defaultErrorToast ( err . message || 'Failed to edit webhook secret' )
8079 )
8180 } ,
8281 } )
@@ -86,9 +85,7 @@ export const EditSecretDialog = ({
8685
8786 const handleDialogChange = ( value : boolean ) => {
8887 setOpen ( value )
89-
9088 if ( value ) return
91-
9289 form . reset ( )
9390 updateSecretMutation . reset ( )
9491 }
@@ -109,85 +106,69 @@ export const EditSecretDialog = ({
109106 return (
110107 < Dialog open = { open } onOpenChange = { handleDialogChange } >
111108 < DialogTrigger asChild > { trigger } </ DialogTrigger >
112-
113109 < DialogContent >
114- < DialogHeader >
115- < DialogTitle >
116- Rotate Secret for { webhookName ? `"${ webhookName } "` : 'Webhook' }
117- </ DialogTitle >
118- < div className = "flex flex-col gap-3 pt-2" >
119- < p className = "text-fg-tertiary prose-body" >
120- < strong className = "text-fg-secondary" > Important:</ strong > E2B
121- sends only one signature secret at a time. Once you change it, the
122- old secret immediately stops working.
123- </ p >
124- < div className = "flex flex-col gap-2" >
125- < p className = "text-fg-secondary prose-body font-medium" >
126- To rotate safely without downtime:
127- </ p >
128- < ol className = "text-fg-tertiary prose-body list-decimal list-inside space-y-1 pl-1" >
129- < li > Generate a new custom secret</ li >
130- < li >
131- Update your endpoint to accept{ ' ' }
132- < strong className = "text-fg" > both</ strong > current and new
133- custom secrets
134- </ li >
135- < li > Deploy your changes</ li >
136- < li >
137- Then roll confirm your new custom secret here — E2B will start
138- using the new secret
139- </ li >
140- < li > Remove old secret validation from your code later</ li >
141- </ ol >
142- </ div >
143- </ div >
110+ < DialogHeader className = "gap-2" >
111+ < DialogTitle > Edit '{ webhook . name } ' secret</ DialogTitle >
112+ < DialogDescription className = "text-fg-tertiary" >
113+ Replacing the secret will deactivate the current one. Make sure to
114+ update any systems using it.
115+ </ DialogDescription >
144116 </ DialogHeader >
145117
146118 < Form { ...form } >
147- < form onSubmit = { handleSubmit } className = "min-w-0" >
119+ < form onSubmit = { handleSubmit } className = "flex flex-col gap-4 min-w-0" >
148120 < input type = "hidden" { ...form . register ( 'webhookId' ) } />
149121
150- < div className = "flex flex-col gap-4 pb-6 min-w-0" >
151- < FormField
152- control = { form . control }
153- name = "signatureSecret"
154- render = { ( { field } ) => (
155- < FormItem className = "min-w-0" >
156- < FormControl >
157- < Input
158- placeholder = "Enter new secret"
159- disabled = { isLoading }
160- className = "min-w-0"
161- autoComplete = "off"
162- { ...field }
163- />
164- </ FormControl >
122+ < FormField
123+ control = { form . control }
124+ name = "signatureSecret"
125+ render = { ( { field } ) => (
126+ < FormItem className = "min-w-0 gap-2" >
127+ < FormControl >
128+ < Input
129+ disabled = { isLoading }
130+ className = "min-w-0"
131+ autoComplete = "off"
132+ autoFocus
133+ clearable
134+ onClear = { ( ) =>
135+ form . setValue ( 'signatureSecret' , '' , {
136+ shouldValidate : true ,
137+ shouldDirty : true ,
138+ } )
139+ }
140+ { ...field }
141+ />
142+ </ FormControl >
143+ { errors . signatureSecret ? (
144+ < FormMessage />
145+ ) : (
165146 < p className = "text-fg-tertiary prose-body" >
166147 { '> 32 characters' }
167148 </ p >
168- < FormMessage />
169- </ FormItem >
170- ) }
171- />
172- </ div >
149+ ) }
150+ </ FormItem >
151+ ) }
152+ />
173153
174154 < DialogFooter >
175- { isLoading ? (
176- < div className = "flex items-center justify-center py-2 gap-2 w-full" >
177- < Loader variant = "slash" size = "sm" />
178- < span > Rotating Secret...</ span >
179- </ div >
180- ) : (
181- < Button
182- type = "submit"
183- disabled = { ! isSecretValid }
184- className = "w-full"
185- variant = "secondary"
186- >
187- < CheckIcon className = "size-4" />
188- Confirm
189- </ Button >
190- ) }
155+ < Button
156+ type = "submit"
157+ disabled = { ! isSecretValid || isLoading }
158+ className = "w-full"
159+ >
160+ { isLoading ? (
161+ < >
162+ < Loader variant = "slash" size = "sm" />
163+ < span > Updating secret...</ span >
164+ </ >
165+ ) : (
166+ < >
167+ < CheckIcon className = "size-4" />
168+ Confirm
169+ </ >
170+ ) }
171+ </ Button >
191172 </ DialogFooter >
192173 </ form >
193174 </ Form >
0 commit comments