Files
supabase/apps/studio/components/ui/BannerStack/Banners/BannerIndexAdvisor.tsx
kemal.earth ce48c64f68 feat(studio): generic observability banner (#40957)
* 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
2025-12-04 11:42:31 +00:00

46 lines
1.6 KiB
TypeScript

import { BannerCard } from '../BannerCard'
import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
import { LOCAL_STORAGE_KEYS } from 'common'
import { useParams } from 'common/hooks'
import { Lightbulb } from 'lucide-react'
import { EnableIndexAdvisorButton } from 'components/interfaces/QueryPerformance/IndexAdvisor/EnableIndexAdvisorButton'
import { useBannerStack } from '../BannerStackProvider'
import { useTrack } from 'lib/telemetry/track'
export const BannerIndexAdvisor = () => {
const track = useTrack()
const { ref } = useParams()
const { dismissBanner } = useBannerStack()
const [, setIsDismissed] = useLocalStorageQuery(
LOCAL_STORAGE_KEYS.INDEX_ADVISOR_NOTICE_DISMISSED(ref ?? ''),
false
)
return (
<BannerCard
onDismiss={() => {
setIsDismissed(true)
dismissBanner('index-advisor-banner')
track('index_advisor_banner_dismiss_button_clicked')
}}
>
<div className="flex flex-col gap-y-4">
<div className="flex flex-col gap-y-2 items-start">
<div className="p-2 rounded-lg bg-warning-200 text-warning dark:bg-warning-300">
<Lightbulb size={16} />
</div>
</div>
<div className="flex flex-col gap-y-1 mb-2">
<p className="text-sm font-medium">Enable Index Advisor</p>
<p className="text-xs text-foreground-lighter text-balance">
Recommends indexes to improve query performance.
</p>
</div>
<div className="flex gap-2">
<EnableIndexAdvisorButton />
</div>
</div>
</BannerCard>
)
}