diff --git a/packages/grafana-data/src/types/navModel.ts b/packages/grafana-data/src/types/navModel.ts index 405924b4757..2c83bb45753 100644 --- a/packages/grafana-data/src/types/navModel.ts +++ b/packages/grafana-data/src/types/navModel.ts @@ -7,17 +7,13 @@ export interface NavLinkDTO { id?: string; text: string; description?: string; - section?: NavSection; subTitle?: string; icon?: IconName; img?: string; url?: string; target?: LinkTarget; sortWeight?: number; - divider?: boolean; - hideFromMenu?: boolean; hideFromTabs?: boolean; - showIconInNavbar?: boolean; roundIcon?: boolean; /** * This is true for some sections that have no children (but is still a section) @@ -47,12 +43,6 @@ export interface NavModelItem extends NavLinkDTO { emptyMessage?: string; } -export enum NavSection { - Core = 'core', - Plugin = 'plugin', - Config = 'config', -} - export enum NavMenuItemType { Section = 'section', Item = 'item', diff --git a/pkg/services/navtree/models.go b/pkg/services/navtree/models.go index e8130651b0c..a2313976b10 100644 --- a/pkg/services/navtree/models.go +++ b/pkg/services/navtree/models.go @@ -17,23 +17,17 @@ const ( WeightDashboard WeightExplore WeightAlerting - WeightPlugin - WeightConfig WeightAlertsAndIncidents WeightMonitoring WeightDataConnections WeightApps + WeightPlugin + WeightConfig WeightAdmin WeightProfile WeightHelp ) -const ( - NavSectionCore string = "core" - NavSectionPlugin string = "plugin" - NavSectionConfig string = "config" -) - const ( NavIDRoot = "root" NavIDDashboards = "dashboards" @@ -49,27 +43,23 @@ const ( ) type NavLink struct { - Id string `json:"id,omitempty"` - Text string `json:"text"` - Section string `json:"section,omitempty"` - SubTitle string `json:"subTitle,omitempty"` - Icon string `json:"icon,omitempty"` // Available icons can be browsed in Storybook: https://developers.grafana.com/ui/latest/index.html?path=/story/docs-overview-icon--icons-overview - Img string `json:"img,omitempty"` - Url string `json:"url,omitempty"` - Target string `json:"target,omitempty"` - SortWeight int64 `json:"sortWeight,omitempty"` - Divider bool `json:"divider,omitempty"` - HideFromMenu bool `json:"hideFromMenu,omitempty"` - HideFromTabs bool `json:"hideFromTabs,omitempty"` - ShowIconInNavbar bool `json:"showIconInNavbar,omitempty"` - RoundIcon bool `json:"roundIcon,omitempty"` - IsSection bool `json:"isSection,omitempty"` - Children []*NavLink `json:"children,omitempty"` - HighlightText string `json:"highlightText,omitempty"` - HighlightID string `json:"highlightId,omitempty"` - 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"` + Id string `json:"id,omitempty"` + Text string `json:"text"` + SubTitle string `json:"subTitle,omitempty"` + Icon string `json:"icon,omitempty"` // Available icons can be browsed in Storybook: https://developers.grafana.com/ui/latest/index.html?path=/story/docs-overview-icon--icons-overview + Img string `json:"img,omitempty"` + Url string `json:"url,omitempty"` + Target string `json:"target,omitempty"` + SortWeight int64 `json:"sortWeight,omitempty"` + HideFromTabs bool `json:"hideFromTabs,omitempty"` + RoundIcon bool `json:"roundIcon,omitempty"` + IsSection bool `json:"isSection,omitempty"` + Children []*NavLink `json:"children,omitempty"` + HighlightText string `json:"highlightText,omitempty"` + HighlightID string `json:"highlightId,omitempty"` + 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"` } func (node *NavLink) Sort() { diff --git a/pkg/services/navtree/navtreeimpl/admin.go b/pkg/services/navtree/navtreeimpl/admin.go index 65a156c9cdd..4bc69dc6d11 100644 --- a/pkg/services/navtree/navtreeimpl/admin.go +++ b/pkg/services/navtree/navtreeimpl/admin.go @@ -96,7 +96,6 @@ func (s *ServiceImpl) getOrgAdminNode(c *contextmodel.ReqContext) (*navtree.NavL Text: "Configuration", SubTitle: "Organization: " + c.OrgName, Icon: "cog", - Section: navtree.NavSectionConfig, SortWeight: navtree.WeightConfig, Children: configNodes, } @@ -161,7 +160,6 @@ func (s *ServiceImpl) getServerAdminNode(c *contextmodel.ReqContext) *navtree.Na Id: navtree.NavIDAdmin, Icon: "shield", SortWeight: navtree.WeightAdmin, - Section: navtree.NavSectionConfig, Children: adminNavLinks, } diff --git a/pkg/services/navtree/navtreeimpl/applinks.go b/pkg/services/navtree/navtreeimpl/applinks.go index 362e7c82161..6c74399b50a 100644 --- a/pkg/services/navtree/navtreeimpl/applinks.go +++ b/pkg/services/navtree/navtreeimpl/applinks.go @@ -71,7 +71,6 @@ func (s *ServiceImpl) processAppPlugin(plugin plugins.PluginDTO, c *contextmodel Id: "plugin-page-" + plugin.ID, Img: plugin.Info.Logos.Small, SubTitle: plugin.Info.Description, - Section: navtree.NavSectionPlugin, SortWeight: navtree.WeightPlugin, IsSection: true, PluginID: plugin.ID, @@ -201,7 +200,6 @@ func (s *ServiceImpl) addPluginToSection(c *contextmodel.ReqContext, treeRoot *n SubTitle: "App plugins that extend the Grafana experience", Id: navtree.NavIDApps, Children: []*navtree.NavLink{appLink}, - Section: navtree.NavSectionCore, SortWeight: navtree.WeightApps, Url: s.cfg.AppSubURL + "/apps", }) @@ -211,7 +209,6 @@ func (s *ServiceImpl) addPluginToSection(c *contextmodel.ReqContext, treeRoot *n Id: navtree.NavIDMonitoring, SubTitle: "Monitoring and infrastructure apps", Icon: "heart-rate", - Section: navtree.NavSectionCore, SortWeight: navtree.WeightMonitoring, Children: []*navtree.NavLink{appLink}, Url: s.cfg.AppSubURL + "/monitoring", @@ -228,7 +225,6 @@ func (s *ServiceImpl) addPluginToSection(c *contextmodel.ReqContext, treeRoot *n Id: navtree.NavIDAlertsAndIncidents, SubTitle: "Alerting and incident management apps", Icon: "bell", - Section: navtree.NavSectionCore, SortWeight: navtree.WeightAlertsAndIncidents, Children: alertsAndIncidentsChildren, Url: s.cfg.AppSubURL + "/alerts-and-incidents", diff --git a/pkg/services/navtree/navtreeimpl/navtree.go b/pkg/services/navtree/navtreeimpl/navtree.go index 881378a54c7..f36d5d23530 100644 --- a/pkg/services/navtree/navtreeimpl/navtree.go +++ b/pkg/services/navtree/navtreeimpl/navtree.go @@ -89,7 +89,6 @@ func (s *ServiceImpl) GetNavTree(c *contextmodel.ReqContext, hasEditPerm bool, p Id: "starred", Icon: "star", SortWeight: navtree.WeightSavedItems, - Section: navtree.NavSectionCore, Children: starredItemsLinks, EmptyMessageId: "starred-empty", Url: s.cfg.AppSubURL + "/dashboards?starred", @@ -106,7 +105,6 @@ func (s *ServiceImpl) GetNavTree(c *contextmodel.ReqContext, hasEditPerm bool, p Icon: "apps", Url: s.cfg.AppSubURL + "/dashboards", SortWeight: navtree.WeightDashboard, - Section: navtree.NavSectionCore, Children: dashboardChildLinks, } @@ -124,7 +122,6 @@ func (s *ServiceImpl) GetNavTree(c *contextmodel.ReqContext, hasEditPerm bool, p SubTitle: "Explore your data", Icon: "compass", SortWeight: navtree.WeightExplore, - Section: navtree.NavSectionCore, Url: s.cfg.AppSubURL + "/explore", }) } @@ -192,7 +189,6 @@ func (s *ServiceImpl) getHomeNode(c *contextmodel.ReqContext, prefs *pref.Prefer Id: "home", Url: homeUrl, Icon: "home-alt", - Section: navtree.NavSectionCore, SortWeight: navtree.WeightHome, } return homeNode @@ -216,7 +212,6 @@ func (s *ServiceImpl) addHelpLinks(treeRoot *navtree.NavTreeRoot, c *contextmode Url: "#", Icon: "question-circle", SortWeight: navtree.WeightHelp, - Section: navtree.NavSectionConfig, Children: []*navtree.NavLink{}, } @@ -234,7 +229,6 @@ func (s *ServiceImpl) addHelpLinks(treeRoot *navtree.NavTreeRoot, c *contextmode Id: "support-bundles", Url: "/support-bundles", Icon: "wrench", - Section: navtree.NavSectionConfig, SortWeight: navtree.WeightHelp, } @@ -286,7 +280,6 @@ func (s *ServiceImpl) getProfileNode(c *contextmodel.ReqContext) *navtree.NavLin Id: "profile", Img: gravatarURL, Url: s.cfg.AppSubURL + "/profile", - Section: navtree.NavSectionConfig, SortWeight: navtree.WeightProfile, Children: children, RoundIcon: true, @@ -387,12 +380,12 @@ func (s *ServiceImpl) buildDashboardNavLinks(c *contextmodel.ReqContext, hasEdit if hasEditPerm { if hasAccess(hasEditPermInAnyFolder, ac.EvalPermission(dashboards.ActionDashboardsCreate)) { dashboardChildNavs = append(dashboardChildNavs, &navtree.NavLink{ - Text: "New dashboard", Icon: "plus", Url: s.cfg.AppSubURL + "/dashboard/new", HideFromTabs: true, Id: "dashboards/new", ShowIconInNavbar: true, IsCreateAction: true, + Text: "New dashboard", Icon: "plus", Url: s.cfg.AppSubURL + "/dashboard/new", HideFromTabs: true, Id: "dashboards/new", IsCreateAction: true, }) dashboardChildNavs = append(dashboardChildNavs, &navtree.NavLink{ Text: "Import dashboard", SubTitle: "Import dashboard from file or Grafana.com", Id: "dashboards/import", Icon: "plus", - Url: s.cfg.AppSubURL + "/dashboard/import", HideFromTabs: true, ShowIconInNavbar: true, IsCreateAction: true, + Url: s.cfg.AppSubURL + "/dashboard/import", HideFromTabs: true, IsCreateAction: true, }) } } @@ -419,7 +412,6 @@ func (s *ServiceImpl) buildLegacyAlertNavLinks(c *contextmodel.ReqContext) *navt Id: "alerting-legacy", Icon: "bell", Children: alertChildNavs, - Section: navtree.NavSectionCore, SortWeight: navtree.WeightAlerting, Url: s.cfg.AppSubURL + "/alerting", } @@ -462,7 +454,7 @@ func (s *ServiceImpl) buildAlertNavLinks(c *contextmodel.ReqContext, hasEditPerm if hasAccess(fallbackHasEditPerm, ac.EvalAny(ac.EvalPermission(ac.ActionAlertingRuleCreate), ac.EvalPermission(ac.ActionAlertingRuleExternalWrite))) { alertChildNavs = append(alertChildNavs, &navtree.NavLink{ Text: "Create alert rule", SubTitle: "Create an alert rule", Id: "alert", - Icon: "plus", Url: s.cfg.AppSubURL + "/alerting/new", HideFromTabs: true, ShowIconInNavbar: true, IsCreateAction: true, + Icon: "plus", Url: s.cfg.AppSubURL + "/alerting/new", HideFromTabs: true, IsCreateAction: true, }) } @@ -473,7 +465,6 @@ func (s *ServiceImpl) buildAlertNavLinks(c *contextmodel.ReqContext, hasEditPerm Id: navtree.NavIDAlerting, Icon: "bell", Children: alertChildNavs, - Section: navtree.NavSectionCore, SortWeight: navtree.WeightAlerting, Url: s.cfg.AppSubURL + "/alerting", } @@ -527,7 +518,6 @@ func (s *ServiceImpl) buildDataConnectionsNavLink(c *contextmodel.ReqContext) *n Id: "connections", Url: baseUrl, Children: children, - Section: navtree.NavSectionCore, SortWeight: navtree.WeightDataConnections, } diff --git a/public/app/core/components/AppChrome/MegaMenu/MegaMenu.test.tsx b/public/app/core/components/AppChrome/MegaMenu/MegaMenu.test.tsx index 49f7d60176a..a411c977ff9 100644 --- a/public/app/core/components/AppChrome/MegaMenu/MegaMenu.test.tsx +++ b/public/app/core/components/AppChrome/MegaMenu/MegaMenu.test.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { Router } from 'react-router-dom'; import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock'; -import { NavModelItem, NavSection } from '@grafana/data'; +import { NavModelItem } from '@grafana/data'; import { locationService } from '@grafana/runtime'; import { TestProvider } from '../../../../../test/helpers/TestProvider'; @@ -14,7 +14,6 @@ const setup = () => { const navBarTree: NavModelItem[] = [ { text: 'Section name', - section: NavSection.Core, id: 'section', url: 'section', children: [ @@ -25,7 +24,6 @@ const setup = () => { { text: 'Profile', id: 'profile', - section: NavSection.Config, url: 'profile', }, ]; diff --git a/public/app/core/components/AppChrome/MegaMenu/MegaMenu.tsx b/public/app/core/components/AppChrome/MegaMenu/MegaMenu.tsx index 607a5beabd3..72b90257473 100644 --- a/public/app/core/components/AppChrome/MegaMenu/MegaMenu.tsx +++ b/public/app/core/components/AppChrome/MegaMenu/MegaMenu.tsx @@ -3,12 +3,12 @@ import { cloneDeep } from 'lodash'; import React from 'react'; import { useLocation } from 'react-router-dom'; -import { GrafanaTheme2, NavSection } from '@grafana/data'; +import { GrafanaTheme2 } from '@grafana/data'; import { useTheme2 } from '@grafana/ui'; import { useSelector } from 'app/types'; import { NavBarMenu } from './NavBarMenu'; -import { enrichConfigItems, enrichWithInteractionTracking, getActiveItem } from './utils'; +import { enrichWithInteractionTracking, getActiveItem } from './utils'; export interface Props { onClose: () => void; @@ -23,15 +23,10 @@ export const MegaMenu = React.memo(({ onClose, searchBarHidden }) => { const navTree = cloneDeep(navBarTree); - const coreItems = navTree - .filter((item) => item.section === NavSection.Core || item.section === NavSection.Plugin) + // Remove profile + help from tree + const navItems = navTree + .filter((item) => item.id !== 'profile' && item.id !== 'help') .map((item) => enrichWithInteractionTracking(item, true)); - const configItems = enrichConfigItems( - navTree.filter((item) => item.section === NavSection.Config && item && item.id !== 'help' && item.id !== 'profile'), - location - ).map((item) => enrichWithInteractionTracking(item, true)); - - const navItems = [...coreItems, ...configItems]; const activeItem = getActiveItem(navItems, location.pathname); diff --git a/public/app/core/components/AppChrome/MegaMenu/NavBarMenuItemWrapper.tsx b/public/app/core/components/AppChrome/MegaMenu/NavBarMenuItemWrapper.tsx index ac5deb8cd9c..d64073c6f6c 100644 --- a/public/app/core/components/AppChrome/MegaMenu/NavBarMenuItemWrapper.tsx +++ b/public/app/core/components/AppChrome/MegaMenu/NavBarMenuItemWrapper.tsx @@ -2,7 +2,7 @@ import { css } from '@emotion/css'; import React from 'react'; import { GrafanaTheme2, NavModelItem } from '@grafana/data'; -import { toIconName, useStyles2 } from '@grafana/ui'; +import { useStyles2 } from '@grafana/ui'; import { NavBarMenuItem } from './NavBarMenuItem'; import { NavBarMenuSection } from './NavBarMenuSection'; @@ -34,14 +34,12 @@ export function NavBarMenuItemWrapper({ {linkHasChildren(link) && (