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
116 lines
4.3 KiB
TypeScript
116 lines
4.3 KiB
TypeScript
import Link from 'next/link'
|
|
import { Button, Card, CardContent } from 'ui'
|
|
import {
|
|
PageSection,
|
|
PageSectionContent,
|
|
PageSectionDescription,
|
|
PageSectionMeta,
|
|
PageSectionSummary,
|
|
PageSectionTitle,
|
|
} from 'ui-patterns/PageSection'
|
|
|
|
import { PauseProjectButton } from './Infrastructure/PauseProjectButton'
|
|
import { RestartServerButton } from './Infrastructure/RestartServerButton'
|
|
import { ResumeProjectButton } from '@/components/interfaces/Project/ResumeProjectButton'
|
|
import { useProjectPauseStatusQuery } from '@/data/projects/project-pause-status-query'
|
|
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
|
|
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
|
import { PROJECT_STATUS } from '@/lib/constants'
|
|
|
|
export const Project = () => {
|
|
const { data: project } = useSelectedProjectQuery()
|
|
const isBranch = Boolean(project?.parent_project_ref)
|
|
const isPaused = project?.status === PROJECT_STATUS.INACTIVE
|
|
const entityLabel = isBranch ? 'branch' : 'project'
|
|
const entityLabelCapitalized = isBranch ? 'Branch' : 'Project'
|
|
|
|
const { projectSettingsRestartProject } = useIsFeatureEnabled([
|
|
'project_settings:restart_project',
|
|
])
|
|
const {
|
|
data: pauseStatus,
|
|
isError: isPauseStatusError,
|
|
isSuccess: isPauseStatusSuccess,
|
|
} = useProjectPauseStatusQuery({ ref: project?.ref }, { enabled: isPaused })
|
|
|
|
const shouldShowDashboardLink =
|
|
isPaused && (isPauseStatusError || (isPauseStatusSuccess && !pauseStatus.can_restore))
|
|
|
|
const primaryActionLabel = isPaused
|
|
? shouldShowDashboardLink
|
|
? `View ${entityLabel} dashboard`
|
|
: `Resume ${entityLabel}`
|
|
: projectSettingsRestartProject
|
|
? `Restart ${entityLabel}`
|
|
: 'Restart database'
|
|
|
|
const primaryActionDescription = isPaused
|
|
? isPauseStatusSuccess && !pauseStatus.can_restore
|
|
? `This ${entityLabel} can no longer be resumed here. Open the dashboard to download backups and view recovery options.`
|
|
: isPauseStatusError
|
|
? `Open the dashboard to manage this paused ${entityLabel}.`
|
|
: `Bring your paused ${entityLabel} back online.`
|
|
: `Your ${entityLabel} will not be available for a few minutes.`
|
|
|
|
return (
|
|
<>
|
|
<PageSection id="restart-project">
|
|
<PageSectionMeta>
|
|
<PageSectionSummary>
|
|
<PageSectionTitle>{entityLabelCapitalized} availability</PageSectionTitle>
|
|
<PageSectionDescription>
|
|
{isPaused
|
|
? `Resume your paused ${entityLabel} or review recovery options`
|
|
: `Restart or pause your ${entityLabel} when performing maintenance`}
|
|
</PageSectionDescription>
|
|
</PageSectionSummary>
|
|
</PageSectionMeta>
|
|
<PageSectionContent>
|
|
<Card>
|
|
<CardContent>
|
|
<div className="flex flex-col @lg:flex-row @lg:justify-between @lg:items-center gap-4">
|
|
<div>
|
|
<p className="text-sm">{primaryActionLabel}</p>
|
|
<div className="max-w-[420px]">
|
|
<p className="text-sm text-foreground-lighter">{primaryActionDescription}</p>
|
|
</div>
|
|
</div>
|
|
{isPaused ? (
|
|
shouldShowDashboardLink ? (
|
|
<Button asChild>
|
|
<Link href={`/project/${project?.ref}`}>View project dashboard</Link>
|
|
</Button>
|
|
) : (
|
|
<ResumeProjectButton />
|
|
)
|
|
) : (
|
|
<RestartServerButton />
|
|
)}
|
|
</div>
|
|
</CardContent>
|
|
|
|
{!isPaused && (
|
|
<CardContent>
|
|
<div
|
|
className="flex w-full flex-col @lg:flex-row @lg:justify-between @lg:items-center gap-4"
|
|
id="pause-project"
|
|
>
|
|
<div>
|
|
<p className="text-sm">Pause {entityLabel}</p>
|
|
<div className="max-w-[420px]">
|
|
<p className="text-sm text-foreground-lighter">
|
|
Your {entityLabel} will not be accessible while it is paused.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<PauseProjectButton />
|
|
</div>
|
|
</CardContent>
|
|
)}
|
|
</Card>
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
</>
|
|
)
|
|
}
|