Connections: Pass keywords from the backend to CommandPalette (#80276)

* pass keywords from the backend to CommandPalette

* add csv and json to keywords
pull/80539/head
Ashley Harrison 1 year ago committed by GitHub
parent 343422537e
commit 15af2e5053
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      packages/grafana-data/src/types/navModel.ts
  2. 1
      pkg/services/navtree/models.go
  3. 1
      pkg/services/navtree/navtreeimpl/navtree.go
  4. 3
      public/app/features/commandPalette/actions/staticActions.ts

@ -26,6 +26,8 @@ export interface NavLinkDTO {
pluginId?: string;
// Whether the page is used to create a new resource. We may place these in a different position in the UI.
isCreateAction?: boolean;
// Optional keywords to match on when searching (e.g. in the CommandPalette)
keywords?: string[];
}
export interface NavModelItem extends NavLinkDTO {

@ -67,6 +67,7 @@ type NavLink struct {
EmptyMessageId string `json:"emptyMessageId,omitempty"`
PluginID string `json:"pluginId,omitempty"` // (Optional) The ID of the plugin that registered nav link (e.g. as a standalone plugin page)
IsCreateAction bool `json:"isCreateAction,omitempty"`
Keywords []string `json:"keywords,omitempty"`
}
func (node *NavLink) Sort() {

@ -500,6 +500,7 @@ func (s *ServiceImpl) buildDataConnectionsNavLink(c *contextmodel.ReqContext) *n
SubTitle: "Browse and create new connections",
Url: baseUrl + "/add-new-connection",
Children: []*navtree.NavLink{},
Keywords: []string{"csv", "graphite", "json", "loki", "prometheus", "sql", "tempo"},
})
// Data sources

@ -22,7 +22,7 @@ function navTreeToActions(navTree: NavModelItem[], parents: NavModelItem[] = [])
navItem = enrichHelpItem({ ...navItem });
delete navItem.url;
}
const { url, target, text, isCreateAction, children, onClick } = navItem;
const { url, target, text, isCreateAction, children, onClick, keywords } = navItem;
const hasChildren = Boolean(children?.length);
if (!(url || onClick || hasChildren)) {
@ -44,6 +44,7 @@ function navTreeToActions(navTree: NavModelItem[], parents: NavModelItem[] = [])
target,
parent: parents.length > 0 && !isCreateAction ? idForNavItem(parents[parents.length - 1]) : undefined,
perform: onClick,
keywords: keywords?.join(' '),
priority: priority,
subtitle: isCreateAction ? undefined : subtitle,
};

Loading…
Cancel
Save