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 = ({
- + { + setShowResetgPgStatStatements(true) + }} + />
-
+
+

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 + onResetReportClick?: () => void }) => { const router = useRouter() const { project } = useProjectContext() const enableQueryPerformanceV2 = useFlag('queryPerformanceV2') + const [showBottomSection, setShowBottomSection] = useLocalStorageQuery( + LOCAL_STORAGE_KEYS.QUERY_PERF_SHOW_BOTTOM_SECTION, + true + ) const defaultSearchQueryValue = router.query.search ? String(router.query.search) : '' const defaultFilterRoles = router.query.roles ? (router.query.roles as string[]) : [] const defaultSortByValue = router.query.sort @@ -128,20 +135,32 @@ export const QueryPerformanceFilterBar = ({

- +
+ {!showBottomSection && onResetReportClick && ( + + )} + +
) } diff --git a/apps/studio/lib/constants/index.ts b/apps/studio/lib/constants/index.ts index 1e236e61867..0e55cf6dc87 100644 --- a/apps/studio/lib/constants/index.ts +++ b/apps/studio/lib/constants/index.ts @@ -50,6 +50,8 @@ export const LOCAL_STORAGE_KEYS = { PGBOUNCER_DEPRECATION_WARNING: 'pgbouncer-deprecation-warning-dismissed', PROJECT_LINT_IGNORE_LIST: 'supabase-project-lint-ignore-list', + + QUERY_PERF_SHOW_BOTTOM_SECTION: 'supabase-query-perf-show-bottom-section', } export const OPT_IN_TAGS = {