Files
supabase/apps/studio/components/layouts/AppLayout/NoticeBanner.tsx
Charis 5a01291c23 feat(studio): smart incident banner targeting (#43112)
Feature enhancement — smarter incident banner targeting logic

## What is the current behavior?

Displaying the incident banner requires toggling a flag or environment
variable. Banners are shown to all users regardless of whether their
projects are in affected regions or whether the incident affects project
creation.

## What is the new behavior?

Banner visibility is now driven by `show_banner` metadata from the
StatusPage API — no manual flag or env var toggle needed. Per-user
targeting is then applied:
- Users with projects only see the banner when they have a database in
an affected region
- Users without projects only see the banner when the incident affects
project creation

Incident responses are enriched with cache data (`affected_regions`,
`affects_project_creation`) fetched from a Supabase table. Visibility
logic is extracted into a dedicated hook and pure utility function,
backed by unit tests.

## Additional context

Resolves FE-2562
2026-02-25 17:18:33 +00:00

45 lines
1.3 KiB
TypeScript

import { LOCAL_STORAGE_KEYS } from 'common'
import { useRouter } from 'next/router'
import { TimestampInfo } from 'ui-patterns'
import { HeaderBanner } from '@/components/interfaces/Organization/HeaderBanner'
import { InlineLink } from '@/components/ui/InlineLink'
import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
/**
* Used to display urgent notices that apply for all users, such as maintenance windows.
*/
export const NoticeBanner = () => {
const router = useRouter()
const [bannerAcknowledged, setBannerAcknowledged, { isSuccess }] = useLocalStorageQuery(
LOCAL_STORAGE_KEYS.MAINTENANCE_WINDOW_BANNER,
false
)
if (router.pathname.includes('sign-in') || !isSuccess || bannerAcknowledged) {
return null
}
return (
<HeaderBanner
variant="warning"
title="Upcoming Dashboard and Management API maintenance"
description={
<>
<TimestampInfo
className="text-sm"
utcTimestamp={1768530600000}
label="02:30 UTC on Jan 16, 2026"
/>
.{' '}
<InlineLink href="https://status.supabase.com/incidents/lg4j8mcn50zb">
Learn more
</InlineLink>
</>
}
onDismiss={() => setBannerAcknowledged(true)}
/>
)
}