From f4ac9e92dfe3ed8d1b22b5aa28ce70988457ec0d Mon Sep 17 00:00:00 2001 From: Kyle Burton Date: Thu, 16 Jan 2025 21:59:55 -0600 Subject: [PATCH] Adds externalLoginUrl to SessionExpiredModal This allows a commons to direct the user to any login page, including a data-portal login page, when a user's session expires. --- .gitignore | 2 ++ .../frontend/src/components/Modals/Gen3ModalsProvider.tsx | 2 +- .../frontend/src/components/Modals/SessionExpiredModal.tsx | 5 ++++- packages/frontend/src/components/Modals/types.ts | 4 ++++ packages/sampleCommons/.env.development | 4 ++-- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 4a844a31..17531131 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,6 @@ yarn-error.log* packages/sampleCommons/config/canine packages/sampleCommons/config/midrc packages/sampleCommons/config/heal +packages/sampleCommons/config/bdc +packages/sampleCommons/.env.development /packages/frontend/.rollup.cache/ diff --git a/packages/frontend/src/components/Modals/Gen3ModalsProvider.tsx b/packages/frontend/src/components/Modals/Gen3ModalsProvider.tsx index 7a0f9926..4242261e 100644 --- a/packages/frontend/src/components/Modals/Gen3ModalsProvider.tsx +++ b/packages/frontend/src/components/Modals/Gen3ModalsProvider.tsx @@ -36,7 +36,7 @@ const getModal = ( break; } case Modals.SessionExpireModal: { - res = ; + res = ; break; } } diff --git a/packages/frontend/src/components/Modals/SessionExpiredModal.tsx b/packages/frontend/src/components/Modals/SessionExpiredModal.tsx index 459dd288..3a9b76fa 100644 --- a/packages/frontend/src/components/Modals/SessionExpiredModal.tsx +++ b/packages/frontend/src/components/Modals/SessionExpiredModal.tsx @@ -2,16 +2,19 @@ import { useCallback } from 'react'; import { useRouter } from 'next/router'; import { Text } from '@mantine/core'; import { BaseModal } from './BaseModal'; +import { SessionExpiredModalConfig } from "./types"; export const SessionExpiredModal = ({ openModal, + config }: { openModal: boolean; + config: SessionExpiredModalConfig; }): JSX.Element => { const router = useRouter(); const onLogout = useCallback(() => { - router.push('/Login'); + router.push(config.externalLoginUrl || '/Login'); }, [router]); return ( diff --git a/packages/frontend/src/components/Modals/types.ts b/packages/frontend/src/components/Modals/types.ts index c919b09d..3f829dda 100644 --- a/packages/frontend/src/components/Modals/types.ts +++ b/packages/frontend/src/components/Modals/types.ts @@ -12,7 +12,11 @@ export interface FirstTimeModalConfig extends BaseModalConfig{ expireDays?: number; } +export interface SessionExpiredModalConfig extends BaseModalConfig{ + externalLoginUrl?: string; +} export interface ModalsConfig { systemUseModal?: FirstTimeModalConfig; + sessionExpiredModal?: SessionExpiredModalConfig; } diff --git a/packages/sampleCommons/.env.development b/packages/sampleCommons/.env.development index 7a923fa9..572e8e37 100644 --- a/packages/sampleCommons/.env.development +++ b/packages/sampleCommons/.env.development @@ -1,5 +1,5 @@ -GEN3_COMMONS_NAME=gen3 -NEXT_PUBLIC_GEN3_API=https://localhost:3010 +GEN3_COMMONS_NAME=bdc +NEXT_PUBLIC_GEN3_API=https://staging.gen3.biodatacatalyst.nhlbi.nih.gov/ ## For more fine grain control over the API uncomment the relevant lines #NEXT_PUBLIC_GEN3_SUBMISSION_API=https://localhost:3010/api/v0/submission