Commit Graph
5 Commits
Author SHA1 Message Date
Alaister YoungandAlaister Young 0c97b9789b [FE-3107] chore(studio): remove remaining Next.js references (#54426)
Removes the remaining Next.js dependencies, compatibility shims, test
mocks, ESLint/TypeScript presets, and webpack/Next workarounds from
Studio following the TanStack Start migration.

Addresses FE-3107.

**Removed:**

- `next` and `next-router-mock` from `apps/studio/package.json` (and
updated `pnpm-lock.yaml`)
- Orphaned `apps/studio/compat/next/script.tsx` shim, `script.test.tsx`,
`compat/**` knip entry, and `nextCompat()` / `ssr.noExternal` `/^next/`
plumbing from `apps/studio/vite.config.ts`
- `apps/studio/tests/lib/route-mock.ts` and all `next-router-mock`
setup/imports across `tests/vitestSetup.ts`,
`tests/lib/custom-render.tsx`, and 12 test files
- `apps/studio/tests/pages/` directory (moved the 3 remaining tests to
`components/interfaces/Organization/Organization.utils.test.ts` and
`apps/studio/tests/routes/`)
- Unused `'use client'` directives across 23 Studio files
- Next.js/webpack workarounds: `graphiqlViteWorkers()` in
`vite.config.ts`, webpack `import.meta.glob` `try/catch` fallback in
`ConnectStepsSection.tsx`, shell `NODE_ENV=test` override in
`vite.config.ts` / root `package.json` / `studio-e2e-test.yml`, Next
`getPathMatch` and `_next` passthrough in `redirects.shared.*`,
`window.next?.router` check in `monaco-graphiql-coexistence.spec.ts`,
and unused `ANALYZE` env var in `apps/studio/turbo.jsonc`
- Next-only Sentry/chunk-load filters (`NEXT_NOT_FOUND`,
`NEXT_REDIRECT`, Next `/org/[slug]/` regex, `/app:\/\//`, dead
`includeThirdPartyErrorFilter` plumbing, webpack chunk error regex) and
stale Next/Pages Router comments, docs, and `#__next` CSS selector

**Changed:**

- `apps/studio/eslint.config.cjs`: switched from
`eslint-config-supabase/next` to the new `eslint-config-supabase/react`
preset (dropping `@next/next/no-img-element: off`, keeping `.next` /
`next-env.d.ts` ignored for local checkouts with stale pre-migration
build artifacts)
- `apps/studio/tsconfig.json`: extends `tsconfig/base.json` directly
instead of `tsconfig/nextjs.json` (identical resolved compiler options)
- `apps/studio/.github/eslint-rule-baselines.json`: pruned 33 stale
`pages/...` and `types/next.ts` entries without changing any rule
thresholds
- `apps/studio/tests/lib/custom-render.tsx`: backed
`TestFrameworkProvider` with TanStack Router instead of
`next-router-mock`
-
`apps/studio/components/interfaces/Integrations/GraphQL/GraphiQLTab.tsx`:
imports `graphiql/setup-workers/vite` directly
- `apps/studio/styles/globals.css`: replaced `@source
'../pages/**/*.{js,ts,jsx,tsx}'` with `@source
'../routes/**/*.{js,ts,jsx,tsx}'`
- `apps/studio/turbo.jsonc`: declared `"NEXT_PUBLIC_*"` in
`tasks.build.env` now that Turborepo infers `nitro` instead of `nextjs`
-
`apps/studio/components/interfaces/Organization/Organization.utils.ts`:
narrowed `buildOrgUrl`'s `slug` parameter to `string[] | undefined`

**Added:**

- `packages/eslint-config-supabase/shared.js` and
`packages/eslint-config-supabase/react.js` (plus `presets.test.ts`),
decoupling non-Next React apps from `eslint-config-next` with verified
zero non-`@next/*` rule drift while keeping
`eslint-config-supabase/next` unchanged for the Next.js apps

## To test

- Run `pnpm --filter eslint-config-supabase run test` and confirm preset
parity tests pass
- Run `pnpm --filter studio run lint`, `pnpm --filter studio run
lint:ratchet`, `pnpm --filter studio run typecheck`, `pnpm knip
--workspace apps/studio`, and `pnpm --filter studio run test`
- Run `pnpm --filter studio run build` and verify the production build,
prerendered routes, chunk-cycle check, and GraphiQL web workers succeed
- Smoke-test Studio locally (`pnpm dev:studio`): verify GraphiQL loads
cleanly, ConnectSheet framework steps render, and Tailwind styles on
route pages are intact

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-12-02 17:01:50 +08:00
Alaister YoungandAlaister Young 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>
2026-12-01 14:44:59 +08:00
Gildas GarciaandJoshen Lim de63769998 feat(studio): add ability to purge CDN cache to storage UI (#52777)
## Problem

Users should be able to purge the CDN cache for an individual object or
entire bucket via the UI.
This feature is only available for Pro+ customers. Free tier customers
should be encouraged to upgrade to get access.

## Solution

- Add a _Purge CDN cache_ action to the bucket menu. Prompt users on
Free plan to upgrade if needed.
<img width="182" height="149" alt="image"
src="https://github.com/user-attachments/assets/b665c8d0-b540-400e-a328-85c48ddafee0"
/>
<img width="534" height="242" alt="image"
src="https://github.com/user-attachments/assets/15dfd3d3-c8a9-4ad7-9046-0929fd715511"
/>

<img width="538" height="211" alt="image"
src="https://github.com/user-attachments/assets/3e29644e-9335-4b1d-b321-49303c2e8476"
/>


- Add a _Purge CDN cache_ action to the bucket item menu. Prompt users
on Free plan to upgrade if needed.
<img width="283" height="313" alt="image"
src="https://github.com/user-attachments/assets/a801297e-04b5-46c7-aaf7-4569e66e4714"
/>
  
<img width="541" height="249" alt="image"
src="https://github.com/user-attachments/assets/b58d264b-76ba-43d4-9579-6c07be9cb684"
/>

  
<img width="537" height="207" alt="image"
src="https://github.com/user-attachments/assets/132b37bd-3a29-48b5-aa7e-7df29abcbfe6"
/>

## Notes

- Refactored the _Edit bucket_ menu so that only one modal is allowed
- Fixed focus management related to the modals displayed by the _Edit
bucket_ menu items
- Introduced a way to mock the authenticated users in tests

## Review instructions

- On an org on at least _Pro_ plan
  - Open a bucket _Edit bucket_ menu and click _Purge CDN cache_
- Confirming should call the `/platform/storage/{ref}/cdn/purge-bucket`
API endpoint
  - Open a bucket item menu and click _Purge CDN cache_
- Confirming should call the `/platform/storage/{ref}/cdn/purge-object`
API endpoint

- On an org on _Free_ plan
  - Open a bucket _Edit bucket_ menu and click _Purge CDN cache_
  - You should be prompted to upgrade
  - Open a bucket item menu and click _Purge CDN cache_
  - You should be prompted to upgrade

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-11-10 16:08:08 +01:00
supabase-vercel-tedd[bot] 04f3c6c41c fix(studio): return to the buckets list after deleting a bucket from its page (#53028)
## Problem

Deleting a bucket from its own page
(`/storage/files/buckets/[bucketId]`) could leave Studio on the deleted
bucket's route. The page kept loading and then showed "Failed to fetch
buckets" / "Bucket not found".

On success, `DeleteBucketModal` called `onClose()` and then
`router.push` to the buckets list. On the bucket page, `onClose` clears
the `?delete` query param through nuqs, which queues its own shallow
push to the current bucket URL. That push could race with the navigation
to the list and land back on the deleted bucket. The page then
re-rendered with the bucket query already removed from the cache,
refetched the missing bucket, and got a 404.

## Solution

- On the bucket's own page, the success handler now awaits `router.push`
to the buckets list and does not call `onClose`. The modal closes when
the page unmounts. When there is no `bucketId` in the route, it still
calls `onClose` as before.
- Added a component test for deleting from the bucket page. It checks
that Studio ends up on `/project/<ref>/storage/files` and that `onClose`
is not called. The test opts out of the global `useParams` stub so the
modal reads `bucketId` from the mocked route. It fails without the fix.

## How to verify

1. Open a project, go to Storage > Files, and open any bucket.
2. Choose Edit bucket > Delete bucket, type the bucket name, and
confirm.
3. Studio shows the success toast and lands on the buckets list
(`/project/<ref>/storage/files`). The deleted bucket no longer appears
there.
4. Studio never shows the deleted bucket's page with a spinner that
keeps loading, "Failed to fetch buckets" or "Bucket not found".

## Checks run

- `pnpm --filter studio exec vitest run
components/interfaces/Storage/FilesBuckets/DeleteBucketModal.test.tsx`
(2 passed)
- `pnpm turbo run typecheck --filter='...[origin/master]'`
- `pnpm turbo run lint --filter='[origin/master]'`
- Prettier check on the changed files


[FE-4926](https://linear.app/supabase/issue/FE-4926/deleting-a-bucket-leaves-its-page-loading-until-an-error)

---------

Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com>
2026-11-05 08:15:41 -06:00
6ef729cb5c feat(storage): versioning bucket modals (FE-4161) (#49205)
| # | Branch | Base |
| - | ------ | ---- |
| 1 | `feat/storage-versioning-private-alpha` — merged | `master` |
| 2 | `feat/storage-versioning/002-bucket-form-fields` | `master` |
| 3 | `feat/storage-versioning/003-bucket-modals` ◀ | 2 |
| 4 | `feat/storage-versioning/004-object-versions-data` | 3 |
| 5 | `feat/storage-versioning/005-file-preview-versions` | 4 |
| 6 | `feat/storage-versioning/006-billing-storage-retention` | 5 |
| 7 | `feat/storage-versioning/007-archived-objects-data` | 6 |
| 8 | `feat/storage-versioning/008-archived-rows` | 7 |
| 9 | `feat/storage-versioning/009-archived-preview-pane` | 8 |
| 10 | `feat/storage-versioning/010-replace-file` | 9 |

## [3/10] Storage object versioning: wire into the bucket modals

**Base:** `feat/storage-versioning/002-bucket-form-fields` (PR 2)

### This PR

Mounts the object-versioning form section in the create and edit bucket
modals behind the feature preview, and saves it.

- create and edit bucket modals spread `bucketVersioningFormFields` into
their existing form schema
- lifecycle defaults  to 30 days / 10 versions
- edit adds a confirmation before suspending an actively versioned
bucket

## Enabling object versioning on a new bucket and setting lifecycle
policies


https://github.com/user-attachments/assets/194f8319-4929-432e-8a50-206f180a77a8

## Edit and suspend object-versioning


https://github.com/user-attachments/assets/f31e1d34-9840-4f5a-a269-6a911214742d

## To reproduce

1. Make sure storage versioning is enabled under feature previews >
Storage Versioning
2. Open Storage Bucket File explorer
3. create new bucket and enable Object Versioning
4. set lifecycle policy
- Noncurrent version expiration: can be either empty or >1
- Retained noncurrent versions: can be either empty or between 1 and 100
and can't exist without "Noncurrent version expiration"
5. Open new bucket with object versioning and test changing lifecycle
policies
6. Disabling object-versioning shows proper warning and updates
`versioning_status` to SUSPENDED (it can never go back to DISABLED once
it has been enabled on a bucket)

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2026-10-07 16:38:35 +02:00