Skip to content
Merged
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
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-13288-fixed-1768563557558.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

IAM routing cleanup ([#13288](https://github.com/linode/manager/pull/13288))
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { createLazyRoute } from '@tanstack/react-router';

import { DefaultsLanding } from './DefaultsLanding';

export const defaultsLandingLazyRoute = createLazyRoute('/iam/roles/')({
export const defaultsLandingLazyRoute = createLazyRoute('/iam/roles')({
component: DefaultsLanding,
});
11 changes: 1 addition & 10 deletions packages/manager/src/routes/IAM/IAMRoute.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
import { NotFound } from '@linode/ui';
import { Outlet } from '@tanstack/react-router';
import React from 'react';

import { DocumentTitleSegment } from 'src/components/DocumentTitle';
import { ProductInformationBanner } from 'src/components/ProductInformationBanner/ProductInformationBanner';
import { SuspenseLoader } from 'src/components/SuspenseLoader';
import { useIsIAMEnabled } from 'src/features/IAM/hooks/useIsIAMEnabled';

export const IAMRoute = () => {
const { isIAMEnabled, isLoading } = useIsIAMEnabled();
return (
<React.Suspense fallback={<SuspenseLoader />}>
<DocumentTitleSegment segment="Identity and Access" />
<ProductInformationBanner bannerLocation="Identity and Access" />
{isLoading ? (
<SuspenseLoader />
) : isIAMEnabled ? (
<Outlet />
) : (
<NotFound />
)}
<Outlet />
</React.Suspense>
);
};
35 changes: 28 additions & 7 deletions packages/manager/src/routes/IAM/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ const iamTabsRoute = createRoute({
const iamUsersRoute = createRoute({
getParentRoute: () => iamTabsRoute,
path: 'users',
beforeLoad: async ({ context }) => {
const isIAMEnabled = await checkIAMEnabled(
context.queryClient,
context.flags,
context.profile
);

if (!isIAMEnabled) {
throw redirect({
to: '/users',
replace: true,
});
}
},
}).lazy(() =>
import('src/features/IAM/Users/UsersTable/usersLandingLazyRoute').then(
(m) => m.usersLandingLazyRoute
Expand All @@ -72,16 +86,11 @@ const iamRolesRoute = createRoute({

if (!isIAMEnabled) {
throw redirect({
to: '/account/users',
to: '/users',
replace: true,
});
}
},
});

const iamRolesIndexRoute = createRoute({
getParentRoute: () => iamRolesRoute,
path: '/',
}).lazy(() =>
import('src/features/IAM/Roles/rolesLandingLazyRoute').then(
(m) => m.rolesLandingLazyRoute
Expand Down Expand Up @@ -142,6 +151,19 @@ const iamDelegationsRoute = createRoute({
const isDelegationEnabled = context?.flags?.iamDelegation?.enabled;
const profile = context?.profile;

const isIAMEnabled = await checkIAMEnabled(
context.queryClient,
context.flags,
context.profile
);

if (!isIAMEnabled) {
throw redirect({
to: '/users',
replace: true,
});
}

const isChildAccount = profile?.user_type === 'child';
if (!isDelegationEnabled || isChildAccount) {
throw redirect({
Expand Down Expand Up @@ -401,7 +423,6 @@ const iamUserNameEntitiesCatchAllRoute = createRoute({
export const iamRouteTree = iamRoute.addChildren([
iamTabsRoute.addChildren([
iamRolesRoute.addChildren([
iamRolesIndexRoute,
iamDefaultsTabsRoute.addChildren([
iamDefaultRolesRoute,
iamDefaultEntityAccessRoute,
Expand Down