From 521b0202e2cb6a04a2de3ca85389b34b5e7ab6d3 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Tue, 24 May 2022 01:04:21 -0700 Subject: [PATCH] Search: remove special playground page and replace the standard results (#49442) --- .../search/components/DashboardListPage.tsx | 2 +- .../search/components/DashboardSearch.tsx | 2 +- .../app/features/search/page/SearchPage.tsx | 112 ------------------ .../search/page/components/FolderSection.tsx | 2 +- .../search/page/components/SearchView.tsx | 19 ++- public/app/features/search/service/bluge.ts | 1 + public/app/routes/routes.tsx | 6 - 7 files changed, 13 insertions(+), 131 deletions(-) delete mode 100644 public/app/features/search/page/SearchPage.tsx diff --git a/public/app/features/search/components/DashboardListPage.tsx b/public/app/features/search/components/DashboardListPage.tsx index 03374885f92..ffb8219067e 100644 --- a/public/app/features/search/components/DashboardListPage.tsx +++ b/public/app/features/search/components/DashboardListPage.tsx @@ -47,7 +47,7 @@ export const DashboardListPage: FC = memo(({ navModel, match, location }) return ( {/*Todo: remove the false to test, or when we feel confident with thsi approach */} - {false && config.featureToggles.panelTitleSearch ? ( + {Boolean(config.featureToggles.panelTitleSearch && !window.location.search?.includes('index=sql')) ? ( ; } diff --git a/public/app/features/search/page/SearchPage.tsx b/public/app/features/search/page/SearchPage.tsx deleted file mode 100644 index ba0509e0ab8..00000000000 --- a/public/app/features/search/page/SearchPage.tsx +++ /dev/null @@ -1,112 +0,0 @@ -import { css } from '@emotion/css'; -import React, { useState } from 'react'; -import { useAsync, useDebounce } from 'react-use'; - -import { GrafanaTheme2, NavModelItem } from '@grafana/data'; -import { Input, useStyles2, Spinner, InlineSwitch, InlineFieldRow, InlineField, Select } from '@grafana/ui'; -import Page from 'app/core/components/Page/Page'; -import { backendSrv } from 'app/core/services/backend_srv'; -import { FolderDTO } from 'app/types'; - -import { useSearchQuery } from '../hooks/useSearchQuery'; -import { getGrafanaSearcher } from '../service'; - -import { SearchView } from './components/SearchView'; - -const node: NavModelItem = { - id: 'search', - text: 'Search playground', - subTitle: 'The body below will eventually live inside existing UI layouts', - icon: 'dashboard', - url: 'search', -}; - -export default function SearchPage() { - const styles = useStyles2(getStyles); - - const [showManage, setShowManage] = useState(false); // grid vs list view - const [folderDTO, setFolderDTO] = useState(); // grid vs list view - const folders = useAsync(async () => { - const rsp = await getGrafanaSearcher().search({ - query: '*', - kind: ['folder'], - }); - return rsp.view.map((v) => ({ value: v.uid, label: v.name })); - }, []); - const setFolder = async (uid?: string) => { - if (uid?.length) { - const dto = await backendSrv.getFolderByUid(uid); - setFolderDTO(dto); - } else { - setFolderDTO(undefined); - } - }; - - // since we don't use "query" from use search... it is not actually loaded from the URL! - const { query, onQueryChange } = useSearchQuery({}); - - const [inputValue, setInputValue] = useState(query.query ?? ''); - const onSearchQueryChange = (e: React.ChangeEvent) => { - e.preventDefault(); - setInputValue(e.currentTarget.value); - }; - useDebounce(() => onQueryChange(inputValue), 200, [inputValue]); - - return ( - - - : null} - /> - - - setShowManage(!showManage)} /> - - -