Files
supabase/apps/studio/components/layouts/AppLayout/StatusBanner.tsx
Charis fb118a978c fix(studio): link maintenance banner titles to their status page (#54195)
## What

The incident banner links to the status page, but the in-progress and
upcoming maintenance banners had no link.

The maintenance banner titles ("Scheduled maintenance in progress",
"Upcoming scheduled maintenance") now link to that maintenance's own
status page entry (`item.url`).

To support this, `HeaderBanner`'s `title` prop now accepts `ReactNode`
instead of only `string`.
2026-11-27 08:31:48 -05:00

114 lines
2.9 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 (
<>
Follow the <InlineLink href={pageUrl}>status page</InlineLink> for updates
</>
)
}
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.
*/
export const StatusBanner = ({ signedOut = false }: { signedOut?: boolean } = {}) => {
const state = useStatusBanner({ signedOut })
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={
selection.kind === 'incident' ? (
title
) : (
<InlineLink href={selection.item.url}>{title}</InlineLink>
)
}
description={getBannerDescription({ selection, description, pageUrl })}
onDismiss={onDismiss}
/>
)
}