mirror of
https://github.com/supabase/supabase.git
synced 2026-12-05 16:09:06 +00:00
## Context For upgrading a project's Postgres version, the eligibility check returns blockers if a project has active pipelines running. However, the notices are currently confusing and not actionable from a user's POV for these reasons: - The warnings mention the slot name in the title, but as a user i've no idea what slot names these are referring to - There's no CTA as a user to action on to unblock myself - There's multiple warnings due to each replication slot that the pipelines take up, although they all point to the same reason that pipelines just needs to be stopped before upgrading - Example here if i have 3 active pipelines: I get 10 warnings here <img width="500" alt="image" src="https://github.com/user-attachments/assets/c4d99cd4-df3b-4e8e-90cd-896c0f2fa52b" /> Am opting to consolidate all Pipelines related upgrade warnings into just one row as such, by grouping them if the upgrade eligibility error type is `active_replication_slot` and the slot name begins with `supabase_etl_`. Added a "Manage" CTA as well that brings users to the Pipelines page <img width="799" height="234" alt="image" src="https://github.com/user-attachments/assets/50a0c64a-6afe-44e2-9bf8-a21e8ecfc47a" /> Also small nit but this PR fixes the weird list decorator in the rows too <img width="165" height="81" alt="image" src="https://github.com/user-attachments/assets/8c0a0ff6-225f-48d1-a25f-8ffa9e65533c" />
71 lines
2.7 KiB
TypeScript
71 lines
2.7 KiB
TypeScript
import { useQuery } from '@tanstack/react-query'
|
|
import { components } from 'api-types'
|
|
import { IS_PLATFORM } from 'common'
|
|
|
|
import { configKeys } from './keys'
|
|
import { get, handleError, unguarded } from '@/data/fetchers'
|
|
import { useProjectDetailQuery } from '@/data/projects/project-detail-query'
|
|
import { PROJECT_STATUS } from '@/lib/constants/infrastructure'
|
|
import type { StudioError } from '@/lib/errors/studio-errors'
|
|
import type { UseCustomQueryOptions } from '@/types'
|
|
|
|
export type ProjectUpgradeTargetVersion = { postgres_version: string; release_channel: string }
|
|
export type ProjectUpgradeEligibilityVariables = { projectRef?: string }
|
|
export type ProjectUpgradeEligibilityResponse =
|
|
components['schemas']['ProjectUpgradeEligibilityResponse_Output']
|
|
export type ProjectUpgradeEligibilityValidationError =
|
|
ProjectUpgradeEligibilityResponse['validation_errors'][number]
|
|
export type ProjectUpgradeEligibilityWarning = ProjectUpgradeEligibilityResponse['warnings'][number]
|
|
|
|
/**
|
|
* Fetches upgrade eligibility information for a project.
|
|
*
|
|
* @param projectRef - The project's reference identifier
|
|
* @returns The project upgrade eligibility response, or `undefined` if no data was returned
|
|
* @throws Error if `projectRef` is not provided
|
|
*/
|
|
export async function getProjectUpgradeEligibility(
|
|
{ projectRef }: ProjectUpgradeEligibilityVariables,
|
|
signal?: AbortSignal
|
|
): Promise<ProjectUpgradeEligibilityResponse | undefined> {
|
|
if (!projectRef) throw new Error('projectRef is required')
|
|
|
|
const { data, error } = await get('/v1/projects/{ref}/upgrade/eligibility', {
|
|
params: { path: { ref: projectRef } },
|
|
signal,
|
|
grant: unguarded.migrating,
|
|
})
|
|
|
|
if (error) handleError(error)
|
|
|
|
return data as ProjectUpgradeEligibilityResponse | undefined
|
|
}
|
|
|
|
export type ProjectUpgradeEligibilityData = Awaited<ReturnType<typeof getProjectUpgradeEligibility>>
|
|
export type ProjectUpgradeEligibilityError = StudioError
|
|
|
|
export const useProjectUpgradeEligibilityQuery = <TData = ProjectUpgradeEligibilityData>(
|
|
{ projectRef }: ProjectUpgradeEligibilityVariables,
|
|
{
|
|
enabled = true,
|
|
...options
|
|
}: UseCustomQueryOptions<
|
|
ProjectUpgradeEligibilityData,
|
|
ProjectUpgradeEligibilityError,
|
|
TData
|
|
> = {}
|
|
) => {
|
|
const { data: project } = useProjectDetailQuery({ ref: projectRef })
|
|
return useQuery<ProjectUpgradeEligibilityData, ProjectUpgradeEligibilityError, TData>({
|
|
queryKey: configKeys.upgradeEligibility(projectRef),
|
|
queryFn: ({ signal }) => getProjectUpgradeEligibility({ projectRef }, signal),
|
|
enabled:
|
|
enabled &&
|
|
project !== undefined &&
|
|
project.status === PROJECT_STATUS.ACTIVE_HEALTHY &&
|
|
typeof projectRef !== 'undefined' &&
|
|
IS_PLATFORM,
|
|
...options,
|
|
})
|
|
}
|