Skip to content

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

Added feature flag logsUsageChartIntervals

TzeYiing96c6ee0dad1b
diff --git a/studio/components/interfaces/Home/ProjectUsage.tsx b/studio/components/interfaces/Home/ProjectUsage.tsx
index 9fff9678d0d..e584711cd43 100644
--- a/studio/components/interfaces/Home/ProjectUsage.tsx
+++ b/studio/components/interfaces/Home/ProjectUsage.tsx
@@ -11,6 +11,7 @@ import {
Typography,
Button,
Dropdown,
+ IconChevronDown,
} from '@supabase/ui'
import Panel from 'components/to-be-cleaned/Panel'
@@ -19,6 +20,7 @@ import { ProjectUsageMinimal } from 'components/to-be-cleaned/Usage'
import { get } from 'lib/common/fetch'
import { API_URL, METRICS, DATE_FORMAT } from 'lib/constants'
+import { useFlag } from 'hooks'
const CHART_INTERVALS = [
{ key: 'minutely', label: '60 minutes', startValue: 1, startUnit: 'hour', format: 'MMM D, h:ma' },
@@ -30,6 +32,7 @@ interface Props {
}
const ProjectUsage: FC<Props> = ({ project }) => {
+ const logsUsageChartIntervals = useFlag('logsUsageChartIntervals')
const [interval, setInterval] = useState<string>('minutely')
const router = useRouter()
const { ref } = router.query
@@ -41,7 +44,9 @@ const ProjectUsage: FC<Props> = ({ project }) => {
// conditional fetching will cause cached data to clear (not desirable)
// { refreshInterval: isActive ? 3000 : 30000 }
)
- const selectedInterval = CHART_INTERVALS.find((i) => i.key === interval) || CHART_INTERVALS[0]
+ const selectedInterval = logsUsageChartIntervals
+ ? CHART_INTERVALS.find((i) => i.key === interval) || CHART_INTERVALS[0]
+ : CHART_INTERVALS[2]
const startDate = dayjs()
.subtract(selectedInterval.startValue, selectedInterval.startUnit)
.format(DATE_FORMAT)
@@ -53,11 +58,11 @@ const ProjectUsage: FC<Props> = ({ project }) => {
<div className="flex flex-row justify-between w-full">
<Typography.Title level={4}>Statistics for past {selectedInterval.label}</Typography.Title>
- <Dropdown
- side="bottom"
- align="center"
- overlay={
- <>
+ {logsUsageChartIntervals && (
+ <Dropdown
+ side="bottom"
+ align="center"
+ overlay={
<Dropdown.RadioGroup value={interval} onChange={setInterval}>
{CHART_INTERVALS.map((i) => (
<Dropdown.Radio key={i.key} value={i.key}>
@@ -65,11 +70,13 @@ const ProjectUsage: FC<Props> = ({ project }) => {
</Dropdown.Radio>
))}
</Dropdown.RadioGroup>
- </>
- }
- >
- <Button type="outline">{selectedInterval.label}</Button>
- </Dropdown>
+ }
+ >
+ <Button type="text" iconRight={<IconChevronDown size="small" />}>
+ {selectedInterval.label}
+ </Button>
+ </Dropdown>
+ )}
</div>
<div className="">
{startDate && endDate && (
diff --git a/studio/tests/components/Home/ProjectUsage.test.js b/studio/tests/components/Home/ProjectUsage.test.js
index c2f6860bf32..9864a387cd1 100644
--- a/studio/tests/components/Home/ProjectUsage.test.js
+++ b/studio/tests/components/Home/ProjectUsage.test.js
@@ -23,6 +23,14 @@ ProjectUsage.mockImplementation((props) => {
)
})
+jest.mock('components/ui/Flag/Flag')
+import Flag from 'components/ui/Flag/Flag'
+Flag.mockImplementation(({ children }) => <>{children}</>)
+jest.mock('hooks')
+import { useFlag } from 'hooks'
+useFlag.mockReturnValue(true)
+
+
beforeEach(() => {
get.mockReset()