diff --git a/packages/manager/src/routes/profile.tsx b/packages/manager/src/routes/profile.tsx
index 415bcaffd64..1b1eec52285 100644
--- a/packages/manager/src/routes/profile.tsx
+++ b/packages/manager/src/routes/profile.tsx
@@ -13,15 +13,15 @@ export const ProfileRoutes = () => {
);
};
-const ProfileRoute = createRoute({
+const profileRoute = createRoute({
getParentRoute: () => rootRoute,
path: 'profile',
}).lazy(() =>
import('src/features/Profile/Profile').then((m) => m.ProfileLazyRoute)
);
-const ProfileDisplaySettingsRoute = createRoute({
- getParentRoute: () => ProfileRoute,
+const profileDisplaySettingsRoute = createRoute({
+ getParentRoute: () => profileRoute,
path: 'display',
}).lazy(() =>
import('src/features/Profile/DisplaySettings/DisplaySettings').then(
@@ -29,8 +29,8 @@ const ProfileDisplaySettingsRoute = createRoute({
)
);
-const ProfileAuthenticationSettingsRoute = createRoute({
- getParentRoute: () => ProfileRoute,
+const profileAuthenticationSettingsRoute = createRoute({
+ getParentRoute: () => profileRoute,
path: 'auth',
}).lazy(() =>
import(
@@ -38,15 +38,15 @@ const ProfileAuthenticationSettingsRoute = createRoute({
).then((m) => m.authenticationSettingsLazyRoute)
);
-const ProfileSSHKeysRoute = createRoute({
- getParentRoute: () => ProfileRoute,
+const profileSSHKeysRoute = createRoute({
+ getParentRoute: () => profileRoute,
path: 'keys',
}).lazy(() =>
import('src/features/Profile/SSHKeys/SSHKeys').then((m) => m.SSHKeysLazyRoute)
);
-const ProfileLishSettingsRoute = createRoute({
- getParentRoute: () => ProfileRoute,
+const profileLishSettingsRoute = createRoute({
+ getParentRoute: () => profileRoute,
path: 'lish',
}).lazy(() =>
import('src/features/Profile/LishSettings/LishSettings').then(
@@ -54,8 +54,8 @@ const ProfileLishSettingsRoute = createRoute({
)
);
-const ProfileAPITokensRoute = createRoute({
- getParentRoute: () => ProfileRoute,
+const profileAPITokensRoute = createRoute({
+ getParentRoute: () => profileRoute,
path: 'tokens',
}).lazy(() =>
import('src/features/Profile/APITokens/APITokens').then(
@@ -63,8 +63,8 @@ const ProfileAPITokensRoute = createRoute({
)
);
-const ProfileOAuthClientsRoute = createRoute({
- getParentRoute: () => ProfileRoute,
+const profileOAuthClientsRoute = createRoute({
+ getParentRoute: () => profileRoute,
path: 'clients',
}).lazy(() =>
import('src/features/Profile/OAuthClients/OAuthClients').then(
@@ -72,8 +72,8 @@ const ProfileOAuthClientsRoute = createRoute({
)
);
-const ProfileReferralsRoute = createRoute({
- getParentRoute: () => ProfileRoute,
+const profileReferralsRoute = createRoute({
+ getParentRoute: () => profileRoute,
path: 'referrals',
}).lazy(() =>
import('src/features/Profile/Referrals/Referrals').then(
@@ -81,8 +81,8 @@ const ProfileReferralsRoute = createRoute({
)
);
-const ProfileSettingsRoute = createRoute({
- getParentRoute: () => ProfileRoute,
+const profileSettingsRoute = createRoute({
+ getParentRoute: () => profileRoute,
path: 'settings',
}).lazy(() =>
import('src/features/Profile/Settings/Settings').then(
@@ -90,13 +90,13 @@ const ProfileSettingsRoute = createRoute({
)
);
-export const profileRouteTree = ProfileRoute.addChildren([
- ProfileAuthenticationSettingsRoute,
- ProfileDisplaySettingsRoute,
- ProfileSSHKeysRoute,
- ProfileLishSettingsRoute,
- ProfileAPITokensRoute,
- ProfileOAuthClientsRoute,
- ProfileReferralsRoute,
- ProfileSettingsRoute,
+export const profileRouteTree = profileRoute.addChildren([
+ profileAuthenticationSettingsRoute,
+ profileDisplaySettingsRoute,
+ profileSSHKeysRoute,
+ profileLishSettingsRoute,
+ profileAPITokensRoute,
+ profileOAuthClientsRoute,
+ profileReferralsRoute,
+ profileSettingsRoute,
]);
diff --git a/packages/manager/src/routes/routes.test.tsx b/packages/manager/src/routes/routes.test.tsx
index bd32bf2dcb2..acb81318d46 100644
--- a/packages/manager/src/routes/routes.test.tsx
+++ b/packages/manager/src/routes/routes.test.tsx
@@ -6,23 +6,20 @@ import {
import { waitFor } from '@testing-library/react';
import React from 'react';
+import { accountSettingsFactory } from 'src/factories';
import { renderWithTheme } from 'src/utilities/testHelpers';
-import { allPaths } from './utils/allPaths';
import { routeTree } from './index';
+import { allPaths } from './utils/allPaths';
+
+import type { RouterContext } from './types';
// Mock any context or dependencies your routes might need
-const mockContext = {
- accountSettings: {},
- app: {
- features: {},
- flags: {},
- notifications: [],
- },
+const mockContext: RouterContext = {
+ accountSettings: accountSettingsFactory.build(),
isACLPEnabled: false,
isDatabasesEnabled: false,
isPlacementGroupsEnabled: false,
- selfServeBetas: false,
};
// Helper function to create a test router
diff --git a/packages/manager/src/routes/stackscripts.tsx b/packages/manager/src/routes/stackscripts.tsx
index 22757ef5df8..9a1def8fdce 100644
--- a/packages/manager/src/routes/stackscripts.tsx
+++ b/packages/manager/src/routes/stackscripts.tsx
@@ -17,14 +17,14 @@ export const StackScriptsRoutes = () => {
);
};
-const StackScriptsRoute = createRoute({
+const stackScriptsRoute = createRoute({
component: StackScriptsRoutes,
getParentRoute: () => rootRoute,
path: 'stackscripts',
});
-const StackScriptsLandingRoute = createRoute({
- getParentRoute: () => StackScriptsRoute,
+const stackScriptsLandingRoute = createRoute({
+ getParentRoute: () => stackScriptsRoute,
path: '/',
}).lazy(() =>
import('src/features/StackScripts/StackScriptsLanding').then(
@@ -32,8 +32,8 @@ const StackScriptsLandingRoute = createRoute({
)
);
-const StackScriptsAccountRoute = createRoute({
- getParentRoute: () => StackScriptsRoute,
+const stackScriptsAccountRoute = createRoute({
+ getParentRoute: () => stackScriptsRoute,
path: 'account',
}).lazy(() =>
import('src/features/StackScripts/StackScriptsLanding').then(
@@ -41,8 +41,8 @@ const StackScriptsAccountRoute = createRoute({
)
);
-const StackScriptsCommunityRoute = createRoute({
- getParentRoute: () => StackScriptsRoute,
+const stackScriptsCommunityRoute = createRoute({
+ getParentRoute: () => stackScriptsRoute,
path: 'community',
}).lazy(() =>
import('src/features/StackScripts/StackScriptsLanding').then(
@@ -50,38 +50,38 @@ const StackScriptsCommunityRoute = createRoute({
)
);
-const StackScriptsCreateRoute = createRoute({
+const stackScriptsCreateRoute = createRoute({
// TODO: TanStack Router - broken, perhaps due to being a class component.
component: () => ,
- getParentRoute: () => StackScriptsRoute,
+ getParentRoute: () => stackScriptsRoute,
path: 'create',
});
-const StackScriptsDetailRoute = createRoute({
+const stackScriptsDetailRoute = createRoute({
// TODO: TanStack Router - broken, perhaps due to being a class component.
component: () => ,
- getParentRoute: () => StackScriptsRoute,
+ getParentRoute: () => stackScriptsRoute,
parseParams: (params) => ({
stackScriptID: Number(params.stackScriptID),
}),
path: '$stackScriptID',
});
-const StackScriptsEditRoute = createRoute({
+const stackScriptsEditRoute = createRoute({
// TODO: TanStack Router - broken, perhaps due to being a class component.
component: () => ,
- getParentRoute: () => StackScriptsRoute,
+ getParentRoute: () => stackScriptsRoute,
parseParams: (params) => ({
stackScriptID: Number(params.stackScriptID),
}),
path: '$stackScriptID/edit',
});
-export const stackScriptsRouteTree = StackScriptsRoute.addChildren([
- StackScriptsLandingRoute,
- StackScriptsAccountRoute,
- StackScriptsCommunityRoute,
- StackScriptsCreateRoute,
- StackScriptsDetailRoute,
- StackScriptsEditRoute,
+export const stackScriptsRouteTree = stackScriptsRoute.addChildren([
+ stackScriptsLandingRoute,
+ stackScriptsAccountRoute,
+ stackScriptsCommunityRoute,
+ stackScriptsCreateRoute,
+ stackScriptsDetailRoute,
+ stackScriptsEditRoute,
]);
diff --git a/packages/manager/src/routes/support.tsx b/packages/manager/src/routes/support.tsx
index 49cd9ec6c71..7082ccd6b37 100644
--- a/packages/manager/src/routes/support.tsx
+++ b/packages/manager/src/routes/support.tsx
@@ -15,22 +15,22 @@ export const SupportTicketsRoutes = () => {
);
};
-const SupportRoute = createRoute({
+const supportRoute = createRoute({
// TODO: TanStackRouter - got to handle the MainContent.tsx `globalErrors.account_unactivated` logic.
component: SupportTicketsRoutes,
getParentRoute: () => rootRoute,
path: 'support',
});
-const SupportLandingRoute = createRoute({
- getParentRoute: () => SupportRoute,
+const supportLandingRoute = createRoute({
+ getParentRoute: () => supportRoute,
path: '/',
}).lazy(() =>
import('src/features/Help/HelpLanding').then((m) => m.helpLandingLazyRoute)
);
-const SupportTicketsRoute = createRoute({
- getParentRoute: () => SupportRoute,
+const supportTicketsRoute = createRoute({
+ getParentRoute: () => supportRoute,
path: 'tickets',
}).lazy(() =>
import('src/features/Support/SupportTickets/SupportTicketsLanding').then(
@@ -38,8 +38,8 @@ const SupportTicketsRoute = createRoute({
)
);
-const SupportTicketDetailRoute = createRoute({
- getParentRoute: () => SupportRoute,
+const supportTicketDetailRoute = createRoute({
+ getParentRoute: () => supportRoute,
parseParams: (params) => ({
ticketId: Number(params.ticketId),
}),
@@ -50,8 +50,8 @@ const SupportTicketDetailRoute = createRoute({
)
);
-const SupportSearchLandingRoute = createRoute({
- getParentRoute: () => SupportRoute,
+const supportSearchLandingRoute = createRoute({
+ getParentRoute: () => supportRoute,
path: 'search',
}).lazy(() =>
import('src/features/Help/SupportSearchLanding/SupportSearchLanding').then(
@@ -59,8 +59,8 @@ const SupportSearchLandingRoute = createRoute({
)
);
-export const supportRouteTree = SupportRoute.addChildren([
- SupportLandingRoute,
- SupportTicketsRoute.addChildren([SupportTicketDetailRoute]),
- SupportSearchLandingRoute,
+export const supportRouteTree = supportRoute.addChildren([
+ supportLandingRoute,
+ supportTicketsRoute.addChildren([supportTicketDetailRoute]),
+ supportSearchLandingRoute,
]);
diff --git a/packages/manager/src/routes/types.ts b/packages/manager/src/routes/types.ts
index b4998f1f250..dfcb907463f 100644
--- a/packages/manager/src/routes/types.ts
+++ b/packages/manager/src/routes/types.ts
@@ -1,6 +1,7 @@
-// TODO: TanStackRouter - type this better
+import type { AccountSettings } from '@linode/api-v4';
+
export type RouterContext = {
- accountSettings?: any;
+ accountSettings?: AccountSettings;
globalErrors?: {
account_unactivated?: boolean;
};
diff --git a/packages/manager/src/routes/utils/allPaths.ts b/packages/manager/src/routes/utils/allPaths.ts
index 6a8779ad2e3..3a76edb1293 100644
--- a/packages/manager/src/routes/utils/allPaths.ts
+++ b/packages/manager/src/routes/utils/allPaths.ts
@@ -1,5 +1,7 @@
import { routeTree } from '..';
+import type { AnyRoute } from '@tanstack/react-router';
+
/**
* This function is meant to be used for testing purposes only.
* It allows us to generate a list of all unique @tanstack/router paths defined in the routing factory.
@@ -7,7 +9,10 @@ import { routeTree } from '..';
* We import this util in cypress to loop through all routes and test them.
* It probably should not be used for anything else.
*/
-export const getAllRoutePaths = (route: any, parentPath = ''): string[] => {
+export const getAllRoutePaths = (
+ route: AnyRoute,
+ parentPath = ''
+): string[] => {
let currentPath = parentPath
? `${parentPath}/${route.path || ''}`
: route.path || '';
@@ -15,15 +20,15 @@ export const getAllRoutePaths = (route: any, parentPath = ''): string[] => {
// Remove leading and trailing slashes
currentPath = currentPath.replace(/^\/+|\/+$/g, '');
- const paths: Set = new Set();
+ const paths = new Set();
// Check if the current path is valid
if (currentPath && currentPath !== '//') {
paths.add('/' + currentPath);
}
- if (route.children) {
- route.children.forEach((childRoute: any) => {
+ if (route.children && Array.isArray(route.children)) {
+ route.children.forEach((childRoute) => {
getAllRoutePaths(childRoute, currentPath).forEach((path) =>
paths.add(path)
);