mirror of
https://github.com/supabase/supabase.git
synced 2026-09-08 10:59:38 +08:00
<!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## Stack Draft stack extracted from `docs/monitoring`. Merge bottom-up. The troubleshooting *catalog* rewrite (`content/troubleshooting` and the Diagnosing UI) stays out of scope. 1. #49503 move inspect and advisors 2. #49501 split Studio logs from ClickHouse queries 3. #49500 treat reports as signal dashboards 4. #49502 add Observe the data hub 5. #49506 add agent setup components 6. #49504 add hire-an-agent templates 7. **#49505** restructure observability nav, overview, Detecting, and flatten Observe the data ← **this PR** ## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Docs update. Top layer in the observability stack. ## What is the current behavior? The section is still titled Monitoring and Debugging, with a Debugging / Monitoring split that does not match the new pages. The debugging guide is still the master layer-isolation + symptom table. Observe the data is split into “what data” vs “where to observe it,” which duplicates the source pages. ## What is the new behavior? - Section title is Observability - Overview groups Observe the data, Detect and resolve, Hire an agent, and Export - **Observe the data is flattened by source.** Logs, Metrics API, Database, Advisors, and Reports each list where to read that source. There is no separate MCP/API/CLI/Studio nav group. - **Observe vs Detecting:** Observe is the catalog (what exists, how to access it). Detecting is how to *use* those sources to pick up a Health / Security / Performance / Usage signal. Named errors skip to Diagnosing. - Studio Logs sits under Logs. Reports sits beside the other sources. - Troubleshooting stays in the global menu and also appears as Diagnosing under Detect and resolve ## Additional context This is the last PR in the stack. Together the seven PRs reconstruct the `docs/monitoring` observability IA and guide content, without shipping the troubleshooting catalog overhaul. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-a3cb5ece-925b-4046-b58a-5d69e9a9d794?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-a3cb5ece-925b-4046-b58a-5d69e9a9d794&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Saxon Fletcher <SaxonF@users.noreply.github.com> Co-authored-by: Nik Richers <nik@validmind.ai>
252 lines
7.9 KiB
TypeScript
252 lines
7.9 KiB
TypeScript
import { ChevronDown } from 'lucide-react'
|
|
import { useTheme } from 'next-themes'
|
|
import Image from 'next/legacy/image'
|
|
import Link from 'next/link'
|
|
import { usePathname } from 'next/navigation'
|
|
import { Accordion } from 'radix-ui'
|
|
import React, { useEffect, useRef } from 'react'
|
|
|
|
import MenuIconPicker from './MenuIconPicker'
|
|
|
|
type NavAccordionItem = {
|
|
url?: string
|
|
items?: NavAccordionItem[]
|
|
}
|
|
|
|
function hasActiveDescendant(item: NavAccordionItem, pathname: string): boolean {
|
|
if (item.url === pathname) return true
|
|
return item.items?.some((child) => hasActiveDescendant(child, pathname)) ?? false
|
|
}
|
|
|
|
const HeaderLink = React.memo(function HeaderLink(props: {
|
|
title: string
|
|
id: string
|
|
url: string
|
|
}) {
|
|
const pathname = usePathname()
|
|
|
|
return (
|
|
<span
|
|
className={[
|
|
' ',
|
|
!props.title && 'capitalize',
|
|
props.url === pathname ? 'text-brand-link' : 'hover:text-brand-link text-foreground',
|
|
].join(' ')}
|
|
>
|
|
{props.title ?? props.id}
|
|
</span>
|
|
)
|
|
})
|
|
|
|
const ContentAccordionLink = React.memo(function ContentAccordionLink(props: any) {
|
|
const pathname = usePathname()
|
|
const { resolvedTheme } = useTheme()
|
|
const activeItem = props.subItem.url === pathname
|
|
const activeItemRef = useRef<HTMLLIElement>(null)
|
|
|
|
const isChildActive =
|
|
props.subItem.items &&
|
|
props.subItem.items.some((child: NavAccordionItem) => hasActiveDescendant(child, pathname))
|
|
|
|
const LinkContainer = (props) => {
|
|
const isExternal = props.url.startsWith('https://')
|
|
|
|
return (
|
|
<Link
|
|
href={props.url}
|
|
className={props.className}
|
|
target={isExternal ? '_blank' : undefined}
|
|
rel={isExternal ? 'noopener noreferrer' : undefined}
|
|
>
|
|
{props.children}
|
|
</Link>
|
|
)
|
|
}
|
|
|
|
useEffect(() => {
|
|
// scroll to active item
|
|
if (activeItem && activeItemRef.current) {
|
|
// this is a hack, but seems a common one on Stackoverflow
|
|
setTimeout(() => {
|
|
activeItemRef.current?.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
|
|
}, 0)
|
|
}
|
|
})
|
|
return (
|
|
<>
|
|
{props.subItemIndex === 0 && (
|
|
<>
|
|
<div className="h-px w-full bg-border my-3"></div>
|
|
<span className="font-mono text-xs uppercase text-foreground font-medium tracking-wider">
|
|
{props.parent.name}
|
|
</span>
|
|
</>
|
|
)}
|
|
{props.subItem.items && props.subItem.items.length > 0 ? (
|
|
<Accordion.Root
|
|
collapsible
|
|
type="single"
|
|
className="space-y-0.5"
|
|
defaultValue={isChildActive ? props.subItem.url : undefined}
|
|
>
|
|
<Accordion.Item key={props.subItem.url || props.subItem.name} value={props.subItem.url}>
|
|
<Accordion.Trigger
|
|
className={[
|
|
'flex items-center gap-2 w-full',
|
|
'cursor-pointer transition text-sm',
|
|
activeItem
|
|
? 'text-brand-link font-medium'
|
|
: 'hover:text-foreground text-foreground-lighter',
|
|
].join(' ')}
|
|
>
|
|
<span className="flex items-center justify-between w-full">
|
|
<div className="flex items-center gap-2">
|
|
{props.subItem.icon && (
|
|
<Image
|
|
alt={props.subItem.name}
|
|
src={`${props.subItem.icon}${!resolvedTheme?.includes('dark') ? '-light' : ''}.svg`}
|
|
width={15}
|
|
height={15}
|
|
/>
|
|
)}
|
|
{props.subItem.name}
|
|
</div>
|
|
<ChevronDown className="w-4 h-4 transition-transform data-open-parent:rotate-180" />
|
|
</span>
|
|
</Accordion.Trigger>
|
|
<Accordion.Content className="transition data-open:animate-slide-down data-closed:animate-slide-up ml-2">
|
|
{props.subItem.items
|
|
.filter((subItem) => subItem.enabled !== false)
|
|
.map((subSubItem) => {
|
|
if (subSubItem.items && subSubItem.items.length > 0) {
|
|
return (
|
|
<ContentAccordionLink
|
|
key={subSubItem.name}
|
|
subItem={subSubItem}
|
|
subItemIndex={-1}
|
|
parent={props.subItem}
|
|
/>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<li key={`${props.subItem.name}-${subSubItem.url}`}>
|
|
<Link
|
|
href={`${subSubItem.url}`}
|
|
className={[
|
|
'cursor-pointer transition text-sm',
|
|
subSubItem.url === pathname
|
|
? 'text-brand-link'
|
|
: 'hover:text-brand-link text-foreground-lighter',
|
|
].join(' ')}
|
|
>
|
|
{subSubItem.name}
|
|
</Link>
|
|
</li>
|
|
)
|
|
})}
|
|
</Accordion.Content>
|
|
</Accordion.Item>
|
|
</Accordion.Root>
|
|
) : (
|
|
<li key={props.subItem.name} ref={activeItem ? activeItemRef : null}>
|
|
<LinkContainer
|
|
url={props.subItem.url}
|
|
className={[
|
|
'flex items-center gap-2',
|
|
'cursor-pointer transition text-sm',
|
|
activeItem
|
|
? 'text-brand-link font-medium'
|
|
: 'hover:text-foreground text-foreground-lighter',
|
|
].join(' ')}
|
|
parent={props.subItem.parent}
|
|
>
|
|
<div className="flex items-center gap-2">
|
|
{props.subItem.icon && (
|
|
<Image
|
|
alt={props.subItem.name}
|
|
src={`${props.subItem.icon}${!resolvedTheme?.includes('dark') ? '-light' : ''}.svg`}
|
|
width={15}
|
|
height={15}
|
|
/>
|
|
)}
|
|
{props.subItem.name}
|
|
</div>
|
|
</LinkContainer>
|
|
</li>
|
|
)}
|
|
</>
|
|
)
|
|
})
|
|
|
|
const ContentLink = React.memo(function ContentLink(props: any) {
|
|
const pathname = usePathname()
|
|
|
|
return (
|
|
<li className="mb-1.5">
|
|
<Link
|
|
href={props.url}
|
|
className={[
|
|
'cursor-pointer transition text-sm',
|
|
props.url === pathname
|
|
? 'text-brand-link'
|
|
: 'hover:text-foreground text-foreground-lighter',
|
|
].join(' ')}
|
|
>
|
|
{props.icon && (
|
|
<Image alt={props.icon} width={12} height={12} src={`${pathname}${props.icon}`} />
|
|
)}
|
|
{props.name}
|
|
</Link>
|
|
</li>
|
|
)
|
|
})
|
|
|
|
const Content = (props) => {
|
|
const { menu, id } = props
|
|
|
|
if (menu.enabled === false) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<ul className={['relative w-full flex flex-col gap-0 pb-5'].join(' ')}>
|
|
<Link href={menu.url ?? ''}>
|
|
<div className="flex items-center gap-3 my-3 text-brand-link">
|
|
<MenuIconPicker icon={menu.icon} />
|
|
<HeaderLink title={menu.title} url={menu.url} id={id} />
|
|
</div>
|
|
</Link>
|
|
|
|
{menu.items
|
|
.filter((item) => item.enabled !== false)
|
|
.map((x) => {
|
|
return (
|
|
<div key={x.name}>
|
|
{x.items && x.items.length > 0 ? (
|
|
<div className="flex flex-col gap-2.5">
|
|
{x.items
|
|
.filter((item) => item.enabled !== false)
|
|
.map((subItem, subItemIndex) => {
|
|
return (
|
|
<ContentAccordionLink
|
|
key={subItem.name}
|
|
subItem={subItem}
|
|
subItemIndex={subItemIndex}
|
|
parent={x}
|
|
/>
|
|
)
|
|
})}
|
|
</div>
|
|
) : x.url ? (
|
|
<ContentLink url={x.url} icon={x.icon} name={x.name} key={x.name} />
|
|
) : null}
|
|
</div>
|
|
)
|
|
})}
|
|
</ul>
|
|
)
|
|
}
|
|
|
|
export default React.memo(Content)
|