mirror of
https://github.com/supabase/supabase.git
synced 2026-10-10 03:45:06 +03:00
## Context Related to dashboard scalability Previous PR: https://github.com/supabase/supabase/pull/42856 Note: Changes are all feature flagged still and I'm still not entirely convinced with the current UX Will iterate as as go along, and only make this publicly available when we're satisfied with the behaviour Adds a "Dashboard preference" section to the project settings <img width="265" height="740" alt="image" src="https://github.com/user-attachments/assets/6ce1aa19-26c2-47c6-a9c4-595137266631" /> In which users can then select which database they'd like to use for read queries run from the dashboard Note: Everything is local storage for now, but we'd need middleware support if we want to make this setting persist for all users on the project <img width="791" height="434" alt="image" src="https://github.com/user-attachments/assets/e651d6d9-fed4-4da4-b552-c9f93f8d46d3" /> Added a dialog as well to further explain what this implies <img width="610" height="312" alt="image" src="https://github.com/user-attachments/assets/0aa957af-cb51-476f-aa79-8948a7cbe5ae" /> ## To test - Choosing a replica in dashboard preferences will only affect the table editor as thats the only place that's set up so far to use a replica for read queries (I'll need to follow up for other parts of the dashboard in subsequent PRs)
112 lines
4.0 KiB
TypeScript
112 lines
4.0 KiB
TypeScript
import { BarChart2 } from 'lucide-react'
|
|
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 { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
|
|
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
|
|
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
|
|
|
export const Project = () => {
|
|
const { data: project } = useSelectedProjectQuery()
|
|
const { data: organization } = useSelectedOrganizationQuery()
|
|
const isBranch = Boolean(project?.parent_project_ref)
|
|
const { projectSettingsRestartProject } = useIsFeatureEnabled([
|
|
'project_settings:restart_project',
|
|
])
|
|
|
|
return (
|
|
<>
|
|
<PageSection id="restart-project">
|
|
<PageSectionMeta>
|
|
<PageSectionSummary>
|
|
<PageSectionTitle>Project availability</PageSectionTitle>
|
|
<PageSectionDescription>
|
|
Restart or pause your project 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">
|
|
{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>
|
|
</CardContent>
|
|
<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 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>
|
|
</CardContent>
|
|
</Card>
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
|
|
{!isBranch && (
|
|
<PageSection>
|
|
<PageSectionMeta>
|
|
<PageSectionSummary>
|
|
<PageSectionTitle>Project usage</PageSectionTitle>
|
|
</PageSectionSummary>
|
|
</PageSectionMeta>
|
|
<PageSectionContent>
|
|
<Card>
|
|
<CardContent>
|
|
<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>
|
|
|
|
{!!organization && !!project && (
|
|
<Button asChild type="default">
|
|
<Link href={`/org/${organization.slug}/usage?projectRef=${project.ref}`}>
|
|
View project usage
|
|
</Link>
|
|
</Button>
|
|
)}
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
)}
|
|
</>
|
|
)
|
|
}
|