mirror of
https://github.com/supabase/supabase.git
synced 2026-06-17 21:23:59 +08:00
This PR: * Adds an upgrade flow to the stripe sync engine, allowing users to upgrade to the latest version when it becomes available. * When a new version of sync engine becomes available, users will see an upgrade button instead of install button. * Bumps `supabase-management-js` to version 2.0.2 and `stripe-experiment-sync` to version 1.0.27. * Uses `parseSchemaComment` and related logic from the `stripe-experiment-sync` package in order to avoid writing duplicate code in supabase ui. * Allows installation/uninstallation to timeout after 5 minutes to avoid these operations from getting stuck in case an error occurs in their processing. This allows users to retry the operation, as opposed to the older behaviour where the users always see a spinner on the install/uninstall button and couldn't do anything. * Remove the SSL enforcement admonition as it is no longer required. Sync engine can now be installed with or without SSL enforcement enabled. --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
82 lines
2.4 KiB
TypeScript
82 lines
2.4 KiB
TypeScript
import { AlertCircle, Check, RefreshCwIcon } from 'lucide-react'
|
|
import { SchemaInstallationStatus } from 'stripe-experiment-sync/supabase'
|
|
|
|
import {
|
|
hasInstallError,
|
|
hasUninstallError,
|
|
isInstalled,
|
|
isInstalling,
|
|
isUninstalling,
|
|
} from './stripe-sync-status'
|
|
|
|
export const StatusDisplay = ({
|
|
status,
|
|
isInstallRequested,
|
|
isInstallInitiated,
|
|
isUninstallRequested,
|
|
isUninstallInitiated,
|
|
isUpgrade,
|
|
timedOut,
|
|
}: {
|
|
status: SchemaInstallationStatus
|
|
isInstallRequested: boolean
|
|
isInstallInitiated: boolean
|
|
isUninstallRequested: boolean
|
|
isUninstallInitiated: boolean
|
|
isUpgrade?: boolean
|
|
timedOut: boolean
|
|
}) => {
|
|
const installed = isInstalled(status)
|
|
const installError = hasInstallError(status)
|
|
const uninstallError = hasUninstallError(status)
|
|
const installInProgress = isInstalling(status)
|
|
const uninstallInProgress = isUninstalling(status)
|
|
|
|
const installing = (installInProgress || isInstallRequested || isInstallInitiated) && !timedOut
|
|
const uninstalling =
|
|
(uninstallInProgress || isUninstallRequested || isUninstallInitiated) && !timedOut
|
|
|
|
if (uninstalling) {
|
|
return (
|
|
<span className="flex items-center gap-2 text-foreground-light text-sm">
|
|
<RefreshCwIcon size={14} className="animate-spin text-foreground-lighter" />
|
|
Uninstalling...
|
|
</span>
|
|
)
|
|
}
|
|
if (uninstallError) {
|
|
return (
|
|
<span className="flex items-center gap-2 text-foreground-light text-sm">
|
|
<AlertCircle size={14} className="text-destructive" />
|
|
Uninstallation error
|
|
</span>
|
|
)
|
|
}
|
|
if (installing) {
|
|
return (
|
|
<span className="flex items-center gap-2 text-foreground-light text-sm">
|
|
<RefreshCwIcon size={14} className="animate-spin text-foreground-lighter" />
|
|
{isUpgrade ? 'Upgrading...' : 'Installing...'}
|
|
</span>
|
|
)
|
|
}
|
|
if (installError) {
|
|
return (
|
|
<span className="flex items-center gap-2 text-foreground-light text-sm">
|
|
<AlertCircle size={14} className="text-destructive" />
|
|
{isUpgrade ? 'Upgrade error' : 'Installation error'}
|
|
</span>
|
|
)
|
|
}
|
|
if (installed) {
|
|
return (
|
|
<span className="flex items-center gap-2 text-foreground-light text-sm">
|
|
<Check size={14} strokeWidth={1.5} className="text-brand" /> Installed
|
|
</span>
|
|
)
|
|
}
|
|
return (
|
|
<span className="flex items-center gap-2 text-foreground-light text-sm">Not installed</span>
|
|
)
|
|
}
|