mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 23:49:03 +00:00
## Problem The webhook deliveries table has a search input and sortable column headers, but they only act on the page of rows already loaded (5 rows). The backend uses cursor pagination and has no server-side filtering or sorting, so searching for a term that isn't on the visible page shows "No deliveries found" even when matches exist. This looks broken. Closes FE-4762. The follow-up to bring these back once the backend supports it is tracked in DEPR-709. ## Solution - Removed the search input, its focus shortcut, and the `deliverySearch` URL state from the deliveries table. - Removed the sort controls from the column headers. Headers are now plain text. - Removed the unused `filterWebhookDeliveries` helper and its test. Rows now render in the order the API returns them. - Updated the empty state copy, since it referred to adjusting a search. - Cursor pagination is unchanged. ## How to test 1. Open a project's webhooks page and select an endpoint with deliveries. 2. Check that the Deliveries section has no search input, only the Live toggle and the refresh button. 3. Check that the column headers (Status, Event, Response, Attempted) are not clickable and show no sort icons. 4. Check that the previous and next page buttons still page through deliveries. 5. Select an endpoint with no deliveries and check that the empty state reads "Webhook attempts will show up here once this endpoint receives events."
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import type { WebhookEndpoint } from './PlatformWebhooks.types'
|
|
|
|
const secureRandomHex = (length: number) => {
|
|
if (length <= 0) return ''
|
|
|
|
const cryptoApi = globalThis.crypto
|
|
if (!cryptoApi?.getRandomValues) {
|
|
throw new Error('Web Crypto API is not available')
|
|
}
|
|
|
|
const byteCount = Math.ceil(length / 2)
|
|
const bytes = new Uint8Array(byteCount)
|
|
cryptoApi.getRandomValues(bytes)
|
|
|
|
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0'))
|
|
.join('')
|
|
.slice(0, length)
|
|
}
|
|
|
|
export const generateSigningSecret = () => `whsec_${secureRandomHex(16)}`
|
|
|
|
export const getWebhookEndpointDisplayName = (
|
|
endpoint: Pick<WebhookEndpoint, 'url' | 'eventTypes'>
|
|
) => {
|
|
const eventTypesLabel = endpoint.eventTypes.includes('*')
|
|
? 'all events'
|
|
: endpoint.eventTypes.join(', ')
|
|
return `${endpoint.url} (${eventTypesLabel})`
|
|
}
|
|
|
|
export const getTestWebhookEventType = (
|
|
subscribedEventTypes: string[],
|
|
fallbackEventTypes: string[]
|
|
) => subscribedEventTypes.find((eventType) => eventType !== '*') ?? fallbackEventTypes[0]
|
|
|
|
const normalizeSearch = (value: string) => value.trim().toLowerCase()
|
|
|
|
export const filterWebhookEndpoints = (endpoints: WebhookEndpoint[], search: string) => {
|
|
const normalizedSearch = normalizeSearch(search)
|
|
if (normalizedSearch.length === 0) return endpoints
|
|
|
|
return endpoints.filter((endpoint) => {
|
|
const haystack =
|
|
`${getWebhookEndpointDisplayName(endpoint)} ${endpoint.url} ${endpoint.description}`.toLowerCase()
|
|
return haystack.includes(normalizedSearch)
|
|
})
|
|
}
|