mirror of
https://github.com/supabase/supabase.git
synced 2026-09-06 09:59:03 +08:00
## What PR 7 of the SQL-editor query-source (Database vs Logs) stack. Surfaces `log_sql` snippets as a distinct query source across the SQL editor sidebar. Stacked on **`charislam/toolbar-ui-creation-flow`** (PR 6 — toolbar UI + creation flow); review/merge that first. Nothing is user-visible until the flags roll out — every entry point requires **both** `sqlEditorLogsSource` **and** `otelLegacyLogs`. ## Changes - **Nav** — a flag-gated **Logs** section (`LogsSnippetsSection`) backed by its own single-type `log_sql` query. The active snippet is injected only into the section it belongs to, via a shared `withActiveSnippet(snippets, active, belongsPredicate)` helper (also DRYs the private/favorites/shared injections). - **Search** (`SearchList`) — a **Logs** result group with a shared, extracted `SqlSnippetTree`; the "N results found" count now sums database + logs, with loading/empty states covering both queries. - **Tabs** — an immutable `sqlSource` field on tab/recent-item metadata (set at tab creation, lazily backfilled once the snippet loads via `useEffectEvent`), and a distinct `ScrollText` icon via a shared `LogsSnippetIcon`. Tab cleanup treats `log_sql` tabs as live and only prunes them when logs data is authoritative (`canPruneLogsTabs`), so a disabled/erroring logs query never wrongly deletes logs tabs or blocks database-tab cleanup. - **Data layer** — `useSqlSnippetsQuery` gains an optional `type` param so logs reuse the same `SnippetWithContent` shape as the other sections (no casts). ## Tests - `state/tabs.test.ts` — `sqlSource` backfill + creation-time carry-through. - `components/layouts/Tabs/Tabs.utils.test.tsx` — cleanup prunes stale database/logs snippets, keeps live ones, and preserves logs tabs when logs data isn't authoritative. ## Verification - `pnpm --filter studio typecheck` ✓ - `pnpm --filter studio run lint:ratchet` ✓ - `pnpm test:studio` (affected suites) ✓ <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a collapsible Logs section to the SQL editor sidebar for browsing, sorting, selecting, renaming, and deleting log queries. * Expanded SQL search with separate, paginated results for database and log queries. * Added dedicated log-query icons across navigation, tabs, previews, and recent items. * **Bug Fixes** * Improved tab and recent-item cleanup while preserving active log queries and accurate source metadata. * **Tests** * Added coverage for log tab cleanup and SQL source metadata synchronization. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
export const contentKeys = {
|
|
allContentLists: (projectRef: string | undefined) => ['projects', projectRef, 'content'] as const,
|
|
infiniteList: (
|
|
projectRef: string | undefined,
|
|
options?: {
|
|
type: string
|
|
name: string | undefined
|
|
limit?: number
|
|
sort?: string
|
|
}
|
|
) => ['projects', projectRef, 'content-infinite', options].filter(Boolean),
|
|
list: (
|
|
projectRef: string | undefined,
|
|
options: { type?: string; name?: string; limit?: number }
|
|
) => ['projects', projectRef, 'content', options] as const,
|
|
sqlSnippets: (
|
|
projectRef: string | undefined,
|
|
options?: {
|
|
type?: 'sql' | 'log_sql'
|
|
sort?: 'inserted_at' | 'name'
|
|
name?: string
|
|
visibility?: string
|
|
favorite?: boolean
|
|
}
|
|
) => ['projects', projectRef, 'content', 'sql', options].filter(Boolean),
|
|
folders: (
|
|
projectRef: string | undefined,
|
|
options?: { sort?: 'inserted_at' | 'name'; name?: string }
|
|
) => ['projects', projectRef, 'content', 'folders', options].filter(Boolean),
|
|
folderContents: (
|
|
projectRef: string | undefined,
|
|
id?: string,
|
|
options?: { sort?: 'inserted_at' | 'name'; name?: string }
|
|
) => ['projects', projectRef, 'content', 'folders', id, options].filter(Boolean),
|
|
resource: (projectRef: string | undefined, id?: string) =>
|
|
['projects', projectRef, 'content-id', id] as const,
|
|
count: (
|
|
projectRef: string | undefined,
|
|
type?: string,
|
|
options?: {
|
|
visibility?: string
|
|
favorite?: boolean
|
|
name?: string
|
|
}
|
|
) => ['projects', projectRef, 'content', 'count', type, options].filter(Boolean),
|
|
}
|