Skip to content

Commit cad8e00

Browse files
upcoming: [M3-10417], [M3-10418], [M3-10419] and [M3-10420] - Redirects account tabs to flat routes /login-history, /settings, /maintenance and /service-transfers (linode#12702)
* Route accout/login-history -> /login-history * Route accout/maintenance -> /maintenance * Added changeset: Redirects account tabs to flat routes /login-history, /settings, /maintenance and /service-transfers * Route accout/settings -> /settings * Route accout/service-transfers -> /service-transfers * Fix casing: serviceTransfers -> ServiceTransfers * Update packages/manager/.changeset/pr-12702-upcoming-features-1755191140699.md Co-authored-by: Connie Liu <[email protected]> --------- Co-authored-by: Connie Liu <[email protected]>
1 parent cdcf176 commit cad8e00

28 files changed

+545
-19
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Upcoming Features
3+
---
4+
5+
Redirect Account tabs to flat routes `/login-history`, `/settings`, `/maintenance`, and `/service-transfers` ([#12702](https://github.com/linode/manager/pull/12702))

packages/manager/src/components/PrimaryNav/PrimaryNav.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,19 +296,19 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
296296
},
297297
{
298298
display: 'Login History',
299-
to: '/account/login-history', // TODO: replace with '/login-history' when flat route is added
299+
to: '/login-history',
300300
},
301301
{
302302
display: 'Service Transfers',
303-
to: '/account/service-transfers', // TODO: replace with '/service-transfers' when flat route is added
303+
to: '/service-transfers',
304304
},
305305
{
306306
display: 'Maintenance',
307-
to: '/account/maintenance', // TODO: replace with '/maintenance' when flat route is added
307+
to: '/maintenance',
308308
},
309309
{
310310
display: 'Settings',
311-
to: '/account/settings', // TODO: replace with '/settings' when flat route is added
311+
to: '/settings',
312312
},
313313
],
314314
name: 'Administration',

packages/manager/src/features/Account/AccountLogins.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { TableRowEmpty } from 'src/components/TableRowEmpty/TableRowEmpty';
1515
import { TableRowError } from 'src/components/TableRowError/TableRowError';
1616
import { TableRowLoading } from 'src/components/TableRowLoading/TableRowLoading';
1717
import { TableSortCell } from 'src/components/TableSortCell';
18+
import { useFlags } from 'src/hooks/useFlags';
1819
import { useOrderV2 } from 'src/hooks/useOrderV2';
1920
import { usePaginationV2 } from 'src/hooks/usePaginationV2';
2021

@@ -43,11 +44,14 @@ const useStyles = makeStyles()((theme: Theme) => ({
4344

4445
const AccountLogins = () => {
4546
const { classes } = useStyles();
47+
const flags = useFlags();
4648
const { data: permissions } = usePermissions('account', [
4749
'list_account_logins',
4850
]);
4951
const pagination = usePaginationV2({
50-
currentRoute: '/account/login-history',
52+
currentRoute: flags?.iamRbacPrimaryNavChanges
53+
? '/login-history'
54+
: '/account/login-history',
5155
preferenceKey: 'account-logins-pagination',
5256
});
5357

@@ -57,7 +61,9 @@ const AccountLogins = () => {
5761
order: 'desc',
5862
orderBy: 'datetime',
5963
},
60-
from: '/account/login-history',
64+
from: flags?.iamRbacPrimaryNavChanges
65+
? '/login-history'
66+
: '/account/login-history',
6167
},
6268
preferenceKey: `${preferenceKey}-order`,
6369
});

packages/manager/src/features/Account/Maintenance/MaintenanceTable.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ export const MaintenanceTable = ({ type }: Props) => {
7373
const flags = useFlags();
7474

7575
const pagination = usePaginationV2({
76-
currentRoute: `/account/maintenance`,
76+
currentRoute: flags?.iamRbacPrimaryNavChanges
77+
? `/maintenance`
78+
: `/account/maintenance`,
7779
preferenceKey: `${preferenceKey}-${type}`,
7880
queryParamsPrefix: type,
7981
});
@@ -84,7 +86,9 @@ export const MaintenanceTable = ({ type }: Props) => {
8486
order: 'desc',
8587
orderBy: 'status',
8688
},
87-
from: `/account/maintenance`,
89+
from: flags?.iamRbacPrimaryNavChanges
90+
? `/maintenance`
91+
: `/account/maintenance`,
8892
},
8993
preferenceKey: `${preferenceKey}-order-${type}`,
9094
prefix: type,

packages/manager/src/features/EntityTransfers/EntityTransfersCreate/EntityTransfersCreate.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { DocumentTitleSegment } from 'src/components/DocumentTitle';
99
import { LandingHeader } from 'src/components/LandingHeader';
1010
import { getRestrictedResourceText } from 'src/features/Account/utils';
1111
import { usePermissions } from 'src/features/IAM/hooks/usePermissions';
12+
import { useFlags } from 'src/hooks/useFlags';
1213
import { sendEntityTransferCreateEvent } from 'src/utilities/analytics/customEventAnalytics';
1314
import { getAPIErrorOrDefault } from 'src/utilities/errorUtils';
1415

@@ -29,6 +30,7 @@ import type { QueryClient } from '@tanstack/react-query';
2930

3031
export const EntityTransfersCreate = () => {
3132
const navigate = useNavigate();
33+
const flags = useFlags();
3234
const { error, isPending, mutateAsync: createTransfer } = useCreateTransfer();
3335
const queryClient = useQueryClient();
3436

@@ -77,7 +79,9 @@ export const EntityTransfersCreate = () => {
7779
queryKey: [entityTransfersQueryKey],
7880
});
7981
navigate({
80-
to: '/account/service-transfers',
82+
to: flags?.iamRbacPrimaryNavChanges
83+
? '/service-transfers'
84+
: '/account/service-transfers',
8185
state: (prev) => ({ ...prev, transfer }),
8286
});
8387
},

packages/manager/src/features/EntityTransfers/EntityTransfersCreate/LinodeTransferTable.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as React from 'react';
1111
import { SelectableTableRow } from 'src/components/SelectableTableRow/SelectableTableRow';
1212
import { TableCell } from 'src/components/TableCell';
1313
import { TableContentWrapper } from 'src/components/TableContentWrapper/TableContentWrapper';
14+
import { useFlags } from 'src/hooks/useFlags';
1415
import { usePaginationV2 } from 'src/hooks/usePaginationV2';
1516
import { extendType } from 'src/utilities/extendType';
1617

@@ -36,10 +37,14 @@ export const LinodeTransferTable = React.memo((props: Props) => {
3637
selectedLinodes,
3738
disabled,
3839
} = props;
40+
const flags = useFlags();
41+
3942
const [searchText, setSearchText] = React.useState('');
4043

4144
const pagination = usePaginationV2({
42-
currentRoute: '/account/service-transfers/create',
45+
currentRoute: flags?.iamRbacPrimaryNavChanges
46+
? '/service-transfers/create'
47+
: '/account/service-transfers/create',
4348
initialPage: 1,
4449
preferenceKey: 'linode-transfer-table',
4550
});

packages/manager/src/features/EntityTransfers/EntityTransfersLanding/EntityTransfersLanding.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as React from 'react';
55

66
import { DocumentTitleSegment } from 'src/components/DocumentTitle';
77
import { usePermissions } from 'src/features/IAM/hooks/usePermissions';
8+
import { useFlags } from 'src/hooks/useFlags';
89
import { usePaginationV2 } from 'src/hooks/usePaginationV2';
910

1011
import { TransfersTable } from '../TransfersTable';
@@ -21,12 +22,17 @@ export const EntityTransfersLanding = () => {
2122

2223
const location = useLocation();
2324
const navigate = useNavigate();
25+
const flags = useFlags();
26+
27+
const url = flags?.iamRbacPrimaryNavChanges
28+
? '/service-transfers'
29+
: '/account/service-transfers';
2430

2531
const handleCloseSuccessDialog = () => {
2632
setSuccessDialogOpen(false);
2733
setTransfer(undefined);
2834
navigate({
29-
to: '/account/service-transfers',
35+
to: url,
3036
state: (prev) => ({ ...prev, transfer: undefined }),
3137
});
3238
};
@@ -48,19 +54,19 @@ export const EntityTransfersLanding = () => {
4854

4955
const paginationPendingTransfers = usePaginationV2({
5056
initialPage,
51-
currentRoute: '/account/service-transfers',
57+
currentRoute: url,
5258
preferenceKey: pendingTransfersTablePreferenceKey,
5359
queryParamsPrefix: pendingTransfersTablePreferenceKey,
5460
});
5561
const paginationReceivedTransfers = usePaginationV2({
5662
initialPage,
57-
currentRoute: '/account/service-transfers',
63+
currentRoute: url,
5864
preferenceKey: receivedTransfersTablePreferenceKey,
5965
queryParamsPrefix: receivedTransfersTablePreferenceKey,
6066
});
6167
const paginationSentTransfers = usePaginationV2({
6268
initialPage,
63-
currentRoute: '/account/service-transfers',
69+
currentRoute: url,
6470
preferenceKey: sentTransfersTablePreferenceKey,
6571
queryParamsPrefix: sentTransfersTablePreferenceKey,
6672
});

packages/manager/src/features/EntityTransfers/EntityTransfersLanding/TransferControls.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { useNavigate } from '@tanstack/react-router';
22
import * as React from 'react';
33

4+
import { useFlags } from 'src/hooks/useFlags';
5+
46
import { ConfirmTransferDialog } from './ConfirmTransferDialog';
57
import {
68
StyledLabelWrapperGrid,
@@ -22,6 +24,7 @@ interface Props {
2224
export const TransferControls = React.memo((props: Props) => {
2325
const { permissions } = props;
2426

27+
const flags = useFlags();
2528
const [token, setToken] = React.useState('');
2629
const [confirmDialogOpen, setConfirmDialogOpen] = React.useState(false);
2730

@@ -38,7 +41,11 @@ export const TransferControls = React.memo((props: Props) => {
3841
};
3942

4043
const handleCreateTransfer = () =>
41-
navigate({ to: '/account/service-transfers/create' });
44+
navigate({
45+
to: flags?.iamRbacPrimaryNavChanges
46+
? '/service-transfers/create'
47+
: '/account/service-transfers/create',
48+
});
4249

4350
return (
4451
<>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { Navigate, useLocation } from '@tanstack/react-router';
2+
import * as React from 'react';
3+
4+
import { DocumentTitleSegment } from 'src/components/DocumentTitle';
5+
import { LandingHeader } from 'src/components/LandingHeader';
6+
import { MaintenanceBannerV2 } from 'src/components/MaintenanceBanner/MaintenanceBannerV2';
7+
import { PlatformMaintenanceBanner } from 'src/components/PlatformMaintenanceBanner/PlatformMaintenanceBanner';
8+
import { useFlags } from 'src/hooks/useFlags';
9+
10+
import AccountLogins from '../Account/AccountLogins';
11+
12+
import type { LandingHeaderProps } from 'src/components/LandingHeader';
13+
14+
export const LoginHistoryLanding = () => {
15+
const flags = useFlags();
16+
const location = useLocation();
17+
18+
if (
19+
!flags?.iamRbacPrimaryNavChanges &&
20+
location.pathname !== '/account/login-history'
21+
) {
22+
return <Navigate replace to="/account/login-history" />;
23+
}
24+
25+
const landingHeaderProps: LandingHeaderProps = {
26+
title: 'Login History',
27+
};
28+
29+
return (
30+
<>
31+
<PlatformMaintenanceBanner pathname={location.pathname} />
32+
<MaintenanceBannerV2 pathname={location.pathname} />
33+
<DocumentTitleSegment segment="Login History" />
34+
<LandingHeader {...landingHeaderProps} spacingBottom={4} />
35+
<AccountLogins />
36+
</>
37+
);
38+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { createLazyRoute } from '@tanstack/react-router';
2+
3+
import { LoginHistoryLanding } from './LoginHistoryLanding';
4+
5+
export const loginHistoryLandingLazyRoute = createLazyRoute('/login-history')({
6+
component: LoginHistoryLanding,
7+
});

0 commit comments

Comments
 (0)