Files
supabase/apps/studio/components/interfaces/ProjectCreation/ProjectCreationStatusAdmonition.tsx
Charis 53b20cad5e feat(studio): project creation status admonition (#51029)
## Summary

- Adds a new project-creation-form incident warning path behind the
`incidentIoStatusPage` ConfigCat flag (default off — no visible behavior
change until the flag is enabled)
- When the flag is on, reads the new `/api/status-page` endpoint (added
earlier in this stack) instead of the legacy `/api/incident-status`
endpoint, and only fetches the legacy endpoint when the flag is off
- Extracts region-matching logic into `RegionSelector.utils.ts`
(`regionMatches`, `getItemsAffectingProjectCreation`) with unit test
coverage

See Linear FE-4057 for full context and design.

## Test plan

- [x] `pnpm --filter studio run typecheck`
- [x] `pnpm --filter studio run lint:ratchet`
- [x] `pnpm knip --workspace apps/studio`
- [x] `pnpm test:prettier`
- [x] `pnpm --filter studio exec vitest run
components/interfaces/ProjectCreation/RegionSelector.utils.test.ts`
(35/35 passing)

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

* **New Features**
* Project creation displays a warning and links to the status page when
an incident or maintenance event may affect the selected region.
* Status notices match exact regions and broader smart-region groupings;
global project-creation notices are also shown.
* The AI assistant can report visible, active incidents and in-progress
maintenance, including affected components and update details. When
there are no active events, it reports that status.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-29 17:37:01 -04:00

42 lines
1.5 KiB
TypeScript

import { useQuery } from '@tanstack/react-query'
import { Admonition } from 'ui-patterns/Admonition'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import { getItemsAffectingProjectCreation } from './RegionSelector.utils'
import { InlineLink } from '@/components/ui/InlineLink'
import { statusPageQueryOptions } from '@/data/platform/status-page-query'
import { normalizeStatusPage } from '@/lib/status-page/status-page.utils'
export const ProjectCreationStatusAdmonition = ({
selectedRegionCode,
}: {
selectedRegionCode?: string
}) => {
const { data } = useQuery({ ...statusPageQueryOptions(), select: normalizeStatusPage })
if (!data) return null
const items = getItemsAffectingProjectCreation(data.items, selectedRegionCode)
const item = items[0]
if (!item) return null
const isMaintenance = item.kind === 'maintenance'
const isRegionSpecific = item.projectCreationScope?.type === 'regions'
return (
<FormItemLayout layout="horizontal">
<Admonition
type="warning"
title={isMaintenance ? 'Maintenance in progress' : 'Incident in progress'}
description={
<>
{isMaintenance ? 'Maintenance' : 'An incident'} may affect project creation
{isRegionSpecific ? ' in this region' : ''}. Follow updates on{' '}
<InlineLink href={data.pageUrl}>status page</InlineLink>.
</>
}
className="mt-3"
/>
</FormItemLayout>
)
}