Files
supabase/apps/studio/components/ui/BannerStack/BannerStackProvider.tsx
T
Mert YEREKAPAN 3d76559cec chore(studio): remove logs.all deprecation banner (#52491)
## Problem

The `logs.all` Management API endpoint retired on September 23, and the
deprecation banner stopped rendering on September 24 because of its
hardcoded expiry. The banner's code is now dead weight in the bundle.

Resolves GROWTH-1104.

## Solution

Removes the banner and everything it pulled in:

- Deletes `BannerLogsAllDeprecation.tsx`, plus its mount effect, expiry
timer, and exposure tracking in `AppBannerWrapper.tsx`.
- Removes `isLogsOrObservabilityPath` (only this banner used it) and its
tests.
- Removes `BANNER_ID.LOGS_ALL_DEPRECATION`.
`BannerStackProvider.test.tsx` used it as an arbitrary ID, so those
tests now use `BANNER_ID.EXPLORER`. The tests themselves are unchanged.
- Removes the `LOGS_ALL_DEPRECATION_2026_09_23` local storage key and
the two `logs_all_deprecation_banner_*` telemetry events.

The dismissal key stays in users' browsers, which is harmless because
nothing reads it anymore.

## Review instructions

1. Open a project's Logs or Observability page on the preview and
confirm no `logs.all` notice appears and the page renders normally.
2. Open an organization's landing page and confirm the Terms of Service
banner still behaves as before.

## Checklist

Check all before review:

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
2026-10-29 14:44:04 -06:00

79 lines
2.6 KiB
TypeScript

import { createContext, useCallback, useContext, useEffect, useRef, useState } from 'react'
export const BANNER_ID = {
INDEX_ADVISOR: 'index-advisor-banner',
TABLE_EDITOR_QUEUE_OPERATIONS: 'table-editor-queue-operations-banner',
RLS_EVENT_TRIGGER: 'rls-event-trigger-banner',
FREE_MICRO_UPGRADE: 'free-micro-upgrade-banner',
TERMS_OF_SERVICE_UPDATE: 'terms-of-service-update-banner',
EXPLORER: 'explorer-banner',
} as const
export type BannerId = (typeof BANNER_ID)[keyof typeof BANNER_ID]
export interface Banner {
id: BannerId
content: React.ReactNode
isDismissed: boolean
priority?: number
onDismiss?: () => void
}
interface BannerStackContextType {
banners: Banner[]
addBanner: (banner: Banner) => void
dismissBanner: (id: BannerId) => void
}
const BannerStackContext = createContext<BannerStackContextType | undefined>(undefined)
export const BannerStackProvider = ({ children }: { children: React.ReactNode }) => {
const [banners, setBanners] = useState<Banner[]>([])
const removalTimeouts = useRef(new Set<ReturnType<typeof setTimeout>>())
useEffect(() => {
const timeouts = removalTimeouts.current
return () => {
timeouts.forEach(clearTimeout)
timeouts.clear()
}
}, [])
const addBanner = useCallback((banner: Banner) => {
setBanners((prev) => {
const existingIndex = prev.findIndex((b) => b.id === banner.id)
if (existingIndex !== -1) {
if (!prev[existingIndex].isDismissed) return prev
const revived = [...prev]
revived[existingIndex] = banner
return revived.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))
}
const newBanners = [...prev, banner]
return newBanners.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))
})
}, [])
const dismissBanner = useCallback((id: string) => {
setBanners((prev) => prev.map((b) => (b.id === id ? { ...b, isDismissed: true } : b)))
const timeout = setTimeout(() => {
removalTimeouts.current.delete(timeout)
// A later addBanner can revive this id before the exit animation
// finishes. Drop it only if it is still dismissed.
setBanners((prev) => prev.filter((b) => b.id !== id || !b.isDismissed))
}, 300)
removalTimeouts.current.add(timeout)
}, [])
return (
<BannerStackContext.Provider value={{ banners, addBanner, dismissBanner }}>
{children}
</BannerStackContext.Provider>
)
}
export const useBannerStack = () => {
const context = useContext(BannerStackContext)
if (!context) throw new Error('useBannerStack must be used within BannerStackProvider')
return context
}