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