import { Link } from '@tanstack/react-router' import { useParams } from 'common' import { ArrowRightIcon, CheckCircle2Icon, FileWarningIcon, PlusIcon } from 'lucide-react' import { Button, Card, GithubIcon, Skeleton } from 'ui' import { Admonition } from 'ui-patterns/Admonition' import { CollapsibleCardSection } from 'ui-patterns/CollapsibleCardSection' import { EmptyStatePresentational } from 'ui-patterns/EmptyStatePresentational' import { createConfigurationDriftRows, groupMatchedConfigFields, groupUnmanagedConfigFields, type ConfigSectionGroup, type ConfigurationDriftRow, } from './ConfigurationDriftPage.utils' import { AlertError } from '@/components/ui/AlertError' import { DynamicLink } from '@/components/ui/DynamicLink' import { NoPermission } from '@/components/ui/NoPermission' import { useSelectedGitHubConfigDrift } from '@/hooks/misc/useGitHubConfigDrift' export function ConfigurationDriftPageSkeleton() { return (
{['w-28', 'w-44', 'w-52'].map((width) => (
))}
{[0, 1].map((panel) => (
))}
) } function ConfigurationDriftItem({ row, configFileName, }: { row: ConfigurationDriftRow configFileName: string }) { const valueDiff = row.valueDiff return (

{row.settingLabel}

{row.configPath} Drift

Current environment · active

            {valueDiff.dashboardValue}
          

{configFileName} · intended

            {valueDiff.configValue}
          
) } export function ConfigurationDriftResults({ rows, configFileName, }: { rows: ConfigurationDriftRow[] configFileName: string }) { const driftCount = rows.length const issueSummary = `${driftCount} ${driftCount === 1 ? 'setting differs' : 'settings differ'}` return (

{issueSummary}

Current environment values differ from {configFileName}. Update the setting to resolve.

{rows.map((row) => ( ))}
) } function ConfigFieldSection({ title, description, groups, }: { title: string description: string groups: ConfigSectionGroup[] }) { const fieldCount = groups.reduce((count, group) => count + group.rows.length, 0) if (fieldCount === 0) return null return (
{groups.map((group) => (

{group.sectionLabel}

    {group.rows.map((row) => (
  • {row.label} {row.value}
  • ))}
))}
) } export function ConfigurationDriftPage() { const { ref: projectRef = '' } = useParams() const { summary, isReady, isPermissionDenied, isPending, isFetching, isError, error, errorSource, configFileName, refetch, } = useSelectedGitHubConfigDrift() const driftRows = createConfigurationDriftRows(summary.driftedFields, projectRef) const comparableSettingCount = summary.matchedFields.length + driftRows.length const matchedGroups = groupMatchedConfigFields(summary.matchedFields) const unmanagedGroups = groupUnmanagedConfigFields(summary.unmanagedFields) if (isPending) { return } if (isPermissionDenied) { return } if (isError) { const isConfigFileError = errorSource === 'config-file' const subject = isConfigFileError ? configFileName ? `Could not read ${configFileName}` : 'Could not read the config file' : 'Could not check configuration drift' const description = isConfigFileError ? 'Fix the listed values on the selected GitHub branch, then refresh.' : 'Refresh to compare the supported settings with the selected GitHub branch again.' return ( refetch()}> Refresh } /> ) } if (!isReady) { return ( This feature requires a GitHub integration to enable the project to be managed by a config file.

} >
) } const configFile = configFileName ?? 'config file' return (
This project is connected to GitHub. The next commit redeploys{' '} {configFile} and overwrites changes made here. To keep these changes, run supabase config pull locally. } /> {comparableSettingCount === 0 ? (

No comparable settings found

This branch does not define any supported, non-secret settings that can be compared with the current environment.

) : driftRows.length === 0 ? (

All compared settings match

The current environment matches all {summary.matchedFields.length} comparable settings in this branch.

) : ( )}
) }