Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Translate settings nav bar
Damian Legawiec8648805ed8b9
diff --git a/packages/dashboard-core/src/components/settings-sidebar.tsx b/packages/dashboard-core/src/components/settings-sidebar.tsxindex 6e9bcb51f8..0446378f2c 100644--- a/packages/dashboard-core/src/components/settings-sidebar.tsx+++ b/packages/dashboard-core/src/components/settings-sidebar.tsx@@ -64,7 +64,9 @@ export function SettingsSidebar({ open }: { open: boolean }) {>{visible.groups.map(({ group, entries }) => (<SidebarGroup key={group.key}>- <SidebarGroupLabel>{group.label}</SidebarGroupLabel>+ <SidebarGroupLabel>+ {group.labelKey ? t(group.labelKey) : group.label}+ </SidebarGroupLabel><SidebarMenu>{entries.map((entry) => (<SettingsItem@@ -93,11 +95,13 @@ function SettingsItem({storeId: stringtabIndex: number}) {+ const { t } = useTranslation()const routerState = useRouterState()const currentPath = routerState.location.pathnameconst url = `/${storeId}/settings${entry.path}`const isActive = currentPath === url || currentPath.startsWith(`${url}/`)const Icon = entry.icon ?? PackageIcon+ const label = entry.labelKey ? t(entry.labelKey) : entry.labelreturn (<SidebarMenuItem>@@ -106,7 +110,7 @@ function SettingsItem({<SidebarMenuButton asChild isActive={isActive}><Link to={url} tabIndex={tabIndex}><NavIcon icon={Icon} isActive={isActive} />- <span>{entry.label}</span>+ <span>{label}</span>{entry.comingSoon && (<Badge className="ml-auto h-5 bg-sidebar-accent px-1.5 py-0 text-[10px] font-normal text-sidebar-foreground/70">Soondiff --git a/packages/dashboard-core/src/lib/settings-nav-registry.ts b/packages/dashboard-core/src/lib/settings-nav-registry.tsindex e798bef6aa..b9a6c93998 100644--- a/packages/dashboard-core/src/lib/settings-nav-registry.ts+++ b/packages/dashboard-core/src/lib/settings-nav-registry.ts@@ -14,8 +14,14 @@ import type { SubjectName } from './permissions'export interface SettingsNavEntry {/** Stable identifier — used for register/remove/update and as the React key. */key: string- /** Visible label. */- label: string+ /**+ * Visible label. Either `label` (literal) or `labelKey` (i18n key) must be+ * set; built-in entries use `labelKey` so the sidebar re-renders on+ * language change. Plugins can use either.+ */+ label?: string+ /** i18n key passed to `t(...)` at render time. Takes precedence over `label`. */+ labelKey?: string/*** Path template, prefixed with `/$storeId/settings` at render time. Pass paths* like `'/general'` or `'/staff'`, NOT `/store_abc/settings/general`. The@@ -37,8 +43,10 @@ export interface SettingsNavEntry {export interface SettingsNavGroup {/** Group identifier referenced by entries. */key: string- /** Visible header label. */- label: string+ /** Visible header label. Mirrors `SettingsNavEntry.label` — pair with `labelKey` when localising. */+ label?: string+ /** i18n key passed to `t(...)` at render time. Takes precedence over `label`. */+ labelKey?: string/** Group ordering. Lower numbers render first. Defaults to 100. */position?: number}@@ -73,6 +81,9 @@ function notify() {export const settingsNav: SettingsNavMutator = {add(entry) {+ if (!entry.label && !entry.labelKey) {+ throw new Error(`Settings nav entry "${entry.key}" must define either "label" or "labelKey".`)+ }if (entries.some((e) => e.key === entry.key)) {throw new Error(`Settings nav entry "${entry.key}" already registered.`)}@@ -89,9 +100,16 @@ export const settingsNav: SettingsNavMutator = {const e = entries.find((x) => x.key === key)if (!e) throw new Error(`Settings nav entry "${key}" not found.`)Object.assign(e, patch)+ // Re-validate the merged entry — the patch could remove both label fields.+ if (!e.label && !e.labelKey) {+ throw new Error(`Settings nav entry "${e.key}" must define either "label" or "labelKey".`)+ }notify()},addGroup(group) {+ if (!group.label && !group.labelKey) {+ throw new Error(`Settings nav group "${group.key}" must define either "label" or "labelKey".`)+ }if (groups.some((g) => g.key === group.key)) {throw new Error(`Settings nav group "${group.key}" already registered.`)}diff --git a/packages/dashboard/e2e/store-settings.spec.ts b/packages/dashboard/e2e/store-settings.spec.tsindex 4342ee8520..2d02ca2bc5 100644--- a/packages/dashboard/e2e/store-settings.spec.ts+++ b/packages/dashboard/e2e/store-settings.spec.ts@@ -53,19 +53,31 @@ test.describe('store settings — emails', () => {timeout: 15_000,})+ // The logo card always shows an upload CTA — use that as a proxy for the+ // card's presence. The CardTitle is rendered as a `<div>` so `role=heading`+ // doesn't apply, and matching plain text would collide with other strings.+ const uploadCta = page.getByRole('button', { name: /upload logo/i })++ // Base UI's <Switch> renders a hidden <input> + a visible <button+ // role="switch">. The id is on the hidden input, so we drive interaction+ // via the visible role-switch (matched by its accessible label).+ const consumerEmailsToggle = page.getByRole('switch', {+ name: /send transactional emails to customers/i,+ })+// Cards visible by default (consumer emails are enabled on a fresh store).await expect(page.locator('#store-mail-from-address')).toBeVisible()- await expect(page.getByRole('heading', { name: /^logo$/i })).toBeVisible()+ await expect(uploadCta).toBeVisible()// Toggle off → address + logo cards disappear.- await page.locator('#store-send-consumer-emails').click()+ await consumerEmailsToggle.click()await expect(page.locator('#store-mail-from-address')).toHaveCount(0)- await expect(page.getByRole('heading', { name: /^logo$/i })).toHaveCount(0)+ await expect(uploadCta).toHaveCount(0)// Toggle back on → cards return without losing the seed value.- await page.locator('#store-send-consumer-emails').click()+ await consumerEmailsToggle.click()await expect(page.locator('#store-mail-from-address')).toBeVisible()- await expect(page.getByRole('heading', { name: /^logo$/i })).toBeVisible()+ await expect(uploadCta).toBeVisible()})test('saves sender + support + notifications addresses and reloads them', async ({ page }) => {@@ -97,15 +109,20 @@ test.describe('store settings — emails', () => {test('flags an invalid mail_from_address inline', async ({ page }) => {const creds = await login(page)await page.goto(EMAILS_PATH(creds.store_id))- await expect(page.locator('#store-mail-from-address')).toBeVisible({ timeout: 15_000 })-- await page.locator('#store-mail-from-address').fill('not-an-email')- await page.getByRole('button', { name: /^save$/i }).click()-- // Zod resolver renders an inline error via the field's aria-invalid + the- // accompanying FieldError component — assert the field reflects invalid- // state. Specific copy varies by zod version, so we anchor on the- // attribute rather than the message string.- await expect(page.locator('#store-mail-from-address')).toHaveAttribute('aria-invalid', 'true')+ const senderField = page.locator('#store-mail-from-address')+ await expect(senderField).toBeVisible({ timeout: 15_000 })++ await senderField.fill('not-an-email')++ // The input is `type="email"`, so the browser's native HTML5 validity+ // check rejects the value before the form ever submits — that's what the+ // user actually sees (the native popup blocks the submit). Asserting on+ // `validity.valid` keeps the test honest about what stops the user from+ // sending bad data, rather than relying on Zod's downstream `aria-invalid`+ // (which never fires because the submit is blocked at the form level).+ await expect(async () => {+ const valid = await senderField.evaluate((el) => (el as HTMLInputElement).validity.valid)+ expect(valid).toBe(false)+ }).toPass({ timeout: 5_000 })})})diff --git a/packages/dashboard/e2e/webhooks.spec.ts b/packages/dashboard/e2e/webhooks.spec.tsindex 4d5d0c9500..e07bb62747 100644--- a/packages/dashboard/e2e/webhooks.spec.ts+++ b/packages/dashboard/e2e/webhooks.spec.ts@@ -14,10 +14,12 @@ async function createEndpoint(await page.locator('#webhook-name').fill(opts.name)await page.locator('#webhook-url').fill(opts.url)- // Each event row renders a `<label htmlFor="webhook-event-<slug>">`. We- // address them via their accessible label, which is the event name itself.+ // Base UI's <Checkbox> renders two elements with the same accessible label+ // (a visible role=checkbox span + a hidden native <input>), so `getByLabel`+ // is ambiguous. Target the role=checkbox span by accessible name instead.+ // The label is the literal event name (e.g. `order.completed`).for (const ev of opts.pickEvents ?? []) {- await page.getByLabel(ev, { exact: true }).check()+ await page.getByRole('checkbox', { name: ev }).click()}// The Sheet footer renders just "Cancel" + "Create". Match the latter.@@ -87,8 +89,11 @@ test.describe('webhooks', () => {await rowButton(page, name).click()await expect(page).toHaveURL(/\/settings\/webhooks\/whe_/, { timeout: 15_000 })await expect(page.getByRole('heading', { name })).toBeVisible({ timeout: 15_000 })- await expect(page.locator('#webhook-name')).toHaveValue(name)- await expect(page.locator('#webhook-url')).toHaveValue(url)+ // The detail page surfaces the URL as a copyable subtitle next to the+ // title and shows the Send test / Edit action buttons in the header.+ await expect(page.getByText(url, { exact: true })).toBeVisible()+ await expect(page.getByRole('button', { name: /send test/i })).toBeVisible()+ await expect(page.getByRole('button', { name: /^edit$/i })).toBeVisible()})test('renames an endpoint on its detail page', async ({ page }) => {@@ -101,17 +106,23 @@ test.describe('webhooks', () => {const url = `https://rename-${suffix}.example.com/hook`await createEndpoint(page, { name: original, url, pickEvents: ['order.completed'] })- // After the secret-reveal Done we're already on the detail page.+ // After the secret-reveal Done we're on the detail page; open the Edit+ // sheet via the header button to access the form fields.await page.getByRole('button', { name: /^done$/i }).click()+ await expect(page.getByRole('heading', { name: original })).toBeVisible({ timeout: 15_000 })+ await page.getByRole('button', { name: /^edit$/i }).click()await expect(page.locator('#webhook-name')).toHaveValue(original, { timeout: 15_000 })await page.locator('#webhook-name').fill(updated)await page.getByRole('button', { name: /^save$/i }).click()- // The header title also reflects the new name once the mutation completes+ // The page <h1> reflects the new name once the mutation completes// (the form revalidates from the cached endpoint and the detail body- // refetches on invalidation).- await expect(page.getByRole('heading', { name: updated })).toBeVisible({ timeout: 15_000 })+ // refetches on invalidation). The Edit sheet's title also reflects the+ // name — scope to the heading-level-1 specifically to disambiguate.+ await expect(page.getByRole('heading', { level: 1, name: updated })).toBeVisible({+ timeout: 15_000,+ })})test('sends a test delivery and surfaces it in the embedded deliveries list', async ({diff --git a/packages/dashboard/src/components/spree/webhook-endpoint-form.tsx b/packages/dashboard/src/components/spree/webhook-endpoint-form.tsxindex bbe8483492..c66305ed1f 100644--- a/packages/dashboard/src/components/spree/webhook-endpoint-form.tsx+++ b/packages/dashboard/src/components/spree/webhook-endpoint-form.tsx@@ -1,5 +1,6 @@import {Badge,+ Button,Checkbox,Field,FieldDescription,@@ -8,6 +9,7 @@ import {Input,Switch,} from '@spree/dashboard-ui'+import { useState } from 'react'import { Controller, type UseFormReturn } from 'react-hook-form'import { useTranslation } from 'react-i18next'import { WEBHOOK_EVENT_GROUPS, type WebhookEndpointFormValues } from '@/schemas/webhook-endpoint'@@ -97,6 +99,7 @@ export function WebhookEndpointFormFields({function EventPicker({ value, onChange }: { value: string[]; onChange: (next: string[]) => void }) {const { t } = useTranslation()+ const [customEvent, setCustomEvent] = useState('')const allBuiltIn = WEBHOOK_EVENT_GROUPS.flatMap((g) => g.events)const customEvents = value.filter((e) => !allBuiltIn.includes(e))@@ -104,6 +107,13 @@ function EventPicker({ value, onChange }: { value: string[]; onChange: (next: stonChange(value.includes(event) ? value.filter((e) => e !== event) : [...value, event])}+ function addCustom() {+ const trimmed = customEvent.trim()+ if (!trimmed || value.includes(trimmed)) return+ onChange([...value, trimmed])+ setCustomEvent('')+ }+return (<div className="flex flex-col gap-3 rounded-md border border-border"><div className="border-b border-border bg-muted/30 p-3 text-xs text-muted-foreground">@@ -161,6 +171,24 @@ function EventPicker({ value, onChange }: { value: string[]; onChange: (next: st</div>)}</div>++ <div className="flex items-center gap-2 border-t border-border p-3">+ <Input+ placeholder={t('admin.pages.settings.webhooks.events_custom_input_placeholder')}+ value={customEvent}+ onChange={(e) => setCustomEvent(e.target.value)}+ onKeyDown={(e) => {+ if (e.key === 'Enter') {+ e.preventDefault()+ addCustom()+ }+ }}+ className="font-mono text-xs"+ />+ <Button type="button" variant="outline" size="sm" onClick={addCustom}>+ {t('admin.pages.settings.webhooks.events_add_cta')}+ </Button>+ </div></div>)}diff --git a/packages/dashboard/src/hooks/use-webhook-endpoints.ts b/packages/dashboard/src/hooks/use-webhook-endpoints.tsindex 9961d264c8..5c99fb8ef2 100644--- a/packages/dashboard/src/hooks/use-webhook-endpoints.ts+++ b/packages/dashboard/src/hooks/use-webhook-endpoints.ts@@ -22,9 +22,15 @@ export function useWebhookEndpointQueryKey(id: string | undefined) {return ['webhook-endpoints', storeId, id ?? 'noop'] as const}-export function useWebhookDeliveriesQueryKey(endpointId: string | undefined) {- const { storeId } = useStore()- return ['webhook-endpoints', storeId, endpointId ?? 'noop', 'deliveries'] as const+/**+ * The bare prefix `<ResourceTable queryKey={…}>` uses for the embedded+ * deliveries table. The table builds a compound key `[prefix, { page, … }]`,+ * so invalidating just the prefix prefix-matches every paginated/filtered+ * snapshot. Must stay in sync with the `queryKey` prop on the+ * deliveries `<ResourceTable>` in `webhooks/$webhookEndpointId.tsx`.+ */+export function webhookDeliveriesTableKey(endpointId: string) {+ return `webhook-deliveries:${endpointId}` as const}export function useWebhookEndpoint(id: string | undefined) {@@ -104,11 +110,12 @@ export function useSendTestWebhook() {successMessage: false,errorMessage: 'Failed to send test webhook',onSuccess: (_data, endpointId) => {- // Refetch the deliveries list for the endpoint we just tested so the new- // row appears without needing a manual refresh. The mutation is passed- // the endpoint id as its variable, so we can derive the right key here.+ // Refetch the deliveries list embedded in the detail page (the new test+ // row needs to appear without a manual refresh) and the endpoint's+ // detail cache (total/successful/failed counts + last_delivery_at).+ queryClient.invalidateQueries({ queryKey: [webhookDeliveriesTableKey(endpointId)] })queryClient.invalidateQueries({- queryKey: ['webhook-endpoints', storeId, endpointId, 'deliveries'],+ queryKey: ['webhook-endpoints', storeId, endpointId],})},})@@ -131,12 +138,17 @@ export function useWebhookDelivery(endpointId: string | undefined, deliveryId: s}export function useRedeliverWebhookDelivery(endpointId: string) {- const deliveriesKey = useWebhookDeliveriesQueryKey(endpointId)+ const { storeId } = useStore()return useResourceMutation<WebhookDelivery, Error, string>({mutationFn: (deliveryId) =>adminClient.webhookEndpoints.deliveries.redeliver(endpointId, deliveryId),- invalidate: [deliveriesKey],+ invalidate: [+ // Same matching as send-test — the table prefix the ResourceTable+ // actually queries under, plus the endpoint's detail cache for totals.+ [webhookDeliveriesTableKey(endpointId)],+ ['webhook-endpoints', storeId, endpointId],+ ],successMessage: false,errorMessage: 'Failed to redeliver',})diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.jsonindex c48b775cfa..8669fe6676 100644--- a/packages/dashboard/src/locales/en.json+++ b/packages/dashboard/src/locales/en.json@@ -56,6 +56,28 @@"reports": "Reports","settings": "Settings"},+ "settings_nav": {+ "groups": {+ "store": "Store",+ "payments": "Payments & taxes",+ "fulfillment": "Fulfillment",+ "team": "Team & access"+ },+ "items": {+ "store": "Store",+ "emails": "Emails",+ "channels": "Sales channels",+ "payment_methods": "Payment methods",+ "tax_categories": "Tax categories",+ "markets": "Markets",+ "stock_locations": "Stock locations",+ "custom_field_definitions": "Custom fields",+ "staff": "Staff",+ "api_keys": "API keys",+ "webhooks": "Webhooks",+ "allowed_origins": "Allowed origins"+ }+ },"fields": {"products_count": {"label": "Products"diff --git a/packages/dashboard/src/nav/settings.ts b/packages/dashboard/src/nav/settings.tsindex e7fa970785..bc3effbaf2 100644--- a/packages/dashboard/src/nav/settings.ts+++ b/packages/dashboard/src/nav/settings.ts@@ -14,14 +14,26 @@ import {WebhookIcon,} from 'lucide-react'-settingsNav.addGroup({ key: 'store', label: 'Store', position: 100 })-settingsNav.addGroup({ key: 'payments', label: 'Payments & taxes', position: 150 })-settingsNav.addGroup({ key: 'fulfillment', label: 'Fulfillment', position: 200 })-settingsNav.addGroup({ key: 'team', label: 'Team & access', position: 300 })+// Built-in entries use `labelKey` so labels re-render on language change —+// see settings-sidebar.tsx for resolution. Plugins can still pass `label`+// directly when they don't bundle their own translation files.++settingsNav.addGroup({ key: 'store', labelKey: 'admin.settings_nav.groups.store', position: 100 })+settingsNav.addGroup({+ key: 'payments',+ labelKey: 'admin.settings_nav.groups.payments',+ position: 150,+})+settingsNav.addGroup({+ key: 'fulfillment',+ labelKey: 'admin.settings_nav.groups.fulfillment',+ position: 200,+})+settingsNav.addGroup({ key: 'team', labelKey: 'admin.settings_nav.groups.team', position: 300 })settingsNav.add({key: 'settings.store',- label: 'Store',+ labelKey: 'admin.settings_nav.items.store',path: '/store',icon: StoreIcon,group: 'store',@@ -31,7 +43,7 @@ settingsNav.add({settingsNav.add({key: 'settings.emails',- label: 'Emails',+ labelKey: 'admin.settings_nav.items.emails',path: '/emails',icon: MailIcon,group: 'store',@@ -41,7 +53,7 @@ settingsNav.add({settingsNav.add({key: 'settings.channels',- label: 'Sales channels',+ labelKey: 'admin.settings_nav.items.channels',path: '/channels',icon: RadioTowerIcon,group: 'store',@@ -51,7 +63,7 @@ settingsNav.add({settingsNav.add({key: 'settings.payment-methods',- label: 'Payment methods',+ labelKey: 'admin.settings_nav.items.payment_methods',path: '/payment-methods',icon: CreditCardIcon,group: 'payments',@@ -61,7 +73,7 @@ settingsNav.add({settingsNav.add({key: 'settings.tax-categories',- label: 'Tax categories',+ labelKey: 'admin.settings_nav.items.tax_categories',path: '/tax-categories',icon: PercentIcon,group: 'payments',@@ -71,7 +83,7 @@ settingsNav.add({settingsNav.add({key: 'settings.markets',- label: 'Markets',+ labelKey: 'admin.settings_nav.items.markets',path: '/markets',icon: GlobeIcon,group: 'payments',@@ -81,7 +93,7 @@ settingsNav.add({settingsNav.add({key: 'settings.stock-locations',- label: 'Stock locations',+ labelKey: 'admin.settings_nav.items.stock_locations',path: '/stock-locations',icon: WarehouseIcon,group: 'fulfillment',@@ -91,7 +103,7 @@ settingsNav.add({settingsNav.add({key: 'settings.custom-field-definitions',- label: 'Custom fields',+ labelKey: 'admin.settings_nav.items.custom_field_definitions',path: '/custom-field-definitions',icon: TagIcon,group: 'store',@@ -101,7 +113,7 @@ settingsNav.add({settingsNav.add({key: 'settings.staff',- label: 'Staff',+ labelKey: 'admin.settings_nav.items.staff',path: '/staff',icon: UsersRoundIcon,group: 'team',@@ -111,7 +123,7 @@ settingsNav.add({settingsNav.add({key: 'settings.api-keys',- label: 'API keys',+ labelKey: 'admin.settings_nav.items.api_keys',path: '/api-keys',icon: KeyRoundIcon,group: 'team',@@ -121,7 +133,7 @@ settingsNav.add({settingsNav.add({key: 'settings.webhooks',- label: 'Webhooks',+ labelKey: 'admin.settings_nav.items.webhooks',path: '/webhooks',icon: WebhookIcon,group: 'team',@@ -131,7 +143,7 @@ settingsNav.add({settingsNav.add({key: 'settings.allowed-origins',- label: 'Allowed origins',+ labelKey: 'admin.settings_nav.items.allowed_origins',path: '/allowed-origins',icon: GlobeLockIcon,group: 'team',diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/emails.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/emails.tsxindex eb3a21f533..f37d76aa83 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/emails.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/emails.tsx@@ -69,16 +69,8 @@ function EmailSettingsPage() {const { t } = useTranslation()const { data: store, isLoading, error, refetch } = useStoreSettings()- if (isLoading || !store) {- return (- <div className="flex flex-col gap-6">- <Skeleton className="h-8 w-64" />- <Skeleton className="h-64 w-full" />- <Skeleton className="h-64 w-full" />- </div>- )- }-+ // Error first — otherwise a failed load gets stuck on the skeleton because+ // `!store` is also true and the error branch is unreachable.if (error) {return (<ErrorState@@ -89,6 +81,16 @@ function EmailSettingsPage() {)}+ if (isLoading || !store) {+ return (+ <div className="flex flex-col gap-6">+ <Skeleton className="h-8 w-64" />+ <Skeleton className="h-64 w-full" />+ <Skeleton className="h-64 w-full" />+ </div>+ )+ }+return <EmailSettingsForm store={store} />}@@ -276,9 +278,15 @@ function LogoField({const currentPreview = previewUrl ?? (cleared ? null : initialLogoUrl)// Track the latest blob URL via ref so the unmount cleanup sees the current- // value without forcing the effect to re-subscribe on every replace.+ // value without forcing the effect to re-subscribe on every replace. Two+ // effects: one revokes whenever previewUrl *changes* (covers form.reset+ // setting it to null after save); the unmount one revokes whatever's left.const previewUrlRef = useRef<string | null>(null)- previewUrlRef.current = previewUrl ?? null+ useEffect(() => {+ const previous = previewUrlRef.current+ if (previous && previous !== previewUrl) URL.revokeObjectURL(previous)+ previewUrlRef.current = previewUrl ?? null+ }, [previewUrl])useEffect(() => {return () => {if (previewUrlRef.current) URL.revokeObjectURL(previewUrlRef.current)diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/webhooks/$webhookEndpointId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/webhooks/$webhookEndpointId.tsxindex e29d91939c..ec746f3041 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/webhooks/$webhookEndpointId.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/webhooks/$webhookEndpointId.tsx@@ -53,6 +53,7 @@ import {useUpdateWebhookEndpoint,useWebhookDelivery,useWebhookEndpoint,+ webhookDeliveriesTableKey,} from '@/hooks/use-webhook-endpoints'import { webhookEndpointHealth, webhookHealthBadgeVariant } from '@/lib/webhook-health'import {@@ -410,9 +411,10 @@ function DeliveriesCard({return (<ResourceTable<WebhookDelivery>tableKey="webhook-deliveries"- // Scope the cache to the parent endpoint so two endpoints' deliveries- // can't collide in TanStack Query.- queryKey={`webhook-deliveries:${endpointId}`}+ // `webhookDeliveriesTableKey` keeps the table's prefix in sync with the+ // mutation invalidation in use-webhook-endpoints.ts — without that, the+ // new test/redeliver row never appears until a manual refresh.+ queryKey={webhookDeliveriesTableKey(endpointId)}queryFn={(params) => adminClient.webhookEndpoints.deliveries.list(endpointId, params)}searchParams={searchParams}/>diff --git a/spree/core/app/models/spree/webhook_endpoint.rb b/spree/core/app/models/spree/webhook_endpoint.rbindex 08e3cfa3ea..685702d83d 100644--- a/spree/core/app/models/spree/webhook_endpoint.rb+++ b/spree/core/app/models/spree/webhook_endpoint.rb@@ -23,6 +23,11 @@ module Spreebefore_create :generate_secret_keyafter_create { @reveal_secret_in_response = true }+ # Re-enabling via a direct `update(active: true)` (e.g., the dashboard's+ # edit form) must also clear the auto-disable bookkeeping so the endpoint+ # rejoins the `enabled` scope. `#enable!` handles this too, but we can't+ # rely on every call site using it.+ before_save :clear_disabled_state_when_reactivatedself.whitelisted_ransackable_attributes = %w[name url active]@@ -140,6 +145,13 @@ module Spreeself.secret_key ||= SecureRandom.hex(32)end+ def clear_disabled_state_when_reactivated+ return unless will_save_change_to_active? && active++ self.disabled_at = nil+ self.disabled_reason = nil+ end+def url_must_not_resolve_to_private_ipuri = URI.parse(url)blacklist = SsrfFilter::IPV4_BLACKLIST + SsrfFilter::IPV6_BLACKLISTdiff --git a/spree/core/spec/models/spree/webhook_endpoint_spec.rb b/spree/core/spec/models/spree/webhook_endpoint_spec.rbindex d7655eb8dc..6872ea21ee 100644--- a/spree/core/spec/models/spree/webhook_endpoint_spec.rb+++ b/spree/core/spec/models/spree/webhook_endpoint_spec.rb@@ -70,6 +70,35 @@ describe Spree::WebhookEndpoint, type: :model doexpect(endpoint.secret_key).to eq('existing_key')endend++ describe 'before_save :clear_disabled_state_when_reactivated' do+ let(:endpoint) do+ create(+ :webhook_endpoint,+ store: store,+ active: false,+ disabled_at: 1.hour.ago,+ disabled_reason: 'too many failures'+ )+ end++ it 'clears disabled_at and disabled_reason when activated' do+ endpoint.update!(active: true)+ expect(endpoint.disabled_at).to be_nil+ expect(endpoint.disabled_reason).to be_nil+ end++ it 'rejoins the enabled scope after re-activation' do+ endpoint.update!(active: true)+ expect(described_class.enabled).to include(endpoint)+ end++ it 'leaves disabled bookkeeping alone when active stays false' do+ endpoint.update!(name: 'renamed')+ expect(endpoint.reload.disabled_at).to be_present+ expect(endpoint.disabled_reason).to eq('too many failures')+ end+ endenddescribe '#subscribed_to?' do