From 22eb02506c1ddcb0d1e7e0f8eb8032833b021981 Mon Sep 17 00:00:00 2001 From: Jaalah Ramos <125309814+jaalah-akamai@users.noreply.github.com> Date: Tue, 13 Feb 2024 10:31:11 -0500 Subject: [PATCH] upcoming: [M3-7716] - Add session expiry confirmation dialog for proxy users (#10152) Co-authored-by: Jaalah Ramos Co-authored-by: Mariah Jacobs <114685994+mjac0bs@users.noreply.github.com> --- ...r-10152-upcoming-features-1707246537679.md | 5 + packages/manager/src/MainContent.tsx | 189 +++++++++--------- .../LandingHeader/LandingHeader.tsx | 1 + .../context/switchAccountSessionContext.ts | 7 + .../manager/src/context/useDialogContext.ts | 41 +++- .../src/features/Account/AccountLanding.tsx | 17 +- .../features/Account/SwitchAccountDrawer.tsx | 6 +- .../SwitchAccountSessionDialog.test.tsx | 63 ++++++ .../SwitchAccountSessionDialog.tsx | 38 ++++ .../useParentTokenManagement.test.tsx | 67 +++++++ .../useParentTokenManagement.tsx | 21 ++ .../manager/src/features/Account/constants.ts | 4 + .../manager/src/features/Account/utils.ts | 59 ++++-- .../GlobalNotifications.tsx | 17 +- .../features/TopMenu/UserMenu/UserMenu.tsx | 16 +- .../src/hooks/useIsResourceRestricted.ts | 3 +- 16 files changed, 434 insertions(+), 120 deletions(-) create mode 100644 packages/manager/.changeset/pr-10152-upcoming-features-1707246537679.md create mode 100644 packages/manager/src/context/switchAccountSessionContext.ts create mode 100644 packages/manager/src/features/Account/SwitchAccounts/SwitchAccountSessionDialog.test.tsx create mode 100644 packages/manager/src/features/Account/SwitchAccounts/SwitchAccountSessionDialog.tsx create mode 100644 packages/manager/src/features/Account/SwitchAccounts/useParentTokenManagement.test.tsx create mode 100644 packages/manager/src/features/Account/SwitchAccounts/useParentTokenManagement.tsx diff --git a/packages/manager/.changeset/pr-10152-upcoming-features-1707246537679.md b/packages/manager/.changeset/pr-10152-upcoming-features-1707246537679.md new file mode 100644 index 00000000000..884f698a2f8 --- /dev/null +++ b/packages/manager/.changeset/pr-10152-upcoming-features-1707246537679.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Upcoming Features +--- + +Add session expiry confirmation dialog for proxy to parent user account switching ([#10152](https://github.com/linode/manager/pull/10152)) diff --git a/packages/manager/src/MainContent.tsx b/packages/manager/src/MainContent.tsx index 5d11ba2b26d..0d762133050 100644 --- a/packages/manager/src/MainContent.tsx +++ b/packages/manager/src/MainContent.tsx @@ -29,6 +29,7 @@ import { isFeatureEnabled } from 'src/utilities/accountCapabilities'; import { ENABLE_MAINTENANCE_MODE } from './constants'; import { complianceUpdateContext } from './context/complianceUpdateContext'; +import { switchAccountSessionContext } from './context/switchAccountSessionContext'; import { FlagSet } from './featureFlags'; import { useIsACLBEnabled } from './features/LoadBalancers/utils'; import { useGlobalErrors } from './hooks/useGlobalErrors'; @@ -192,6 +193,11 @@ export const MainContent = () => { const ComplianceUpdateProvider = complianceUpdateContext.Provider; const complianceUpdateContextValue = useDialogContext(); + const SwitchAccountSessionProvider = switchAccountSessionContext.Provider; + const switchAccountSessionContextValue = useDialogContext({ + isOpen: false, + }); + const [menuIsOpen, toggleMenu] = React.useState(false); const { _isManagedAccount, @@ -294,100 +300,105 @@ export const MainContent = () => { */ return (
- - - <> - {shouldDisplayMainContentBanner ? ( - setBannerDismissed(true)} - url={flags.mainContentBanner?.link?.url ?? ''} - /> - ) : null} - toggleMenu(false)} - collapse={desktopMenuIsOpen || false} - open={menuIsOpen} - /> -
- toggleMenu(true)} - username={username} + + + + <> + {shouldDisplayMainContentBanner ? ( + setBannerDismissed(true)} + url={flags.mainContentBanner?.link?.url ?? ''} + /> + ) : null} + toggleMenu(false)} + collapse={desktopMenuIsOpen || false} + open={menuIsOpen} /> -
- - - - }> - - - - - - {isACLBEnabled && ( + toggleMenu(true)} + username={username} + /> +
+ + + + }> + + + + + + {isACLBEnabled && ( + + )} + + + + + + - )} - - - - - - - - - - - - - - - {showDatabases && ( - - )} - {flags.selfServeBetas && ( - - )} - {showVPCs && } - - {/** We don't want to break any bookmarks. This can probably be removed eventually. */} - - - - + + + + + + + + {showDatabases && ( + + )} + {flags.selfServeBetas && ( + + )} + {showVPCs && } + + {/** We don't want to break any bookmarks. This can probably be removed eventually. */} + + + + + - -
-
- -
-
- + +
+ + +