mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
docs/reference-template
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d8568215ad |
[FE-5109] (part 4) refactor(studio): migrate database, editor, storage, and functions interfaces off next/router (#54056)
Part 4 of a 6-PR stack migrating all `next/router` and `next/compat/router` imports in `apps/studio` onto TanStack Router hooks and removing the router shims. | Part | PR | Scope | | --- | --- | --- | | 1 | #54053 | Core navigation helpers, `hooks/**`, `lib/**`, `data/prefetchers/**` | | 2 | #54054 | `components/ui/**` | | 3 | #54055 | `components/layouts/**` and `state/tabs.tsx` | | **4** | **#54056 ← this PR** | **Database, Branching, Compute, Edge Functions, Explorer, SQL Editor, Storage, Table Editor** | | 5 | #54057 | Remaining `components/interfaces/**` and `QueryInsightsTable` router events | | 6 | #54058 | Remove `next/router` & `next/compat/router` shims, `_router-events.ts`, Vite aliases, and test mocks | Migrates the database, branching, compute, functions, explorer, SQL editor, storage, and table editor interfaces off `next/router` and `next/compat/router`. **Changed:** - Migrated the sole `next/compat/router` consumer (`components/interfaces/Database/Replication/Destinations.tsx`) to `useNavigate` - Replaced `useRouter` across `BranchManagement`, `Branching`, `Compute`, `Database` (`Backups`, `Functions`, `Replication`, `Schemas`, `Tables`, `Triggers`), `EdgeFunctions`, `Explorer`, `Functions`, `SQLEditor`, `Storage` (`AnalyticsBuckets`, `FilesBuckets`, `VectorBuckets`, `StorageMenuV2`, `Storage.utils`), and `TableGridEditor` with TanStack Router hooks (`useNavigate`, `useLocation`, `useRoutePattern`) and `useParams` from `common` - Updated unit and component tests across `Database/Replication`, `Explorer`, `Functions`, and `Storage/FilesBuckets/DeleteBucketModal.test.tsx` to use TanStack Router **Simplified:** - `useSnippetEditor` and `useRedirectLegacyReadReplicaDestination` read search values from `useParams` instead of casting `location.search` - `resolveSourceSwitch` returns `replace: boolean` instead of a `push`/`replace` method name - `ExplorerQueryTab` and `EdgeFunctionDetails` guard on a defined ref instead of navigating with `ref ?? ''` - `useFunctionsDetailShortcuts` and `StorageMenuV2` use a local `goTo` helper for their navigation shortcuts - Tests use the shared `createTestRouter` and `customRender` router, use `toMatchObject` for search assertions, and drop duplicate assertions Addresses [FE-5109](https://linear.app/supabase/issue/FE-5109/replace-the-nextrouter-shims-with-tanstack-router-hooks) ## To test - [ ] SQL Editor: creating, renaming, moving, opening templates/examples, and keyboard shortcuts navigate between snippets cleanly - [ ] Table Editor & Database: opening tables, schema table nodes, triggers, functions, backups/PITR, and replication destination flows navigate as expected - [ ] Storage: switching between Files, Analytics, and Vector buckets and deleting a bucket navigates cleanly - [ ] Edge Functions & Explorer: opening function details/logs, explorer chat/query tabs, and branch management actions navigate properly --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com> |
||
|
|
3b57afc40c |
fix(studio): wait for project endpoint before showing function url (#53255)
`EdgeFunctionsListItem` built its URL as ``
`${endpoint}/functions/v1/${slug}` `` from `useProjectApiUrl`, whose
`data` is `undefined` while the project settings query is still pending.
On a cold load, each row showed `undefined/functions/v1/<slug>`, and the
copy button copied that string. `EdgeFunctionDetails` and
`TerminalInstructions` interpolated the endpoint the same way.
**Changed:**
-
`apps/studio/components/interfaces/Functions/EdgeFunctionsListItem.tsx`:
only builds the URL once `endpoint` is defined. While it's pending, the
row shows a `ShimmeringLoader` in place of the URL and no copy button.
The copy button now has an accessible name ("Copy function URL").
-
`apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx`:
the "Invoke function" snippets wait for both the endpoint and the
function. Until then they show a skeleton, so the cURL tab no longer
renders or copies `undefined/functions/v1/...`. If either query fails,
the card shows an `AlertError` instead.
-
`apps/studio/components/interfaces/Functions/TerminalInstructions.tsx`:
the "Invoke your function" curl command is only added once the endpoint
resolves, with a loader in its place until then.
Also checked: `EdgeFunctionOverviewHeader` already guards on `endpoint
&& slug`, so it's unchanged. `EdgeFunctionTesterSheet` doesn't use
`useProjectApiUrl`: it builds the URL from project settings at submit
time and never renders it, so it's also unchanged. `useProjectApiUrl`
itself is unchanged.
**Added:**
-
`apps/studio/components/interfaces/Functions/EdgeFunctionsListItem.test.tsx`:
renders a row while the settings request is in flight and asserts
there's no `undefined/functions/v1` text, a loader is shown and there's
no copy button. Once settings resolve, it asserts the full URL and that
the copy button copies it. It fails on the old component.
-
`apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.platform.test.tsx`:
a case where project settings fail to load, asserting the invoke card
shows the error and no cURL snippet.
## To test
- [ ] Open a project's Edge Functions page (`/project/<ref>/functions`)
with a hard reload and network throttling (for example "Slow 4G"). The
URL column never shows `undefined`: it shows a loader, then
`https://<ref>.supabase.co/functions/v1/<slug>`.
- [ ] Click a row's copy icon: the clipboard has the full function URL
and the page doesn't navigate.
- [ ] Click a row: it still navigates to that function's page.
- [ ] Hard reload a function's Details page
(`/project/<ref>/functions/<slug>/details`) with throttling. The cURL
snippet under "Invoke function" shows a skeleton, then the real URL.
- [ ] Open `/project/<ref>/functions?create=cli` with throttling. The
"Invoke your function" curl command shows a loader, then the real URL.
---------
Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
|
||
|
|
1decd82fcc |
feat(studio): gate edge functions and vector bucket api-keys consumers on grants (#52962)
Part 2 of 6 in a stack for [FE-4731](https://linear.app/supabase/issue/FE-4731/grants-rollout-api-keys-consumers-that-only-need-publishable-keys). Based on #52961. ## Stack 1. #52961 Docs and project API docs consumers 2. 👉 #52962 Edge functions and vector bucket examples 3. #52963 Integrations landing data 4. #52964 Connect sheet and project connection popover; remove the transitional api-keys hooks 5. #52965 `reveal` refinement for single api-key reads; API key pill 6. #52966 API key create and delete ## Changes Moves more publishable-key consumers onto the plain `GET /v1/projects/{ref}/api-keys` grant: - `Functions/TerminalInstructions` - `Functions/EdgeFunctionDetails`: only the `api_gateway_keys_read` check; the `edge_functions_write` check belongs to the edge functions rollout - `Storage/VectorBuckets/.../VectorBucketTableExamplesSheet`: still uses non-revealed keys. When keys can't be read, the note tells the user to substitute their own secret key. Each shows `ApiKeysAccessNote` when denied or errored. The old guards matched the annotation. ## Testing - `TerminalInstructions.platform.test.tsx`, `EdgeFunctionDetails.platform.test.tsx`, `VectorBucketTableExamplesSheet.platform.test.tsx`: granted, denied (no api-keys request), and permission-check error. 🤖 Generated with [Claude Code](https://claude.com/claude-code) |