Skip to content

Commit d6af1ae

Browse files
committed
refactor: improve EditSecretDialog and UpsertWebhookDialog for better user feedback
- Updated EditSecretDialog to enhance the user experience with clearer messaging for secret editing actions. - Modified UpsertWebhookDialog to provide consistent success and error messages when editing webhooks. - Adjusted the layout and descriptions in both dialogs for improved clarity and usability. These changes aim to streamline the webhook management process and enhance user interaction with the dialogs.
1 parent 9494a15 commit d6af1ae

3 files changed

Lines changed: 58 additions & 77 deletions

File tree

src/features/dashboard/settings/webhooks/edit-secret-dialog.tsx

Lines changed: 55 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { Button } from '@/ui/primitives/button'
1919
import {
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>

src/features/dashboard/settings/webhooks/table.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const WebhooksTable = ({
2828
const hasNoWebhooks = totalWebhookCount === 0
2929
const emptyMessage = hasNoWebhooks
3030
? 'No webhooks added yet'
31-
: 'No webhooks match your search.'
31+
: 'No webhooks match your search'
3232

3333
return (
3434
<Table className={cn('w-full table-fixed', className)}>

src/features/dashboard/settings/webhooks/upsert-webhook-dialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export function UpsertWebhookDialog({
9696
toast(
9797
defaultSuccessToast(
9898
isUpdateMode
99-
? 'Webhook updated successfully'
99+
? 'Webhook edited successfully'
100100
: 'Webhook created successfully'
101101
)
102102
)
@@ -114,7 +114,7 @@ export function UpsertWebhookDialog({
114114
defaultErrorToast(
115115
err.message ||
116116
(isUpdateMode
117-
? 'Failed to update webhook'
117+
? 'Failed to edit webhook'
118118
: 'Failed to create webhook')
119119
)
120120
)

0 commit comments

Comments
 (0)