From 64aedb78ba54ccead531342e6d99f451012c0ae5 Mon Sep 17 00:00:00 2001 From: kay delaney <45561153+kaydelaney@users.noreply.github.com> Date: Thu, 19 May 2022 22:16:25 +0100 Subject: [PATCH] Search: Support filtering by tag in folder view (#49221) --- .../app/features/search/page/components/FolderSection.tsx | 6 ++++-- public/app/features/search/page/components/FolderView.tsx | 8 +++----- public/app/features/search/page/components/SearchView.tsx | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/public/app/features/search/page/components/FolderSection.tsx b/public/app/features/search/page/components/FolderSection.tsx index 259c5229246..fa7df925521 100644 --- a/public/app/features/search/page/components/FolderSection.tsx +++ b/public/app/features/search/page/components/FolderSection.tsx @@ -29,6 +29,7 @@ interface SectionHeaderProps { onTagSelected: (tag: string) => void; section: DashboardSection; renderStandaloneBody?: boolean; // render the body on its own + tags?: string[]; } export const FolderSection: FC = ({ @@ -37,6 +38,7 @@ export const FolderSection: FC = ({ onTagSelected, selection, renderStandaloneBody, + tags, }) => { const editable = selectionToggle != null; const theme = useTheme(); @@ -74,7 +76,7 @@ export const FolderSection: FC = ({ folderUid = undefined; folderTitle = undefined; } - const raw = await getGrafanaSearcher().search(query); + const raw = await getGrafanaSearcher().search({ ...query, tags }); const v = raw.view.map( (item) => ({ @@ -91,7 +93,7 @@ export const FolderSection: FC = ({ } as DashboardSectionItem) ); return v; - }, [sectionExpanded, section]); + }, [sectionExpanded, section, tags]); const onSectionExpand = () => { setSectionExpanded(!sectionExpanded); diff --git a/public/app/features/search/page/components/FolderView.tsx b/public/app/features/search/page/components/FolderView.tsx index 6b8fe3c8a35..476876432a3 100644 --- a/public/app/features/search/page/components/FolderView.tsx +++ b/public/app/features/search/page/components/FolderView.tsx @@ -12,11 +12,8 @@ import { SearchResultsProps } from '../components/SearchResultsTable'; import { DashboardSection, FolderSection } from './FolderSection'; -export const FolderView = ({ - selection, - selectionToggle, - onTagSelected, -}: Pick) => { +type Props = Pick & { tags?: string[] }; +export const FolderView = ({ selection, selectionToggle, onTagSelected, tags }: Props) => { const styles = useStyles2(getStyles); const results = useAsync(async () => { @@ -59,6 +56,7 @@ export const FolderView = ({ selectionToggle={selectionToggle} onTagSelected={onTagSelected} section={section} + tags={tags} /> )} diff --git a/public/app/features/search/page/components/SearchView.tsx b/public/app/features/search/page/components/SearchView.tsx index 9a20af7bdf8..0a0c710b9d8 100644 --- a/public/app/features/search/page/components/SearchView.tsx +++ b/public/app/features/search/page/components/SearchView.tsx @@ -131,7 +131,9 @@ export const SearchView = ({ showManage, folderDTO, queryText }: SearchViewProps /> ); } - return ; + return ( + + ); } return (