From 2fa17afca3e55d4284fbe9fc6a09ee0b35020a2a Mon Sep 17 00:00:00 2001 From: Jordi Enric <37541088+jordienr@users.noreply.github.com> Date: Mon, 26 May 2025 16:38:26 +0200 Subject: [PATCH] Project Usage: fix types and component (#35934) * fix types and component * fix types --- .../interfaces/Home/ProjectUsage.tsx | 26 ++++++++++--------- .../interfaces/Home/ProjectUsageSection.tsx | 2 +- .../[ref]/functions/[functionSlug]/index.tsx | 23 ++++++---------- apps/studio/types/ui.ts | 3 ++- packages/api-types/types/platform.d.ts | 4 ++- 5 files changed, 28 insertions(+), 30 deletions(-) diff --git a/apps/studio/components/interfaces/Home/ProjectUsage.tsx b/apps/studio/components/interfaces/Home/ProjectUsage.tsx index d4ad8b99869..d0c2623f3cc 100644 --- a/apps/studio/components/interfaces/Home/ProjectUsage.tsx +++ b/apps/studio/components/interfaces/Home/ProjectUsage.tsx @@ -27,9 +27,11 @@ import { Loading, } from 'ui' +type ChartIntervalKey = ProjectLogStatsVariables['interval'] + const CHART_INTERVALS: ChartIntervals[] = [ { - key: 'minutely', + key: '1hr', label: 'Last 60 minutes', startValue: 1, startUnit: 'hour', @@ -37,21 +39,21 @@ const CHART_INTERVALS: ChartIntervals[] = [ availableIn: ['free', 'pro', 'enterprise', 'team'], }, { - key: 'hourly', + key: '1day', 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: '', + // label: 'Last 7 days', + // startValue: 7, + // startUnit: 'day', + // format: 'MMM D', + // availableIn: ['pro', 'enterprise', 'team'], + // }, ] const ProjectUsage = () => { @@ -65,9 +67,9 @@ const ProjectUsage = () => { const { plan } = useCurrentOrgPlan() - const DEFAULT_INTERVAL = plan?.id === 'free' ? 'hourly' : 'daily' + const DEFAULT_INTERVAL: ChartIntervalKey = plan?.id === 'free' ? '1hr' : '1day' - const [interval, setInterval] = useState(DEFAULT_INTERVAL) + const [interval, setInterval] = useState(DEFAULT_INTERVAL) const { data, isLoading } = useProjectLogStatsQuery({ projectRef, interval }) diff --git a/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx b/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx index 08f566751f1..0093aa5f566 100644 --- a/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx +++ b/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx @@ -14,7 +14,7 @@ export const ProjectUsageSection = () => { // wait for the stats to load before showing the usage section to eliminate multiple spinners const { isLoading: isLogsStatsLoading } = useProjectLogStatsQuery({ projectRef: project?.ref, - interval: 'minutely', + interval: '1hr', }) if (isLoading || isLogsStatsLoading) { diff --git a/apps/studio/pages/project/[ref]/functions/[functionSlug]/index.tsx b/apps/studio/pages/project/[ref]/functions/[functionSlug]/index.tsx index ae12244addd..313098869cb 100644 --- a/apps/studio/pages/project/[ref]/functions/[functionSlug]/index.tsx +++ b/apps/studio/pages/project/[ref]/functions/[functionSlug]/index.tsx @@ -33,19 +33,12 @@ import { } from 'ui' const CHART_INTERVALS: ChartIntervals[] = [ - { - key: '5min', - label: '5 min', - startValue: 5, - startUnit: 'minute', - format: 'MMM D, h:mm:ssa', - }, { key: '15min', label: '15 min', startValue: 15, startUnit: 'minute', - format: 'MMM D, h:mma', + format: 'MMM D, h:mm:ssa', }, { key: '1hr', @@ -61,13 +54,13 @@ const CHART_INTERVALS: ChartIntervals[] = [ startUnit: 'hour', format: 'MMM D, h:mma', }, - { - key: '7day', - label: '7 days', - startValue: 7, - startUnit: 'day', - format: 'MMM D', - }, + // { + // key: '7day', + // label: '7 days', + // startValue: 7, + // startUnit: 'day', + // format: 'MMM D', + // }, ] const PageLayout: NextPageWithLayout = () => { diff --git a/apps/studio/types/ui.ts b/apps/studio/types/ui.ts index 69d3cea5cf4..bd47d809ad5 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 { ProjectLogStatsVariables } from 'data/analytics/project-log-stats-query' import { PlanId } from 'data/subscriptions/types' export interface Notification { @@ -17,7 +18,7 @@ interface NotificationMetadata { } export interface ChartIntervals { - key: 'minutely' | 'hourly' | 'daily' | '5min' | '15min' | '1hr' | '1day' | '7day' + key: Exclude label: string startValue: number startUnit: 'minute' | 'hour' | 'day' diff --git a/packages/api-types/types/platform.d.ts b/packages/api-types/types/platform.d.ts index 4bb55aa5127..2ff723549df 100644 --- a/packages/api-types/types/platform.d.ts +++ b/packages/api-types/types/platform.d.ts @@ -5639,6 +5639,7 @@ export interface components { MAILER_TEMPLATES_MAGIC_LINK_CONTENT: string MAILER_TEMPLATES_REAUTHENTICATION_CONTENT: string MAILER_TEMPLATES_RECOVERY_CONTENT: string + MFA_ALLOW_LOW_AAL: boolean MFA_MAX_ENROLLED_FACTORS: number MFA_PHONE_ENROLL_ENABLED: boolean MFA_PHONE_MAX_FREQUENCY: number @@ -7832,6 +7833,7 @@ export interface components { MAILER_TEMPLATES_MAGIC_LINK_CONTENT?: string | null MAILER_TEMPLATES_REAUTHENTICATION_CONTENT?: string | null MAILER_TEMPLATES_RECOVERY_CONTENT?: string | null + MFA_ALLOW_LOW_AAL?: boolean | null MFA_MAX_ENROLLED_FACTORS?: number | null MFA_PHONE_ENROLL_ENABLED?: boolean | null MFA_PHONE_MAX_FREQUENCY?: number | null @@ -14303,7 +14305,7 @@ export interface operations { UsageApiController_getApiCounts: { parameters: { query?: { - interval?: 'minutely' | 'hourly' | 'daily' | '15min' | '30min' | '1hr' | '3hr' | '1day' + interval?: '15min' | '30min' | '1hr' | '3hr' | '1day' } header?: never path: {