From 4109545478660090a923da16f13587466d720ca8 Mon Sep 17 00:00:00 2001 From: NolanTrem <34580718+NolanTrem@users.noreply.github.com> Date: Fri, 25 Oct 2024 15:24:52 -0700 Subject: [PATCH] Bug in checking vars --- src/pages/auth/login.tsx | 22 ++++++++++++++++------ src/pages/index.tsx | 28 ++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/pages/auth/login.tsx b/src/pages/auth/login.tsx index 597e7fc..17213a8 100644 --- a/src/pages/auth/login.tsx +++ b/src/pages/auth/login.tsx @@ -27,14 +27,24 @@ const LoginPage: React.FC = () => { const [rawDeploymentUrl, setRawDeploymentUrl] = useState(''); const [sanitizedDeploymentUrl, setSanitizedDeploymentUrl] = useState(''); + const getDeploymentUrl = () => { + if ( + typeof window !== 'undefined' && + window.__RUNTIME_CONFIG__?.NEXT_PUBLIC_R2R_DEPLOYMENT_URL && + !window.__RUNTIME_CONFIG__.NEXT_PUBLIC_R2R_DEPLOYMENT_URL.includes( + '__NEXT_PUBLIC_R2R_DEPLOYMENT_URL__' + ) + ) { + return window.__RUNTIME_CONFIG__.NEXT_PUBLIC_R2R_DEPLOYMENT_URL; + } + return DEFAULT_DEPLOYMENT_URL; + }; + useEffect(() => { if (typeof window !== 'undefined') { - const deploymentUrl = - window.__RUNTIME_CONFIG__?.NEXT_PUBLIC_R2R_DEPLOYMENT_URL; - if (deploymentUrl) { - setRawDeploymentUrl(deploymentUrl); - setSanitizedDeploymentUrl(deploymentUrl); - } + const url = getDeploymentUrl(); + setRawDeploymentUrl(url); + setSanitizedDeploymentUrl(url); } }, []); diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 6c8639f..68ba915 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -285,18 +285,30 @@ const HomePage = () => { color="light" disabled={ !window.__RUNTIME_CONFIG__ - ?.NEXT_PUBLIC_HATCHET_DASHBOARD_URL - } - onClick={() => - window.open( - window.__RUNTIME_CONFIG__ - .NEXT_PUBLIC_HATCHET_DASHBOARD_URL, - '_blank' + ?.NEXT_PUBLIC_HATCHET_DASHBOARD_URL || + window.__RUNTIME_CONFIG__.NEXT_PUBLIC_HATCHET_DASHBOARD_URL.includes( + '__NEXT_PUBLIC_HATCHET_DASHBOARD_URL__' ) } + onClick={() => { + const url = + window.__RUNTIME_CONFIG__ + ?.NEXT_PUBLIC_HATCHET_DASHBOARD_URL; + if ( + url && + !url.includes( + '__NEXT_PUBLIC_HATCHET_DASHBOARD_URL__' + ) + ) { + window.open(url, '_blank'); + } + }} tooltip={ !window.__RUNTIME_CONFIG__ - ?.NEXT_PUBLIC_HATCHET_DASHBOARD_URL ? ( + ?.NEXT_PUBLIC_HATCHET_DASHBOARD_URL || + window.__RUNTIME_CONFIG__.NEXT_PUBLIC_HATCHET_DASHBOARD_URL.includes( + '__NEXT_PUBLIC_HATCHET_DASHBOARD_URL__' + ) ? (
Hatchet Dashboard Deployment URL unavailable.