PanelTitleSearch: Show datasource usage in plugins (#83922)

This commit is contained in:
Ryan McKinley 2024-03-05 12:20:38 -08:00 committed by GitHub
parent cb008657cb
commit 3e86a4edc8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 3 deletions

View File

@ -435,6 +435,12 @@ func doSearchQuery(
hasConstraints = true
}
// DatasourceType
if q.DatasourceType != "" {
fullQuery.AddMust(bluge.NewTermQuery(q.DatasourceType).SetField(documentFieldDSType))
hasConstraints = true
}
// Folder
if q.Location != "" {
fullQuery.AddMust(bluge.NewTermQuery(q.Location).SetField(documentFieldLocation))

View File

@ -18,7 +18,7 @@ type DashboardQuery struct {
Query string `json:"query"`
Location string `json:"location,omitempty"` // parent folder ID
Sort string `json:"sort,omitempty"` // field ASC/DESC
Datasource string `json:"ds_uid,omitempty"` // "datasource" collides with the JSON value at the same leel :()
Datasource string `json:"ds_uid,omitempty"` // "datasource" collides with the JSON value at the same level :()
DatasourceType string `json:"ds_type,omitempty"`
Tags []string `json:"tags,omitempty"`
Kind []string `json:"kind,omitempty"`

View File

@ -4,7 +4,7 @@ import { useAsync } from 'react-use';
import AutoSizer from 'react-virtualized-auto-sizer';
import { of } from 'rxjs';
import { GrafanaTheme2, PluginMeta } from '@grafana/data';
import { GrafanaTheme2, PluginMeta, PluginType } from '@grafana/data';
import { config } from '@grafana/runtime';
import { Alert, Spinner, useStyles2 } from '@grafana/ui';
import EmptyListCTA from 'app/core/components/EmptyListCTA/EmptyListCTA';
@ -19,6 +19,13 @@ export function PluginUsage({ plugin }: Props) {
const styles = useStyles2(getStyles);
const searchQuery = useMemo<SearchQuery>(() => {
if (plugin.type === PluginType.datasource) {
return {
query: '*',
ds_type: plugin.id,
kind: ['dashboard'],
};
}
return {
query: '*',
panel_type: plugin.id,

View File

@ -51,7 +51,10 @@ export const usePluginDetailsTabs = (plugin?: CatalogPlugin, pageId?: PluginTabI
});
}
if (config.featureToggles.panelTitleSearch && pluginConfig.meta.type === PluginType.panel) {
if (
config.featureToggles.panelTitleSearch &&
(pluginConfig.meta.type === PluginType.panel || pluginConfig.meta.type === PluginType.datasource)
) {
navModelChildren.push({
text: PluginTabLabels.USAGE,
icon: 'list-ul',