Files
Charis 0daafca2ca feat(studio): status page banner (incident / maintenance / upcoming) (#51044)
## Summary

* Adds a new global status banner (`StatusBanner`) driven by the
[incident.io](<http://incident.io>) status page data, showing at most
one of: an active incident, in-progress maintenance, or upcoming
maintenance, in that priority order.
* All three types are independently dismissible (persisted to a new
localStorage key, `status-banner-dismissed-keys`); dismissal hides the
banner for items still active, and a new incident reappears even if a
related item was previously dismissed.
* Only shows to users who are actually affected (based on their
projects' regions) or when region data is incomplete (fails open), and
is bypassed entirely by the existing emergency incident override.
* Behind the existing `incidentIoStatusPage` ConfigCat flag —
`AppBannerWrapper` renders this new banner instead of the legacy
`StatusPageBanner` only when the flag is on; default behavior is
unchanged.
* This is PR 5b in a stacked series for Linear
[FE-4057](https://linear.app/supabase/issue/FE-4057) — see that issue
for full design context.

## Test plan

* New unit tests (`StatusBanner.utils.test.ts`) covering
banner-selection priority, dismissal-key handling, and copy generation
* New MSW component test (`StatusBanner.test.tsx`) covering loading
state, dismiss-and-persist, and the emergency-override path
* `pnpm --filter studio run typecheck`, `lint:ratchet`, `pnpm knip
--workspace apps/studio`, `pnpm test:prettier`, and relevant vitest
suites all pass

🤖 Generated with [Claude Code](<https://claude.com/claude-code>)

Co-Authored-By: Claude
[noreply@anthropic.com](<mailto:noreply@anthropic.com>)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added status banners for relevant incidents and scheduled maintenance,
including incident details, maintenance timing, and links to the status
page.
* Banners can be dismissed, and dismissed items stay hidden while new
incidents or maintenance updates can still appear.
* Upcoming maintenance banners appear within the relevant lead time, and
maintenance timing is shown when available.
* Emergency overrides display a warning banner without a dismiss option.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-29 18:09:47 -04:00

109 lines
2.8 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import dayjs from 'dayjs'
import type { ReactNode } from 'react'
import { TimestampInfo } from 'ui-patterns/TimestampInfo'
import { getBannerCopy, type BannerSelection } from './StatusBanner.utils'
import { useStatusBanner } from './useStatusBanner'
import { HeaderBanner } from '@/components/interfaces/Organization/HeaderBanner'
import { InlineLink } from '@/components/ui/InlineLink'
const OVERRIDE_TITLE = 'We are investigating a technical issue'
const TIMESTAMP_FORMAT = 'DD MMM, HH:mm'
function formatTimestampLabel(value: string): string {
return dayjs(value).format(TIMESTAMP_FORMAT)
}
function getBannerDescription({
selection,
description,
pageUrl,
}: {
selection: BannerSelection
description: string
pageUrl: string
}): ReactNode {
if (selection.kind === 'incident') {
return (
<>
{description} <InlineLink href={pageUrl}>Status page</InlineLink>
</>
)
}
if (selection.kind === 'maintenance') {
const { scheduledEndAt } = selection.item
const hasFutureEnd = scheduledEndAt !== null && new Date(scheduledEndAt).getTime() > Date.now()
return (
<>
{description}
{hasFutureEnd && (
<>
{' '}
(
<TimestampInfo
utcTimestamp={scheduledEndAt}
label={formatTimestampLabel(scheduledEndAt)}
/>
)
</>
)}
</>
)
}
const { startsAt, endsAt } = selection.item
return (
<>
{description}
{startsAt !== null && endsAt !== null && (
<>
{' '}
(<TimestampInfo utcTimestamp={startsAt} label={formatTimestampLabel(startsAt)} />
{' – '}
<TimestampInfo utcTimestamp={endsAt} label={formatTimestampLabel(endsAt)} />)
</>
)}
</>
)
}
/**
* Global banner for incident.io status page items — a relevant active incident,
* in-progress maintenance, or upcoming maintenance, in that priority order.
* Replaces the legacy StatusPageBanner while `incidentIoStatusPage` is on.
*/
export const StatusBanner = () => {
const state = useStatusBanner()
if (state.type === 'hidden') return null
if (state.type === 'override') {
return (
<HeaderBanner
variant="warning"
title={OVERRIDE_TITLE}
description={
<>
Follow the <InlineLink href="https://status.supabase.com">status page</InlineLink> for
updates
</>
}
/>
)
}
const { selection, pageUrl, onDismiss } = state
const { title, description } = getBannerCopy(selection)
return (
<HeaderBanner
variant={selection.kind === 'incident' ? 'warning' : 'note'}
title={title}
description={getBannerDescription({ selection, description, pageUrl })}
onDismiss={onDismiss}
/>
)
}