From ff8a306a7636ea74a7c83dbd37ee345bc9fa05df Mon Sep 17 00:00:00 2001 From: Jordi Enric <37541088+jordienr@users.noreply.github.com> Date: Fri, 19 Apr 2024 14:09:58 +0200 Subject: [PATCH] Feat: query performance - add btn to hide bottom section (#22902) * add btn to hide bottom section * fix onResetReportClick not being optional for old UI --- .../QueryPerformanceV2/QueryPerformance.tsx | 31 ++++++++++- .../QueryPerformanceFilterBar.tsx | 51 +++++++++++++------ apps/studio/lib/constants/index.ts | 2 + 3 files changed, 66 insertions(+), 18 deletions(-) diff --git a/apps/studio/components/interfaces/QueryPerformanceV2/QueryPerformance.tsx b/apps/studio/components/interfaces/QueryPerformanceV2/QueryPerformance.tsx index 1b3919b3de6..b6b8c845417 100644 --- a/apps/studio/components/interfaces/QueryPerformanceV2/QueryPerformance.tsx +++ b/apps/studio/components/interfaces/QueryPerformanceV2/QueryPerformance.tsx @@ -25,6 +25,9 @@ import { PresetHookResult } from '../Reports/Reports.utils' import { QUERY_PERFORMANCE_REPORT_TYPES } from './QueryPerformance.constants' import { QueryPerformanceFilterBar } from './QueryPerformanceFilterBar' import { QueryPerformanceGrid } from './QueryPerformanceGrid' +import { useLocalStorageQuery } from 'hooks' +import { LOCAL_STORAGE_KEYS } from 'lib/constants' +import { X } from 'lucide-react' interface QueryPerformanceProps { queryHitRate: PresetHookResult @@ -43,6 +46,11 @@ export const QueryPerformance = ({ ) const [showResetgPgStatStatements, setShowResetgPgStatStatements] = useState(false) + const [showBottomSection, setShowBottomSection] = useLocalStorageQuery( + LOCAL_STORAGE_KEYS.QUERY_PERF_SHOW_BOTTOM_SECTION, + true + ) + const handleRefresh = () => { queryPerformanceQuery.runQuery() queryHitRate.runQuery() @@ -161,12 +169,31 @@ export const QueryPerformance = ({
Reset report
diff --git a/apps/studio/components/interfaces/QueryPerformanceV2/QueryPerformanceFilterBar.tsx b/apps/studio/components/interfaces/QueryPerformanceV2/QueryPerformanceFilterBar.tsx
index c845f6b0639..d4f6414507e 100644
--- a/apps/studio/components/interfaces/QueryPerformanceV2/QueryPerformanceFilterBar.tsx
+++ b/apps/studio/components/interfaces/QueryPerformanceV2/QueryPerformanceFilterBar.tsx
@@ -1,11 +1,11 @@
-import { ArrowDown, ArrowUp, RefreshCw } from 'lucide-react'
+import { ArrowDown, ArrowUp, Info, RefreshCw } from 'lucide-react'
import { useRouter } from 'next/router'
import { useState } from 'react'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import { FilterPopover } from 'components/ui/FilterPopover'
import { useDatabaseRolesQuery } from 'data/database-roles/database-roles-query'
-import { useFlag } from 'hooks'
+import { useFlag, useLocalStorageQuery } from 'hooks'
import { DbQueryHook } from 'hooks/analytics/useDbQuery'
import {
Button,
@@ -17,15 +17,22 @@ import {
} from 'ui'
import { TextSearchPopover } from './TextSearchPopover'
import { QueryPerformanceSort } from '../Reports/Reports.queries'
+import { LOCAL_STORAGE_KEYS } from 'lib/constants'
export const QueryPerformanceFilterBar = ({
queryPerformanceQuery,
+ onResetReportClick,
}: {
queryPerformanceQuery: DbQueryHook