mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Search: Support filtering by tag in folder view (#49221)
This commit is contained in:
parent
e8b498fe8b
commit
64aedb78ba
@ -29,6 +29,7 @@ interface SectionHeaderProps {
|
|||||||
onTagSelected: (tag: string) => void;
|
onTagSelected: (tag: string) => void;
|
||||||
section: DashboardSection;
|
section: DashboardSection;
|
||||||
renderStandaloneBody?: boolean; // render the body on its own
|
renderStandaloneBody?: boolean; // render the body on its own
|
||||||
|
tags?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FolderSection: FC<SectionHeaderProps> = ({
|
export const FolderSection: FC<SectionHeaderProps> = ({
|
||||||
@ -37,6 +38,7 @@ export const FolderSection: FC<SectionHeaderProps> = ({
|
|||||||
onTagSelected,
|
onTagSelected,
|
||||||
selection,
|
selection,
|
||||||
renderStandaloneBody,
|
renderStandaloneBody,
|
||||||
|
tags,
|
||||||
}) => {
|
}) => {
|
||||||
const editable = selectionToggle != null;
|
const editable = selectionToggle != null;
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@ -74,7 +76,7 @@ export const FolderSection: FC<SectionHeaderProps> = ({
|
|||||||
folderUid = undefined;
|
folderUid = undefined;
|
||||||
folderTitle = undefined;
|
folderTitle = undefined;
|
||||||
}
|
}
|
||||||
const raw = await getGrafanaSearcher().search(query);
|
const raw = await getGrafanaSearcher().search({ ...query, tags });
|
||||||
const v = raw.view.map(
|
const v = raw.view.map(
|
||||||
(item) =>
|
(item) =>
|
||||||
({
|
({
|
||||||
@ -91,7 +93,7 @@ export const FolderSection: FC<SectionHeaderProps> = ({
|
|||||||
} as DashboardSectionItem)
|
} as DashboardSectionItem)
|
||||||
);
|
);
|
||||||
return v;
|
return v;
|
||||||
}, [sectionExpanded, section]);
|
}, [sectionExpanded, section, tags]);
|
||||||
|
|
||||||
const onSectionExpand = () => {
|
const onSectionExpand = () => {
|
||||||
setSectionExpanded(!sectionExpanded);
|
setSectionExpanded(!sectionExpanded);
|
||||||
|
@ -12,11 +12,8 @@ import { SearchResultsProps } from '../components/SearchResultsTable';
|
|||||||
|
|
||||||
import { DashboardSection, FolderSection } from './FolderSection';
|
import { DashboardSection, FolderSection } from './FolderSection';
|
||||||
|
|
||||||
export const FolderView = ({
|
type Props = Pick<SearchResultsProps, 'selection' | 'selectionToggle' | 'onTagSelected'> & { tags?: string[] };
|
||||||
selection,
|
export const FolderView = ({ selection, selectionToggle, onTagSelected, tags }: Props) => {
|
||||||
selectionToggle,
|
|
||||||
onTagSelected,
|
|
||||||
}: Pick<SearchResultsProps, 'selection' | 'selectionToggle' | 'onTagSelected'>) => {
|
|
||||||
const styles = useStyles2(getStyles);
|
const styles = useStyles2(getStyles);
|
||||||
|
|
||||||
const results = useAsync(async () => {
|
const results = useAsync(async () => {
|
||||||
@ -59,6 +56,7 @@ export const FolderView = ({
|
|||||||
selectionToggle={selectionToggle}
|
selectionToggle={selectionToggle}
|
||||||
onTagSelected={onTagSelected}
|
onTagSelected={onTagSelected}
|
||||||
section={section}
|
section={section}
|
||||||
|
tags={tags}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@ -131,7 +131,9 @@ export const SearchView = ({ showManage, folderDTO, queryText }: SearchViewProps
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return <FolderView selection={selection} selectionToggle={toggleSelection} onTagSelected={onTagAdd} />;
|
return (
|
||||||
|
<FolderView selection={selection} selectionToggle={toggleSelection} tags={query.tag} onTagSelected={onTagAdd} />
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user