mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Problem When editing the events a webhook endpoint is subscribed to and clicking save, the event checkboxes flip back to the previously saved selection while the save is in progress. The saved endpoint has the correct events, but the sheet shows the wrong ones. Closes FE-5275. ## Solution The edit sheet resets its form whenever the event types it receives change. The page built that list as a new array on every render, so any re-render of the page counted as a change. Clicking save puts the mutation into its pending state, which re-renders the page, which reset the form to the old saved events. - Memoized the event type options in the page, so the array only changes when the scope changes. - Added tests that hold the save request open and check the checkboxes while it is pending: one for unchecking an event and one for adding an event. Both failed before the change. ## How to test 1. Open a webhooks page and select an endpoint that is subscribed to all events. 2. Click Edit, uncheck a few events, and click Save changes. 3. Check that the unchecked events stay unchecked while the sheet is saving, and that the endpoint shows the events you picked afterwards. 4. Edit an endpoint that is subscribed to only one or two events, check an extra event, and click Save changes. 5. Check that the extra event stays checked while the sheet is saving, and that the endpoint shows it afterwards. 6. Try the same on an organization webhooks page.
Writing components
Where to create your components
- For components that declare the general structure and layout of a page:
/components/layouts/xxx
- For components that are tightly coupled to a specific interface:
/components/interfaces/xxx
- For components that are meant to be reusable across multiple pages:
/components/ui/xxx
- Note: We're gradually moving files out of the
to-be-cleanedfolder into the respective folders as we refactor
Component structure
- If a component has constants and utility methods that are tightly coupled to itself, keep them close to the component and enclose them in a folder with an
index.tsxas an entry point - Otherwise it can just be a file on its own
- For example:
-
components/ui - SampleComponentA - SampleComponentA.tsx - SampleComponentA.constants.ts - SampleComponentA.utils.ts - SampleComponentA.types.ts - index.ts - SampleComponentB.tsx
-
Template for building components
// Declare the prop types of your component
interface ComponentAProps {
sampleProp: string
}
// Name your component accordingly — use a named export, not a default export
export const ComponentA = ({ sampleProp }: ComponentAProps) => {
return <div>ComponentA: {sampleProp}</div>
}