Skip to content

Commit 8455dd5

Browse files
Merge pull request #2812 from devtron-labs/fix/resource-recommender-grafana
feat: add Grafana module installation status handling in NavigationRoutes
2 parents 933a314 + 3806100 commit 8455dd5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/components/common/navigation/NavigationRoutes.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ const NavigationRoutes = ({ reloadVersionConfig }: Readonly<NavigationRoutesType
149149
const showCloseButtonAfterGettingStartedClicked = () => {
150150
setHelpGettingStartedClicked(true)
151151
}
152+
// We use this to determine if we can show resource recommender, since we do not allow users to feed prometheus url if grafana module is not installed
153+
const [isGrafanaModuleInstalled, setIsGrafanaModuleInstalled] = useState(false)
152154
const [environmentId, setEnvironmentId] = useState(null)
153155
const contextValue = useMemo(() => ({ environmentId, setEnvironmentId }), [environmentId])
154156

@@ -387,17 +389,21 @@ const NavigationRoutes = ({ reloadVersionConfig }: Readonly<NavigationRoutesType
387389
}
388390
}
389391

392+
const getGrafanaModuleStatus = () => getModuleInfo(ModuleNameMap.GRAFANA)
393+
390394
const handleFetchInitialData = async () => {
391395
try {
392-
const [serverModeResponse, environmentDataResponse] = await Promise.all([
396+
const [serverModeResponse, environmentDataResponse, grafanaModuleStatus] = await Promise.all([
393397
getServerMode(),
394398
getEnvironmentDataValues(),
399+
getGrafanaModuleStatus(),
395400
getCurrentServerInfo(),
396401
handleFetchUserPreferences(),
397402
])
398403

399404
await getInit(serverModeResponse)
400405

406+
setIsGrafanaModuleInstalled(grafanaModuleStatus?.result?.status === ModuleStatus.INSTALLED)
401407
setEnvironmentDataState({
402408
isAirgapped: environmentDataResponse.isAirGapEnvironment,
403409
isManifestScanningEnabled: environmentDataResponse.isManifestScanningEnabled,
@@ -663,7 +669,8 @@ const NavigationRoutes = ({ reloadVersionConfig }: Readonly<NavigationRoutesType
663669
setSidePanelConfig,
664670
isEnterprise: currentServerInfo?.serverInfo?.installationType === InstallationType.ENTERPRISE,
665671
isFELibAvailable: !!isFELibAvailable,
666-
isResourceRecommendationEnabled: environmentDataState.isResourceRecommendationEnabled,
672+
isResourceRecommendationEnabled:
673+
isGrafanaModuleInstalled && environmentDataState.isResourceRecommendationEnabled,
667674
}}
668675
>
669676
<ConfirmationModalProvider>

0 commit comments

Comments
 (0)