mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
## What kind of change does this PR introduce? Mechanical cleanup on top of the Button default-variant change (#50160). ## What is the current behavior? Many callsites still pass `variant="default"` even though that is now the component default. ## What is the new behavior? Removes redundant static `variant="default"` from legacy `Button` and `ButtonTooltip` callsites. Keeps explicit defaults where they document the API: - `button-default.tsx` and `button-sizes.tsx` demos - `DocsButton`, which pins neutral styling at the wrapper boundary ## To test Studio: - [Auth → Rate Limits](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/auth/rate-limits): dirty the form so Cancel appears; Cancel stays neutral, Save stays green - [Project Settings → API Keys](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/settings/api-keys): `DocsButton` in the header actions stays neutral Design system: - [Design system → Button](https://design-system-git-dnywh-dc924ac1-supabase.vercel.app/design-system/docs/components/button): `button-default` / `button-sizes` still show explicit default styling; Primary (green) is restricted to the Primary section (and `asChild`) WWW: - [www → Brand assets](https://zone-www-dot-com-git-dnywh-dc924ac1-supabase.vercel.app/brand-assets): Download logo kit / Download button kit stay neutral
100 lines
3.5 KiB
TypeScript
100 lines
3.5 KiB
TypeScript
import { SupportCategories } from '@supabase/shared-types/out/constants'
|
|
import { DatabaseUpgradeStatus } from '@supabase/shared-types/out/events'
|
|
import { LOCAL_STORAGE_KEYS, useParams } from 'common'
|
|
import dayjs from 'dayjs'
|
|
import { X } from 'lucide-react'
|
|
import { Button } from 'ui'
|
|
import { Admonition } from 'ui-patterns/Admonition'
|
|
|
|
import { ButtonTooltip } from './ButtonTooltip'
|
|
import { InlineLink } from './InlineLink'
|
|
import { SupportLink } from '@/components/interfaces/Support/SupportLink'
|
|
import { useProjectUpgradingStatusQuery } from '@/data/config/project-upgrade-status-query'
|
|
import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
|
|
import { useShowPostgresUpgradeLogs } from '@/hooks/misc/useShowPostgresUpgradeLogs'
|
|
import { IS_PLATFORM } from '@/lib/constants'
|
|
import { guessLocalTimezone } from '@/lib/dayjs'
|
|
|
|
// [Joshen] Think twice about the category though - it doesn't correspond
|
|
|
|
export const ProjectUpgradeFailedBanner = () => {
|
|
const { ref } = useParams()
|
|
const { data } = useProjectUpgradingStatusQuery({ projectRef: ref }, { enabled: IS_PLATFORM })
|
|
const { status, initiated_at, latest_status_at, error } = data?.databaseUpgradeStatus ?? {}
|
|
const showPostgresUpgradeLogs = useShowPostgresUpgradeLogs()
|
|
|
|
const [dismissedAt, setDismissedAt] = useLocalStorageQuery<string | null>(
|
|
LOCAL_STORAGE_KEYS.PROJECT_UPGRADE_FAILED_BANNER_DISMISSED_AT(ref ?? 'unknown'),
|
|
null
|
|
)
|
|
|
|
const isFailed = status === DatabaseUpgradeStatus.Failed && initiated_at !== dismissedAt
|
|
const initiatedAt = dayjs
|
|
.utc(initiated_at ?? 0)
|
|
.tz(guessLocalTimezone())
|
|
.format('DD MMM YYYY HH:mm:ss')
|
|
|
|
const subject = 'Upgrade failed for project'
|
|
const message = `Upgrade information:\n• Initiated at: ${initiated_at}\n• Error: ${error}`
|
|
|
|
const initiatedAtEncoded = encodeURIComponent(
|
|
dayjs.utc(initiated_at ?? 0).format('YYYY-MM-DDTHH:mm:ss')
|
|
)
|
|
const latestStatusAtEncoded = encodeURIComponent(
|
|
dayjs
|
|
.utc(latest_status_at ?? 0)
|
|
.utcOffset(0)
|
|
.format('YYYY-MM-DDTHH:mm:ss')
|
|
)
|
|
const timestampFilter = `its=${initiatedAtEncoded}&ite=${latestStatusAtEncoded}`
|
|
|
|
if (!isFailed) return null
|
|
|
|
return (
|
|
<div className="max-w-7xl">
|
|
<Admonition
|
|
type="warning"
|
|
title={`Postgres version upgrade was not successful (Initiated at ${initiatedAt})`}
|
|
actions={
|
|
<>
|
|
<Button asChild>
|
|
<SupportLink
|
|
queryParams={{
|
|
category: SupportCategories.DATABASE_UNRESPONSIVE,
|
|
projectRef: ref,
|
|
subject,
|
|
message,
|
|
}}
|
|
>
|
|
Contact support
|
|
</SupportLink>
|
|
</Button>
|
|
<ButtonTooltip
|
|
icon={<X />}
|
|
variant="text"
|
|
className="w-6"
|
|
tooltip={{ content: { side: 'bottom', text: 'Dismiss' } }}
|
|
aria-label="Dismiss upgrade failed banner"
|
|
onClick={() => setDismissedAt(initiated_at ?? null)}
|
|
/>
|
|
</>
|
|
}
|
|
>
|
|
<div>
|
|
Your project and its data are not affected. Please reach out to us via our support form
|
|
for assistance with the upgrade.
|
|
</div>
|
|
{showPostgresUpgradeLogs && (
|
|
<div>
|
|
You may also view logs related to the failed upgrade in your{' '}
|
|
<InlineLink href={`/project/${ref}/logs/pg-upgrade-logs?${timestampFilter}`}>
|
|
project's logs
|
|
</InlineLink>
|
|
.
|
|
</div>
|
|
)}
|
|
</Admonition>
|
|
</div>
|
|
)
|
|
}
|