The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Update project usage chart date picker (#34734)
Jordi Enric7283c3103e3b
diff --git a/apps/studio/components/interfaces/Home/ProjectUsage.tsx b/apps/studio/components/interfaces/Home/ProjectUsage.tsxindex a322238f98d..7ab7d78caa5 100644--- a/apps/studio/components/interfaces/Home/ProjectUsage.tsx+++ b/apps/studio/components/interfaces/Home/ProjectUsage.tsx@@ -14,6 +14,7 @@ import {useProjectLogStatsQuery,} from 'data/analytics/project-log-stats-query'import { useFillTimeseriesSorted } from 'hooks/analytics/useFillTimeseriesSorted'+import { useCurrentOrgPlan } from 'hooks/misc/useCurrentOrgPlan'import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'import type { ChartIntervals } from 'types'import {@@ -29,13 +30,28 @@ import {const CHART_INTERVALS: ChartIntervals[] = [{key: 'minutely',- label: '60 minutes',+ label: 'Last 60 minutes',startValue: 1,startUnit: 'hour',format: 'MMM D, h:mma',+ availableIn: ['free', 'pro', 'enterprise', 'team'],+ },+ {+ key: 'hourly',+ label: 'Last 24 hours',+ startValue: 24,+ startUnit: 'hour',+ format: 'MMM D, ha',+ availableIn: ['free', 'pro', 'enterprise', 'team'],+ },+ {+ key: 'daily',+ label: 'Last 7 days',+ startValue: 7,+ startUnit: 'day',+ format: 'MMM D',+ availableIn: ['pro', 'enterprise', 'team'],},- { key: 'hourly', label: '24 hours', startValue: 24, startUnit: 'hour', format: 'MMM D, ha' },- { key: 'daily', label: '7 days', startValue: 7, startUnit: 'day', format: 'MMM D' },]const ProjectUsage = () => {@@ -47,7 +63,9 @@ const ProjectUsage = () => {'project_storage:all',])- const [interval, setInterval] = useState<ProjectLogStatsVariables['interval']>('hourly')+ const { plan } = useCurrentOrgPlan()++ const [interval, setInterval] = useState<ProjectLogStatsVariables['interval']>('minutely')const { data, isLoading } = useProjectLogStatsQuery({ projectRef, interval })@@ -95,7 +113,7 @@ const ProjectUsage = () => {<span>{selectedInterval.label}</span></Button></DropdownMenuTrigger>- <DropdownMenuContent side="bottom" align="start">+ <DropdownMenuContent side="bottom" align="start" className="w-40"><DropdownMenuRadioGroupvalue={interval}onValueChange={(interval) =>@@ -103,7 +121,11 @@ const ProjectUsage = () => {}>{CHART_INTERVALS.map((i) => (- <DropdownMenuRadioItem key={i.key} value={i.key}>+ <DropdownMenuRadioItem+ key={i.key}+ value={i.key}+ disabled={!i.availableIn?.includes(plan?.id || 'free')}+ >{i.label}</DropdownMenuRadioItem>))}@@ -111,7 +133,7 @@ const ProjectUsage = () => {</DropdownMenuContent></DropdownMenu><span className="text-xs text-foreground-light">- Statistics for past {selectedInterval.label}+ Statistics for {selectedInterval.label.toLowerCase()}</span></div><div className="grid grid-cols-1 md:grid-cols-2 md:gap-4 lg:grid-cols-4">diff --git a/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx b/apps/studio/components/interfaces/Home/ProjectUsageSection.tsxindex 16eab01497b..306b5496991 100644--- a/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx+++ b/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx@@ -22,7 +22,7 @@ const ProjectUsageSection = () => {// to eliminate multiple spinnersconst { isLoading: isLogsStatsLoading } = useProjectLogStatsQuery({projectRef: project?.ref,- interval: 'hourly',+ interval: 'minutely',})if (usageError) {diff --git a/apps/studio/types/ui.ts b/apps/studio/types/ui.tsindex 7ed014c462c..79637a5b3ad 100644--- a/apps/studio/types/ui.ts+++ b/apps/studio/types/ui.ts@@ -1,4 +1,5 @@import type { PostgresColumn } from '@supabase/postgres-meta'+import { PlanId } from 'data/subscriptions/types'export interface Notification {category: 'info' | 'error' | 'success' | 'loading'@@ -21,6 +22,7 @@ export interface ChartIntervals {startValue: numberstartUnit: 'minute' | 'hour' | 'day'format?: 'MMM D, h:mm:ssa' | 'MMM D, h:mma' | 'MMM D, ha' | 'MMM D'+ availableIn?: PlanId[]}export interface VaultSecret {