mirror of
https://github.com/supabase/supabase.git
synced 2026-09-08 10:59:38 +08:00
## What kind of change does this PR introduce? Feature ## What is the current behavior? The dev toolbar is only discoverable via `window.devToolbar()` in the browser console, or by having your email on the `devToolbarDefaultOn` ConfigCat flag. Once enabled, Studio shows a floating trigger button. ## What is the new behavior? In local and staging Studio, the account/settings dropdown (avatar menu) includes a **Local tools** section above **Theme** with a **Dev toolbar** checkbox toggle. - **On**: shows the floating orb (persists via localStorage, same as `window.devToolbar()`) - **Off**: hides the orb and dismisses the toolbar Open the panel itself via the orb once it is visible. Production builds are unchanged (`isAvailable` is false and the menu item is hidden). | After | | --- | | <img width="226" height="204" alt="CleanShot 2026-08-20 at 12 46 38@2x" src="https://github.com/user-attachments/assets/c846b119-626d-48f5-9a02-aef4d006326c" /> | | <img width="558" height="1024" alt="CleanShot 2026-08-20 at 12 47 04@2x" src="https://github.com/user-attachments/assets/4b3dd22b-537b-4874-821d-c202033c4ad7" /> | ## Manual testing Run `pnpm dev:studio` and open http://localhost:8082. 1. **Find the entry point:** top-right avatar/settings menu → **Local tools** → **Dev toolbar** (above **Theme**). Should not appear in production builds. 2. **Turn it on:** check **Dev toolbar**. A green floating orb should appear (default bottom-right). 3. **Open the panel:** click the orb. The **Dev Toolbar** sheet should open with Events and Flags tabs. 4. **Event count:** navigate around Studio (e.g. open a project, switch pages). The orb badge should increment and stay readable in light and dark mode. 5. **Turn it off:** reopen the avatar menu and uncheck **Dev toolbar**. The orb and panel should disappear. 6. **Close vs hide:** with the toolbar on, open the sheet and use **Close** (X). The orb should remain; only the sheet closes. Optional: confirm `window.devToolbar()` in the browser console still enables the orb. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a Local tools option to enable the development toolbar when available. * Toolbar activation and dismissal preferences now persist between sessions. * Added clearer event-count badges with responsive sizing for larger counts. * **Improvements** * Simplified toolbar controls by removing the separate hide option. * Improved toolbar availability handling across local and production environments. * **Tests** * Expanded coverage for activation, persistence, visibility, and event-count badges. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Danny White <dnywh@users.noreply.github.com> Co-authored-by: Sean Oliver <882952+seanoliver@users.noreply.github.com>
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import type { ReactNode } from 'react'
|
|
|
|
import * as DevToolbarModule from './DevToolbar'
|
|
import * as DevToolbarContextModule from './DevToolbarContext'
|
|
import * as DevToolbarTriggerModule from './DevToolbarTrigger'
|
|
import type { DevTelemetryToolbarContextType } from './types'
|
|
|
|
// Tree-shaking pattern: conditionally export stubs outside local/staging.
|
|
// The bundler replaces NEXT_PUBLIC_ENVIRONMENT at build time, making the
|
|
// ternary static. In production builds (env === 'prod'), the implementation
|
|
// modules are eliminated from the bundle.
|
|
// Duplicated for tree-shaking — bundler must see literal process.env reference.
|
|
// Keep in sync: DevToolbarContext.tsx, DevToolbar.tsx, DevToolbarTrigger.tsx, feature-flags.tsx
|
|
const env = process.env.NEXT_PUBLIC_ENVIRONMENT
|
|
const isToolbarEnabled = env === 'local' || env === 'staging'
|
|
|
|
const noopContext: DevTelemetryToolbarContextType = {
|
|
isAvailable: false,
|
|
isEnabled: false,
|
|
isOpen: false,
|
|
setIsOpen: () => {},
|
|
enableToolbar: () => {},
|
|
events: [],
|
|
setEvents: () => {},
|
|
dismissToolbar: () => {},
|
|
}
|
|
|
|
export const DevToolbarProvider = !isToolbarEnabled
|
|
? ({ children }: { children: ReactNode; apiUrl?: string }) => children
|
|
: DevToolbarContextModule.DevToolbarProvider
|
|
|
|
export const useDevToolbar = !isToolbarEnabled
|
|
? () => noopContext
|
|
: DevToolbarContextModule.useDevToolbar
|
|
|
|
export const DevToolbar = !isToolbarEnabled
|
|
? (_props: { extraTabs?: import('./types').ExtraTab[] }) => null
|
|
: DevToolbarModule.DevToolbar
|
|
|
|
export const DevToolbarTrigger = !isToolbarEnabled
|
|
? () => null
|
|
: DevToolbarTriggerModule.DevToolbarTrigger
|
|
|
|
export type { DevTelemetryEvent, DevToolbarConfig, ExtraTab } from './types'
|