From b4f73c9f09e738265c3ac9ef961fee4ed7b9b2c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 29 Sep 2022 13:27:51 +0200 Subject: [PATCH] PluginPages: Support plugin pages that don't belong to a section (#55904) * Fixing pages that don't exist in navtree * Fix test * fix lint warning * Fixes --- pkg/services/navtree/navtreeimpl/applinks.go | 2 +- public/app/core/components/PageNew/Page.tsx | 2 +- .../core/components/PageNew/SectionNav.tsx | 4 ++ .../plugins/components/AppRootPage.tsx | 15 +----- .../plugins/components/PluginPageContext.tsx | 2 +- public/app/features/plugins/utils.test.ts | 10 ++-- public/app/features/plugins/utils.ts | 54 +++++++++++-------- 7 files changed, 44 insertions(+), 45 deletions(-) diff --git a/pkg/services/navtree/navtreeimpl/applinks.go b/pkg/services/navtree/navtreeimpl/applinks.go index d6a8978f759..88b52e62b5b 100644 --- a/pkg/services/navtree/navtreeimpl/applinks.go +++ b/pkg/services/navtree/navtreeimpl/applinks.go @@ -85,7 +85,7 @@ func (s *ServiceImpl) processAppPlugin(plugin plugins.PluginDTO, c *models.ReqCo SortWeight: navtree.WeightPlugin, } - if s.features.IsEnabled(featuremgmt.FlagTopnav) { + if topNavEnabled { appLink.Url = s.cfg.AppSubURL + "/a/" + plugin.ID } else { appLink.Url = path.Join(s.cfg.AppSubURL, plugin.DefaultNavURL) diff --git a/public/app/core/components/PageNew/Page.tsx b/public/app/core/components/PageNew/Page.tsx index 1ad41a503b4..4e39f9a8701 100644 --- a/public/app/core/components/PageNew/Page.tsx +++ b/public/app/core/components/PageNew/Page.tsx @@ -50,7 +50,7 @@ export const Page: PageType = ({
{layout === PageLayoutType.Standard && (
- {navModel && navModel.main.children && } + {navModel && }
diff --git a/public/app/core/components/PageNew/SectionNav.tsx b/public/app/core/components/PageNew/SectionNav.tsx index 59c31a5bde9..58d2fc57669 100644 --- a/public/app/core/components/PageNew/SectionNav.tsx +++ b/public/app/core/components/PageNew/SectionNav.tsx @@ -13,6 +13,10 @@ export interface Props { export function SectionNav({ model }: Props) { const styles = useStyles2(getStyles); + if (!Boolean(model.main?.children?.length)) { + return null; + } + return (