Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Github pages 404 issue #2179

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Please follow the established format:
- Display full dataset type with library prefix in metadata panel (#2136)
- Enable SQLite WAL mode for Azure ML to fix database locking issues (#2131)
- Replace `flake8`, `isort`, `pylint` and `black` by `ruff` (#2149)
- Fix 404 error when accessing the experiment tracking page on the demo site (#2179)


# Release 10.0.0
Expand Down
23 changes: 23 additions & 0 deletions public/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- Handle GitHub Pages redirect by storing the requested path and redirecting to the root -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Redirecting</title>
<p>Redirecting...</p>
<script>
try {
const path = window.location.pathname.slice(1);
const search = window.location.search;
if (window.localStorage) {
localStorage.setItem('ghp-redirect-path', `${path}${search}`);
}
window.location.href = '../';
} catch (e) {
console.error('Failed to handle redirect:', e);
window.location.href = '/'; // Fallback to root
}
</script>
</head>
<body></body>
</html>
16 changes: 15 additions & 1 deletion src/components/flowchart-wrapper/flowchart-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@
matchedFocusedNode,
} = findMatchedPath(pathname, search);

useEffect(() => {
// Handle GitHub Pages redirect by checking for a stored path and navigating to it if present
let ghpRedirectPath = localStorage.getItem('ghp-redirect-path');
if (ghpRedirectPath) {
history.push(ghpRedirectPath);
}
}, []);

Check warning on line 104 in src/components/flowchart-wrapper/flowchart-wrapper.js

View workflow job for this annotation

GitHub Actions / javascript_lint_and_tests

React Hook useEffect has a missing dependency: 'history'. Either include it or remove the dependency array

Check warning on line 104 in src/components/flowchart-wrapper/flowchart-wrapper.js

View workflow job for this annotation

GitHub Actions / javascript_lint_and_tests

React Hook useEffect has a missing dependency: 'history'. Either include it or remove the dependency array

/**
* On initial load & when user switch active pipeline,
* sets the query params from local storage based on NodeType, tag, expandAllPipelines and active pipeline.
Expand Down Expand Up @@ -131,7 +139,13 @@
};

useEffect(() => {
setParamsFromLocalStorage(activePipeline);
// After processing the redirect, remove the stored path or set parameters from local storage
let ghpRedirectPath = localStorage.getItem('ghp-redirect-path');
if (ghpRedirectPath) {
localStorage.removeItem('ghp-redirect-path');
} else {
setParamsFromLocalStorage(activePipeline);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [activePipeline, tag, nodeType, expandAllPipelines]);

Expand Down
Loading