mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 15:45:43 -06:00
Pin Nav Items: Add tracking for pinned items clicks (#90803)
* Pin Nav Items: Add tracking for pinned items clicks * Update id * Simplify onClick logic
This commit is contained in:
parent
888417c01b
commit
8966083132
@ -49,6 +49,7 @@ const (
|
||||
NavIDCfgGeneral = "cfg/general"
|
||||
NavIDCfgPlugins = "cfg/plugins"
|
||||
NavIDCfgAccess = "cfg/access"
|
||||
NavIDBookmarks = "bookmarks"
|
||||
)
|
||||
|
||||
type NavLink struct {
|
||||
@ -70,6 +71,7 @@ type NavLink struct {
|
||||
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"`
|
||||
ParentItem *NavLink `json:"parentItem,omitempty"` // (Optional) The parent item of the nav link
|
||||
}
|
||||
|
||||
func (node *NavLink) Sort() {
|
||||
|
@ -168,7 +168,7 @@ func (s *ServiceImpl) GetNavTree(c *contextmodel.ReqContext, prefs *pref.Prefere
|
||||
|
||||
treeRoot.AddSection(&navtree.NavLink{
|
||||
Text: "Bookmarks",
|
||||
Id: "bookmarks",
|
||||
Id: navtree.NavIDBookmarks,
|
||||
Icon: "bookmark",
|
||||
SortWeight: navtree.WeightBookmarks,
|
||||
Children: bookmarks,
|
||||
@ -355,6 +355,7 @@ func (s *ServiceImpl) buildBookmarksNavLinks(prefs *pref.Preference, treeRoot *n
|
||||
PluginID: item.PluginID,
|
||||
IsCreateAction: item.IsCreateAction,
|
||||
Keywords: item.Keywords,
|
||||
ParentItem: &navtree.NavLink{Id: navtree.NavIDBookmarks},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ export const enrichWithInteractionTracking = (item: NavModelItem, megaMenuDocked
|
||||
reportInteraction('grafana_navigation_item_clicked', {
|
||||
path: newItem.url ?? newItem.id,
|
||||
menuIsDocked: megaMenuDockedState,
|
||||
itemIsBookmarked: Boolean(config.featureToggles.pinNavItems && newItem?.parentItem?.id === 'bookmarks'),
|
||||
});
|
||||
onClick?.();
|
||||
};
|
||||
|
@ -59,9 +59,7 @@ const navTreeSlice = createSlice({
|
||||
const { item, isSaved } = action.payload;
|
||||
if (bookmarks) {
|
||||
if (isSaved) {
|
||||
if (!bookmarks.children) {
|
||||
bookmarks.children = [];
|
||||
}
|
||||
bookmarks.children ||= [];
|
||||
const newBookmark: NavModelItem = {
|
||||
...item,
|
||||
// Clear the children, sortWeight and empty message of the item
|
||||
@ -69,6 +67,7 @@ const navTreeSlice = createSlice({
|
||||
sortWeight: 0,
|
||||
emptyMessageId: '',
|
||||
emptyMessage: '',
|
||||
parentItem: { id: bookmarks.id, text: bookmarks.text },
|
||||
};
|
||||
bookmarks.children.push(newBookmark);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user