Skip to content

Commit

Permalink
Merge pull request #115 from SciPhi-AI/Nolan/CheckVars
Browse files Browse the repository at this point in the history
Bug in checking vars
  • Loading branch information
NolanTrem authored Oct 25, 2024
2 parents 92019d6 + 4109545 commit 746bd08
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
22 changes: 16 additions & 6 deletions src/pages/auth/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}, []);

Expand Down
28 changes: 20 additions & 8 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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__'
) ? (
<div>
Hatchet Dashboard Deployment URL unavailable.
<br />
Expand Down

0 comments on commit 746bd08

Please sign in to comment.