diff --git a/src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterEnvironmentDrawer/ClusterEnvironmentDrawer.tsx b/src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterEnvironmentDrawer/ClusterEnvironmentDrawer.tsx index 69ca90897e..f871f51288 100644 --- a/src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterEnvironmentDrawer/ClusterEnvironmentDrawer.tsx +++ b/src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterEnvironmentDrawer/ClusterEnvironmentDrawer.tsx @@ -232,7 +232,7 @@ export const ClusterEnvironmentDrawer = ({ const clusterNamespace = getClusterNamespaceByName(clusterNamespacesData, formData.namespace) setNamespaceLabels({ labels: getNamespaceLabels(clusterNamespace), - resourceVersion: clusterNamespace.resourceVersion, + resourceVersion: clusterNamespace?.resourceVersion, }) } else { showError(err) diff --git a/src/components/Navigation/utils.ts b/src/components/Navigation/utils.ts index 27a89bff0b..90568255d9 100644 --- a/src/components/Navigation/utils.ts +++ b/src/components/Navigation/utils.ts @@ -6,7 +6,7 @@ import { } from '@devtron-labs/devtron-fe-common-lib' const getNavigationTreeItems = (items: NavigationItemType['subItems']) => - items.map(({ title, id, href, disabled }) => ({ + (items ?? []).map(({ title, id, href, disabled }) => ({ id, title, href, @@ -96,16 +96,20 @@ const isSubPath = (basePath: string, targetPath: string) => { * @returns True if the item matches the path, otherwise false. */ export const doesNavigationItemMatchPath = ( - item: NavigationItemType | NavigationItemType['subItems'][0], + item: NavigationItemType | NavigationItemType['subItems'][0] | undefined | null, pathname: string, ): boolean => { + if (!item) { + return false + } + const navItem = item as NavigationItemType if (navItem.hasSubMenu && navItem.subItems) { return navItem.subItems.some((subItem) => !subItem.disabled && doesNavigationItemMatchPath(subItem, pathname)) } - return !navItem.disabled && item.href && isSubPath(item.href, pathname) + return !navItem.disabled && !!item.href && isSubPath(item.href, pathname) } /** diff --git a/src/components/common/navigation/NavRoutes.components.tsx b/src/components/common/navigation/NavRoutes.components.tsx index 0c932685ce..fb1b1e1dcb 100644 --- a/src/components/common/navigation/NavRoutes.components.tsx +++ b/src/components/common/navigation/NavRoutes.components.tsx @@ -15,7 +15,7 @@ */ import { lazy, useEffect, useMemo, useState } from 'react' -import { generatePath, Navigate, Route, Routes, useLocation } from 'react-router-dom' +import { generatePath, Navigate, Route, Routes, useLocation, useParams } from 'react-router-dom' import * as Sentry from '@sentry/browser' import { @@ -72,6 +72,16 @@ export const RedirectUserWithSentry = ({ isFirstLoginUser }: { isFirstLoginUser: return } +export const RedirectOldDevtronAppRoute = () => { + const { '*': splat } = useParams() + return ( + + ) +} + const DEVTRON_APP_ROUTES = BASE_ROUTES.APPLICATION_MANAGEMENT.DEVTRON_APP export const DevtronAppRouter = () => { diff --git a/src/components/common/navigation/NavigationRoutes.tsx b/src/components/common/navigation/NavigationRoutes.tsx index 5985505849..bf25cb188d 100644 --- a/src/components/common/navigation/NavigationRoutes.tsx +++ b/src/components/common/navigation/NavigationRoutes.tsx @@ -96,7 +96,11 @@ import { importComponentFromFELibrary, setActionWithExpiry } from '../helpers/He import { SidePanel } from '../SidePanel' import { ErrorBoundary } from '..' import { ENVIRONMENT_DATA_FALLBACK, INITIAL_ENV_DATA_STATE, NAVBAR_WIDTH } from './constants' -import { AutomationAndEnablementRouter, RedirectUserWithSentry } from './NavRoutes.components' +import { + AutomationAndEnablementRouter, + RedirectOldDevtronAppRoute, + RedirectUserWithSentry, +} from './NavRoutes.components' import { EnvironmentDataStateType, NavigationRoutesTypes } from './types' import UpgradeToOSSPlusDialog from './UpgradeToOSSPlusDialog' @@ -670,6 +674,7 @@ const NavigationRoutes = ({ reloadVersionConfig }: Readonly} /> )} + } />