Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 7 additions & 3 deletions src/components/Navigation/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '@devtron-labs/devtron-fe-common-lib'

const getNavigationTreeItems = (items: NavigationItemType['subItems']) =>
items.map<TreeNode>(({ title, id, href, disabled }) => ({
(items ?? []).map<TreeNode>(({ title, id, href, disabled }) => ({
id,
title,
href,
Expand Down Expand Up @@ -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)
}

/**
Expand Down
12 changes: 11 additions & 1 deletion src/components/common/navigation/NavRoutes.components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -72,6 +72,16 @@ export const RedirectUserWithSentry = ({ isFirstLoginUser }: { isFirstLoginUser:
return <Navigate to={redirectPath} replace />
}

export const RedirectOldDevtronAppRoute = () => {
const { '*': splat } = useParams()
return (
<Navigate
to={`/${BASE_ROUTES.APPLICATION_MANAGEMENT.ROOT}/${BASE_ROUTES.APPLICATION_MANAGEMENT.DEVTRON_APP.ROOT}/${splat}`}
replace
/>
)
}

const DEVTRON_APP_ROUTES = BASE_ROUTES.APPLICATION_MANAGEMENT.DEVTRON_APP

export const DevtronAppRouter = () => {
Expand Down
7 changes: 6 additions & 1 deletion src/components/common/navigation/NavigationRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -670,6 +674,7 @@ const NavigationRoutes = ({ reloadVersionConfig }: Readonly<NavigationRoutesType
element={<DataProtectionManagementRouter />}
/>
)}
<Route path="app/*" element={<RedirectOldDevtronAppRoute />} />
<Route
path="*"
element={
Expand Down
Loading