mirror of
https://github.com/supabase/supabase.git
synced 2026-06-14 14:08:31 +08:00
Adds a top-level `logs:all` flag (default `true`) so self-hosted and local setups can hide the logs pages in Studio when Logflare isn't configured — no separate Studio build required. The flag itself works everywhere; the additional `ENABLED_FEATURES_LOGS_ALL` env-var override (from FE-3036) is the self-hosted escape hatch so deployers can flip it without a custom build — that part is a no-op on `IS_PLATFORM` because hosted feature gating flows through `profile.disabled_features` instead. Addresses [COM-205](https://linear.app/supabase/issue/COM-205/add-feature-flag-to-disable-all-logs-in-studio). **Added:** - `logs:all` feature flag in `enabled-features.json` + schema **Changed:** - Sidebar "Logs" nav entry is hidden when `logs:all` is off (same pattern as `reports:all` / `billing:all`) - Cmd-K "Logs Explorer" / "Auth Logs" / etc. routes are hidden when the flag is off - `LogsLayout` renders `<UnknownInterface />` (soft-404) when the flag is off — covers all ~18 logs pages in one spot - `/logs/index.tsx` applies the same soft-404 for the unified-logs entry point ## To test Needs to be tested locally (preview doesn't let you flip the flag — hosted gating is profile-driven, not env-driven). Two ways: - Temporarily edit `"logs:all": false` in `packages/common/enabled-features/enabled-features.json` and run `pnpm dev:studio`, or - Run Studio locally with `ENABLED_FEATURES_LOGS_ALL=false` (env-var path, same as how self-hosted deployers would use it) With the flag **off**: - Sidebar "Logs" entry is hidden - Cmd-K search for "Logs" / "Auth Logs" / "Postgres Logs" etc. returns nothing - Direct navigation to `/project/<ref>/logs`, `/project/<ref>/logs/explorer`, `/project/<ref>/logs/auth-logs`, `/project/<ref>/logs/postgres-logs` (etc.) all render the "Looking for something?" soft-404 with a Head back button With the flag **on** (default): everything works as it does today. **Check on the preview deploy too** — nothing should change, no behaviour difference on hosted. Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
70 lines
2.3 KiB
TypeScript
70 lines
2.3 KiB
TypeScript
import { useParams } from 'common'
|
|
import type { CommandOptions } from 'ui-patterns/CommandMenu'
|
|
import { useRegisterCommands } from 'ui-patterns/CommandMenu'
|
|
import { IRouteCommand } from 'ui-patterns/CommandMenu/internal/types'
|
|
|
|
import { COMMAND_MENU_SECTIONS } from '@/components/interfaces/App/CommandMenu/CommandMenu.utils'
|
|
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
|
|
|
|
export function useLogsGotoCommands(options?: CommandOptions) {
|
|
let { ref } = useParams()
|
|
ref ||= '_'
|
|
|
|
const { logsAll, logsCollections } = useIsFeatureEnabled(['logs:all', 'logs:collections'])
|
|
|
|
useRegisterCommands(
|
|
COMMAND_MENU_SECTIONS.NAVIGATE,
|
|
logsAll
|
|
? [
|
|
{
|
|
id: 'nav-logs-explorer',
|
|
name: 'Logs Explorer',
|
|
route: `/project/${ref}/logs/explorer`,
|
|
defaultHidden: true,
|
|
},
|
|
...(logsCollections
|
|
? ([
|
|
{
|
|
id: 'nav-logs-postgres',
|
|
name: 'Postgres Logs',
|
|
route: `/project/${ref}/logs/postgres-logs`,
|
|
defaultHidden: true,
|
|
},
|
|
{
|
|
id: 'nav-logs-postgrest',
|
|
name: 'PostgREST Logs',
|
|
route: `/project/${ref}/logs/postgrest-logs`,
|
|
defaultHidden: true,
|
|
},
|
|
{
|
|
id: 'nav-logs-pooler',
|
|
name: 'Pooler Logs',
|
|
route: `/project/${ref}/logs/pooler-logs`,
|
|
defaultHidden: true,
|
|
},
|
|
{
|
|
id: 'nav-logs-auth',
|
|
name: 'Auth Logs',
|
|
route: `/project/${ref}/logs/auth-logs`,
|
|
defaultHidden: true,
|
|
},
|
|
{
|
|
id: 'nav-logs-storage',
|
|
name: 'Storage Logs',
|
|
route: `/project/${ref}/logs/storage-logs`,
|
|
defaultHidden: true,
|
|
},
|
|
{
|
|
id: 'nav-logs-realtime',
|
|
name: 'Realtime Logs',
|
|
route: `/project/${ref}/logs/realtime-logs`,
|
|
defaultHidden: true,
|
|
},
|
|
] as IRouteCommand[])
|
|
: []),
|
|
]
|
|
: [],
|
|
{ ...options, deps: [ref] }
|
|
)
|
|
}
|