mirror of
https://github.com/supabase/supabase.git
synced 2026-10-13 05:09:12 +03:00
* feat: more generic observability banner on db report * feat: try popup in corner * feat: tidy up and fix up event as well * feat: add event for dismiss as well * feat: add supplementary link at bottom of reports * fix: sizing of fonts * feat: banner stack approach * fix: isIndexAdvisorAvailable dep * chore: remove unused import for old banner * feat: remove unused isDismissed * chore: remove unused cn * chore: change prio on query perf page * chore: remove unused sendEvent * chore: better useEffect cleanup * chore: remove unused index advisor notice * fix: priority of banner stack * fix: first time loader flickering * chore: lowercase the word Free * feat: add IS_PLATFORM to make sure metrics api banner is scoped to platform * chore: another copy update for observability link * fix: telemetry keys to match styleguide * fix: use the correct way to apply events * feat: add events for index advisor banner too * chore: delete unused old banner * fix: dismiss buttons not working * feat: add extra event to enable index advisor
121 lines
3.6 KiB
TypeScript
121 lines
3.6 KiB
TypeScript
import { PropsWithChildren, useEffect } from 'react'
|
|
import { useParams } from 'common'
|
|
import { LOCAL_STORAGE_KEYS, IS_PLATFORM } from 'common'
|
|
import { UnknownInterface } from 'components/ui/UnknownInterface'
|
|
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
|
|
import { withAuth } from 'hooks/misc/withAuth'
|
|
import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
|
|
import { BannerMetricsAPI } from 'components/ui/BannerStack/Banners/BannerMetricsAPI'
|
|
import { ProjectLayout } from '../ProjectLayout'
|
|
import ObservabilityMenu from './ObservabilityMenu'
|
|
import { BannerStackProvider, useBannerStack } from 'components/ui/BannerStack/BannerStackProvider'
|
|
import { BannerStack } from 'components/ui/BannerStack/BannerStack'
|
|
import { usePathname } from 'next/navigation'
|
|
import { useIndexAdvisorStatus } from 'components/interfaces/QueryPerformance/hooks/useIsIndexAdvisorStatus'
|
|
import { BannerIndexAdvisor } from 'components/ui/BannerStack/Banners/BannerIndexAdvisor'
|
|
import { useRef } from 'react'
|
|
|
|
interface ObservabilityLayoutProps {
|
|
title?: string
|
|
}
|
|
|
|
const ObservabilityLayoutContent = ({
|
|
title,
|
|
children,
|
|
}: PropsWithChildren<ObservabilityLayoutProps>) => {
|
|
const { ref } = useParams()
|
|
const pathname = usePathname()
|
|
const { addBanner, dismissBanner } = useBannerStack()
|
|
const { isIndexAdvisorAvailable, isIndexAdvisorEnabled } = useIndexAdvisorStatus()
|
|
|
|
const [isMetricsBannerDismissed] = useLocalStorageQuery(
|
|
LOCAL_STORAGE_KEYS.OBSERVABILITY_BANNER_DISMISSED(ref ?? ''),
|
|
false
|
|
)
|
|
|
|
const [isIndexAdvisorBannerDismissed] = useLocalStorageQuery(
|
|
LOCAL_STORAGE_KEYS.INDEX_ADVISOR_NOTICE_DISMISSED(ref ?? ''),
|
|
false
|
|
)
|
|
|
|
useEffect(() => {
|
|
if (!isMetricsBannerDismissed && IS_PLATFORM) {
|
|
addBanner({
|
|
id: 'metrics-api-banner',
|
|
isDismissed: false,
|
|
content: <BannerMetricsAPI />,
|
|
priority: 1,
|
|
})
|
|
} else {
|
|
dismissBanner('metrics-api-banner')
|
|
}
|
|
}, [isMetricsBannerDismissed, addBanner, dismissBanner])
|
|
|
|
const prevPathnameRef = useRef(pathname)
|
|
|
|
useEffect(() => {
|
|
const isQueryPerformancePage = pathname?.includes('/query-performance')
|
|
const wasQueryPerformancePage = prevPathnameRef.current?.includes('/query-performance')
|
|
|
|
if (
|
|
isQueryPerformancePage &&
|
|
isIndexAdvisorAvailable &&
|
|
!isIndexAdvisorEnabled &&
|
|
!isIndexAdvisorBannerDismissed
|
|
) {
|
|
addBanner({
|
|
id: 'index-advisor-banner',
|
|
isDismissed: false,
|
|
content: <BannerIndexAdvisor />,
|
|
priority: 3,
|
|
})
|
|
} else if (isIndexAdvisorBannerDismissed || !isQueryPerformancePage) {
|
|
dismissBanner('index-advisor-banner')
|
|
}
|
|
|
|
prevPathnameRef.current = pathname
|
|
}, [
|
|
pathname,
|
|
isIndexAdvisorAvailable,
|
|
isIndexAdvisorEnabled,
|
|
isIndexAdvisorBannerDismissed,
|
|
addBanner,
|
|
dismissBanner,
|
|
])
|
|
|
|
const { reportsAll } = useIsFeatureEnabled(['reports:all'])
|
|
|
|
if (reportsAll) {
|
|
return (
|
|
<ProjectLayout
|
|
title={title}
|
|
product="Observability"
|
|
productMenu={<ObservabilityMenu />}
|
|
isBlocking={false}
|
|
>
|
|
{children}
|
|
</ProjectLayout>
|
|
)
|
|
} else {
|
|
return <UnknownInterface urlBack={`/project/${ref}`} />
|
|
}
|
|
}
|
|
|
|
const ObservabilityLayout = (props: PropsWithChildren<ObservabilityLayoutProps>) => {
|
|
const { ref } = useParams()
|
|
const { reportsAll } = useIsFeatureEnabled(['reports:all'])
|
|
|
|
if (reportsAll) {
|
|
return (
|
|
<BannerStackProvider>
|
|
<ObservabilityLayoutContent {...props} />
|
|
<BannerStack />
|
|
</BannerStackProvider>
|
|
)
|
|
} else {
|
|
return <UnknownInterface urlBack={`/project/${ref}`} />
|
|
}
|
|
}
|
|
|
|
export default withAuth(ObservabilityLayout)
|