Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: remove redundant charts

Jonathan Summers-Muird4f49e2a8f05
diff --git a/studio/components/interfaces/Home/ProjectUsage.tsx b/studio/components/interfaces/Home/ProjectUsage.tsx
index 62a1c0a9dc8..638d99d8109 100644
--- a/studio/components/interfaces/Home/ProjectUsage.tsx
+++ b/studio/components/interfaces/Home/ProjectUsage.tsx
@@ -1,31 +1,28 @@
-import useSWR from 'swr'
-import dayjs from 'dayjs'
-import Link from 'next/link'
-import { FC, useState } from 'react'
-import { useRouter } from 'next/router'
import {
+ Button,
+ Dropdown,
IconArchive,
+ IconChevronDown,
IconDatabase,
IconKey,
IconZap,
Typography,
- Button,
- Dropdown,
- IconChevronDown,
} from '@supabase/ui'
-
-import Panel from 'components/to-be-cleaned/Panel'
import ChartHandler from 'components/to-be-cleaned/Charts/ChartHandler'
-import { ProjectUsageMinimal } from 'components/to-be-cleaned/Usage'
-
-import { useFlag } from 'hooks'
-import { get } from 'lib/common/fetch'
-import { API_URL, METRICS, DATE_FORMAT } from 'lib/constants'
+import Panel from 'components/to-be-cleaned/Panel'
import Table from 'components/to-be-cleaned/Table'
-import StackedAreaChart from 'components/ui/Charts/StackedAreaChart'
import { USAGE_COLORS } from 'components/ui/Charts/Charts.constants'
-import { EndpointResponse, PathsDatum, StatusCodesDatum } from './ChartData.types'
+import StackedAreaChart from 'components/ui/Charts/StackedAreaChart'
+import dayjs from 'dayjs'
+import { useFlag } from 'hooks'
+import { get } from 'lib/common/fetch'
+import { API_URL, DATE_FORMAT, METRICS } from 'lib/constants'
+import Link from 'next/link'
+import { useRouter } from 'next/router'
+import { FC, useState } from 'react'
+import useSWR from 'swr'
import { ChartIntervals } from 'types'
+import { EndpointResponse, PathsDatum, StatusCodesDatum } from './ChartData.types'
const CHART_INTERVALS: ChartIntervals[] = [
{
@@ -47,10 +44,12 @@ const ProjectUsage: FC<Props> = ({ project }) => {
const [interval, setInterval] = useState<string>('hourly')
const router = useRouter()
const { ref } = router.query
+
const { data, error }: any = useSWR(
`${API_URL}/projects/${ref}/log-stats?interval=${interval}`,
get
)
+
const { data: codesData, error: codesFetchError } = useSWR<EndpointResponse<StatusCodesDatum>>(
logsUsageCodesPaths
? `${API_URL}/projects/${ref}/analytics/endpoints/usage.api-codes?interval=${interval}`
@@ -72,6 +71,7 @@ const ProjectUsage: FC<Props> = ({ project }) => {
const endDate = dayjs().format(DATE_FORMAT)
const charts = data?.data
const datetimeFormat = selectedInterval.format || 'MMM D, ha'
+
const handleBarClick = (v: any, search: string) => {
if (!v || !v.activePayload?.[0]?.payload) return
// returns rechart internal tooltip data type
@@ -86,6 +86,7 @@ const ProjectUsage: FC<Props> = ({ project }) => {
router.push(`/project/${ref}/database/api-logs?te=${timestamp}`)
}
}
+
return (
<div className="mx-6 space-y-6">
<div className="flex flex-row items-center gap-2">
@@ -138,11 +139,6 @@ const ProjectUsage: FC<Props> = ({ project }) => {
isLoading={!charts && !error ? true : false}
onBarClick={(v) => handleBarClick(v, '/rest')}
/>
- <ProjectUsageMinimal
- projectRef={project.ref}
- subscription_id={project.subscription_id}
- filter="Database"
- />
</Panel.Content>
</Panel>
<Panel key="auth-chart">
@@ -169,11 +165,6 @@ const ProjectUsage: FC<Props> = ({ project }) => {
isLoading={!charts && !error ? true : false}
onBarClick={(v) => handleBarClick(v, '/auth')}
/>
- <ProjectUsageMinimal
- projectRef={project.ref}
- subscription_id={project.subscription_id}
- filter="Auth"
- />
</Panel.Content>
</Panel>
<Panel key="storage-chart">
@@ -200,11 +191,6 @@ const ProjectUsage: FC<Props> = ({ project }) => {
isLoading={!charts && !error ? true : false}
onBarClick={(v) => handleBarClick(v, '/storage')}
/>
- <ProjectUsageMinimal
- projectRef={project.ref}
- subscription_id={project.subscription_id}
- filter="File storage"
- />
</Panel.Content>
</Panel>
<Panel key="realtime-chart">
diff --git a/studio/components/to-be-cleaned/Usage.tsx b/studio/components/to-be-cleaned/Usage.tsx
index ef03f7914ca..cd8fea48394 100644
--- a/studio/components/to-be-cleaned/Usage.tsx
+++ b/studio/components/to-be-cleaned/Usage.tsx
@@ -77,57 +77,6 @@ const usageLimits = {
},
],
},
- auth: {
- title: 'Auth',
- icon_src: '/img/key.svg',
- features: [
- {
- title: 'Users',
- tiers: {
- free: {
- description: (stats: any) => `${(((stats?.authUsers || 0) / 10000) * 100).toFixed(2)}%`,
- render: (stats: any) => (
- <SparkBar
- value={stats?.authUsers || 0}
- max={10000}
- type={'horizontal'}
- barClass={'bg-brand-900'}
- labelBottom={stats?.authUsers ? new Number(stats?.authUsers).toLocaleString() : '0'}
- labelTop={`${new Number(10000).toLocaleString()}`}
- />
- ),
- },
- pro: {
- description: (stats: any) =>
- `${(((stats?.authUsers || 0) / 100000) * 100).toFixed(2)}%`,
- render: (stats: any) => (
- <SparkBar
- value={stats?.authUsers || 0}
- max={100000}
- type={'horizontal'}
- barClass={'bg-brand-900'}
- labelBottom={stats?.authUsers ? new Number(stats?.authUsers).toLocaleString() : '0'}
- labelTop={`${new Number(100000).toLocaleString()}`}
- />
- ),
- },
- },
- },
- {
- title: 'Auth confirmation emails',
- tiers: {
- free: {
- description: () => `${new Number(1000).toLocaleString()}/month`,
- render: null,
- },
- pro: {
- description: () => `${new Number(30000).toLocaleString()}/month`,
- render: null,
- },
- },
- },
- ],
- },
storage: {
title: 'File storage',
icon_src: '/img/archive.svg',
@@ -212,15 +161,15 @@ const ProjectUsage: FC<any> = ({ projectRef, subscription_id }) => {
<div className="">
{Object.values(usageLimits).map((product) => (
<div
- className="rounded overflow-hidden border border-panel-border-light dark:border-panel-border-dark mb-8"
+ className="border-panel-border-light dark:border-panel-border-dark mb-8 overflow-hidden rounded border"
key={product.title}
>
- <table className="w-full bg-panel-body-light dark:bg-panel-body-dark">
+ <table className="bg-panel-body-light dark:bg-panel-body-dark w-full">
<thead className="bg-panel-header-light dark:bg-panel-header-dark">
- <tr className="rounded overflow-hidden">
- <th className="px-6 py-3 text-left w-1/4">
+ <tr className="overflow-hidden rounded">
+ <th className="w-1/4 px-6 py-3 text-left">
<div className="flex items-center space-x-3">
- <div className="w-8 h-8 bg-white rounded flex items-center justify-center">
+ <div className="flex h-8 w-8 items-center justify-center rounded bg-white">
<img width={'16'} src={product.icon_src} />
</div>
<Typography.Title level={5} className="mb-0">
@@ -228,10 +177,10 @@ const ProjectUsage: FC<any> = ({ projectRef, subscription_id }) => {
</Typography.Title>
</div>
</th>
- <th className="p-3 text-xs leading-4 font-medium text-gray-400 text-left hidden lg:table-cell">
+ <th className="hidden p-3 text-left text-xs font-medium leading-4 text-gray-400 lg:table-cell">
{/* Plan Limits */}
</th>
- <th className="p-3 text-xs leading-4 font-medium text-gray-400 text-left">
+ <th className="p-3 text-left text-xs font-medium leading-4 text-gray-400">
{/* Usage */}
</th>
</tr>
@@ -241,16 +190,16 @@ const ProjectUsage: FC<any> = ({ projectRef, subscription_id }) => {
{product.features.map((feature) => {
return (
<tr
- className="border-t border-panel-border-light dark:border-panel-border-dark"
+ className="border-panel-border-light dark:border-panel-border-dark border-t"
key={feature.title}
>
- <td className="px-6 py-3 whitespace-nowrap text-sm text-typography-body-light dark:text-typography-body-dark">
+ <td className="text-typography-body-light dark:text-typography-body-dark whitespace-nowrap px-6 py-3 text-sm">
{feature.title}
</td>
- <td className="p-3 whitespace-nowrap text-sm text-typography-body-light dark:text-typography-body-dark hidden lg:table-cell w-1/5">
+ <td className="text-typography-body-light dark:text-typography-body-dark hidden w-1/5 whitespace-nowrap p-3 text-sm lg:table-cell">
{feature.tiers[tier]?.description(stats)}
</td>
- <td className="px-6 py-3 text-sm text-typography-body-light dark:text-typography-body-dark ">
+ <td className="text-typography-body-light dark:text-typography-body-dark px-6 py-3 text-sm ">
{/* @ts-ignore */}
{feature.tiers[tier]?.render ? feature.tiers[tier].render(stats) : null}
</td>
@@ -293,7 +242,7 @@ export const ProjectUsageMinimal: FC<any> = ({ projectRef, subscription_id, filt
{feature.tiers[tier]?.render && feature.title !== 'Transfer limits' ? (
<h5 className="text-scale-900 text-sm">{feature.title}</h5>
) : null}
- <div className="text-sm text-typography-body-light dark:text-typography-body-dark">
+ <div className="text-typography-body-light dark:text-typography-body-dark text-sm">
{/* @ts-ignore */}
{feature.tiers[tier]?.render ? feature.tiers[tier].render(stats) : null}
</div>