From b925ae0ff0412aaac7c45bcce05763996a408073 Mon Sep 17 00:00:00 2001 From: Fabio Silva Date: Thu, 9 Jul 2026 11:52:38 +0100 Subject: [PATCH 1/2] fix: always show alerting for anon users --- .../navigation/navigation.provider.tsx | 39 ++++++++----------- .../contexts/navigation/navigation.utils.tsx | 22 ++++++----- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/ui/apps/pmm/src/contexts/navigation/navigation.provider.tsx b/ui/apps/pmm/src/contexts/navigation/navigation.provider.tsx index f2d979fa101..4656b386e1d 100644 --- a/ui/apps/pmm/src/contexts/navigation/navigation.provider.tsx +++ b/ui/apps/pmm/src/contexts/navigation/navigation.provider.tsx @@ -30,9 +30,11 @@ import { useFolders } from 'hooks/api/useFolders'; import { useUpdates } from 'contexts/updates'; import { useLocalStorage } from 'hooks/utils/useLocalStorage'; import { useHaInfo } from 'hooks/api/useHA'; +import { useAuth } from 'contexts/auth'; export const NavigationProvider: FC = ({ children }) => { const { user } = useUser(); + const { isLoggedIn } = useAuth(); const { data: serviceTypes } = useServiceTypes({ enabled: !!user, refetchInterval: INTERVALS_MS.SERVICE_TYPES, @@ -69,18 +71,16 @@ export const NavigationProvider: FC = ({ children }) => { items.push(NAV_QAN); - if (user && settings) { - if (settings.frontend.exploreEnabled && user.isEditor) { + if (user) { + if (settings?.frontend.exploreEnabled && user.isEditor) { items.push( addExplore('grafana-metricsdrilldown-app' in settings.frontend.apps) ); } - if (settings.frontend.unifiedAlertingEnabled) { - items.push(addAlerting(settings?.alertingEnabled, user)); - } + items.push(addAlerting(settings?.alertingEnabled, settings?.frontend.unifiedAlertingEnabled, user)); - if (user.isEditor && settings.advisorEnabled) { + if (user.isEditor && settings?.advisorEnabled) { items.push(addAdvisors(advisors || [])); } @@ -89,7 +89,7 @@ export const NavigationProvider: FC = ({ children }) => { items.push(NAV_INVENTORY); - if (settings.backupManagementEnabled) { + if (settings?.backupManagementEnabled) { items.push(NAV_BACKUPS); } @@ -97,29 +97,24 @@ export const NavigationProvider: FC = ({ children }) => { items.push(addConfiguration(status, versionInfo)); - items.push(addUsersAndAccess(settings)); + if (settings) { + items.push(addUsersAndAccess(settings)); + } } - items.push(addAccount(user, colorMode, toggleColorMode)); + if (isLoggedIn) { + items.push(addAccount(user, colorMode, toggleColorMode)); + } items.push(NAV_HELP); - } else { + } + + if (!isLoggedIn) { items.push(NAV_SIGN_IN); } return items; - }, [ - status, - versionInfo, - serviceTypes, - folders, - user, - settings, - advisors, - colorMode, - haInfo, - toggleColorMode, - ]); + }, [serviceTypes?.serviceTypes, user, haInfo, folders, settings, colorMode, toggleColorMode, advisors, status, versionInfo, isLoggedIn]); return ( { +export const addAlerting = (alertingEnabled = false, unifiedAlertingEnabled = false, user?: User): NavItem => { + const children: NavItem[] = []; - if (enabled) { - children.push(NAV_ALERTS_FIRED); - } children.push(NAV_ALERTS_RULES); children.push(NAV_ALERTS_CONTACT_POINTS); @@ -146,12 +144,18 @@ export const addAlerting = (enabled = false, user?: User): NavItem => { children.push(NAV_ALERTS_SILENCES); children.push(NAV_ALERTS_GROUPS); - if (user?.isPMMAdmin) { - children.push(NAV_ALERTS_SETTINGS); - } + if (unifiedAlertingEnabled) { + if (alertingEnabled) { + children.push(NAV_ALERTS_FIRED); + } + + if (user?.isPMMAdmin) { + children.push(NAV_ALERTS_SETTINGS); + } - if (enabled && user?.isEditor) { - children.push(NAV_ALERTS_TEMPLATES); + if (alertingEnabled && user?.isEditor) { + children.push(NAV_ALERTS_TEMPLATES); + } } return { ...NAV_ALERTS, children }; From 1975ea42c85b6b66c28ad639977670478a06034a Mon Sep 17 00:00:00 2001 From: Fabio Silva Date: Thu, 9 Jul 2026 12:07:30 +0100 Subject: [PATCH 2/2] chore: format --- .../navigation/navigation.provider.tsx | 22 +++++++++++++++++-- .../contexts/navigation/navigation.utils.tsx | 8 ++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/ui/apps/pmm/src/contexts/navigation/navigation.provider.tsx b/ui/apps/pmm/src/contexts/navigation/navigation.provider.tsx index 4656b386e1d..34b1d7cf571 100644 --- a/ui/apps/pmm/src/contexts/navigation/navigation.provider.tsx +++ b/ui/apps/pmm/src/contexts/navigation/navigation.provider.tsx @@ -78,7 +78,13 @@ export const NavigationProvider: FC = ({ children }) => { ); } - items.push(addAlerting(settings?.alertingEnabled, settings?.frontend.unifiedAlertingEnabled, user)); + items.push( + addAlerting( + settings?.alertingEnabled, + settings?.frontend.unifiedAlertingEnabled, + user + ) + ); if (user.isEditor && settings?.advisorEnabled) { items.push(addAdvisors(advisors || [])); @@ -114,7 +120,19 @@ export const NavigationProvider: FC = ({ children }) => { } return items; - }, [serviceTypes?.serviceTypes, user, haInfo, folders, settings, colorMode, toggleColorMode, advisors, status, versionInfo, isLoggedIn]); + }, [ + serviceTypes?.serviceTypes, + user, + haInfo, + folders, + settings, + colorMode, + toggleColorMode, + advisors, + status, + versionInfo, + isLoggedIn, + ]); return ( { - +export const addAlerting = ( + alertingEnabled = false, + unifiedAlertingEnabled = false, + user?: User +): NavItem => { const children: NavItem[] = []; - children.push(NAV_ALERTS_RULES); children.push(NAV_ALERTS_CONTACT_POINTS); children.push(NAV_ALERTS_NOTIFICATION_POLICIES);