mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
fix: allow branch to be paused and restarted (#40884)
* fix: allow branch to be paused and restarted * fix: enable pause button on branches * chore: remove unnecessary query to get project detail
This commit is contained in:
1 parent
b698230349
commit
d02926a68f
2 files changed
+57
-56
No files matched your search
@@ -34,8 +34,7 @@ export const General = () => {
|
||||
// [Joshen] Need to refactor to use RHF so we don't need manual error handlers like this
|
||||
const [nameError, setNameError] = useState<string>()
|
||||
|
||||
const { data: parentProject } = useProjectDetailQuery({ ref: project?.parent_project_ref })
|
||||
const isBranch = parentProject !== undefined
|
||||
const isBranch = Boolean(project?.parent_project_ref)
|
||||
|
||||
const { projectSettingsRestartProject } = useIsFeatureEnabled([
|
||||
'project_settings:restart_project',
|
||||
@@ -81,7 +80,10 @@ export const General = () => {
|
||||
<AlertDescription_Shadcn_>
|
||||
Certain settings are not available while you're on a preview branch. To adjust your
|
||||
project settings, you may return to your{' '}
|
||||
<Link href={`/project/${parentProject.ref}/settings/general`} className="text-brand">
|
||||
<Link
|
||||
href={`/project/${project?.parent_project_ref}/settings/general`}
|
||||
className="text-brand"
|
||||
>
|
||||
main branch
|
||||
</Link>
|
||||
.
|
||||
@@ -135,66 +137,64 @@ export const General = () => {
|
||||
}}
|
||||
</Form>
|
||||
)}
|
||||
<div className="mt-6" id="restart-project">
|
||||
<FormPanel>
|
||||
<div className="flex flex-col px-8 py-4">
|
||||
<div className="flex flex-col @lg:flex-row @lg:justify-between @lg:items-center gap-4">
|
||||
<div>
|
||||
<p className="text-sm">
|
||||
{projectSettingsRestartProject ? 'Restart project' : 'Restart database'}
|
||||
</p>
|
||||
<div className="max-w-[420px]">
|
||||
<p className="text-sm text-foreground-light">
|
||||
Your project will not be available for a few minutes.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<RestartServerButton />
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="flex w-full flex-col @lg:flex-row @lg:justify-between @lg:items-center gap-4 px-8 py-4"
|
||||
id="pause-project"
|
||||
>
|
||||
<div>
|
||||
<p className="text-sm">Pause project</p>
|
||||
<div className="max-w-[420px]">
|
||||
<p className="text-sm text-foreground-light">
|
||||
Your project will not be accessible while it is paused.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<PauseProjectButton />
|
||||
</div>
|
||||
</FormPanel>
|
||||
</div>
|
||||
{!isBranch && (
|
||||
<>
|
||||
<div className="mt-6" id="restart-project">
|
||||
<FormPanel>
|
||||
<div className="flex flex-col px-8 py-4">
|
||||
<div className="flex flex-col @lg:flex-row @lg:justify-between @lg:items-center gap-4">
|
||||
<div className="mt-6">
|
||||
<Panel>
|
||||
<Panel.Content>
|
||||
<div className="flex flex-col @lg:flex-row @lg:justify-between @lg:items-center gap-4">
|
||||
<div className="flex space-x-4">
|
||||
<BarChart2 strokeWidth={2} />
|
||||
<div>
|
||||
<p className="text-sm">
|
||||
{projectSettingsRestartProject ? 'Restart project' : 'Restart database'}
|
||||
<p className="text-sm">Project usage statistics have been moved</p>
|
||||
<p className="text-foreground-light text-sm">
|
||||
You may view your project's usage under your organization's settings
|
||||
</p>
|
||||
<div className="max-w-[420px]">
|
||||
<p className="text-sm text-foreground-light">
|
||||
Your project will not be available for a few minutes.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<RestartServerButton />
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="flex w-full flex-col @lg:flex-row @lg:justify-between @lg:items-center gap-4 px-8 py-4"
|
||||
id="pause-project"
|
||||
>
|
||||
<div>
|
||||
<p className="text-sm">Pause project</p>
|
||||
<div className="max-w-[420px]">
|
||||
<p className="text-sm text-foreground-light">
|
||||
Your project will not be accessible while it is paused.
|
||||
</p>
|
||||
</div>
|
||||
<Button asChild type="default">
|
||||
<Link href={`/org/${organization?.slug}/usage?projectRef=${project?.ref}`}>
|
||||
View project usage
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
<PauseProjectButton />
|
||||
</div>
|
||||
</FormPanel>
|
||||
</div>
|
||||
<div className="mt-6">
|
||||
<Panel>
|
||||
<Panel.Content>
|
||||
<div className="flex flex-col @lg:flex-row @lg:justify-between @lg:items-center gap-4">
|
||||
<div className="flex space-x-4">
|
||||
<BarChart2 strokeWidth={2} />
|
||||
<div>
|
||||
<p className="text-sm">Project usage statistics have been moved</p>
|
||||
<p className="text-foreground-light text-sm">
|
||||
You may view your project's usage under your organization's settings
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<Button asChild type="default">
|
||||
<Link href={`/org/${organization?.slug}/usage?projectRef=${project?.ref}`}>
|
||||
View project usage
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Panel.Content>
|
||||
</Panel>
|
||||
</div>
|
||||
</>
|
||||
</Panel.Content>
|
||||
</Panel>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
+2
-1
@@ -32,7 +32,8 @@ const PauseProjectButton = () => {
|
||||
|
||||
const isAwsK8s = useIsAwsK8sCloudProvider()
|
||||
const isFreePlan = organization?.plan.id === 'free'
|
||||
const isPaidAndNotAwsK8s = !isFreePlan && !isAwsK8s
|
||||
const isBranch = Boolean(project?.parent_project_ref)
|
||||
const isPaidAndNotAwsK8s = !isBranch && !isFreePlan && !isAwsK8s
|
||||
|
||||
const { mutate: pauseProject, isPending: isPausing } = useProjectPauseMutation({
|
||||
onSuccess: (_, variables) => {
|
||||
|
||||
Reference in new issue
Block a user