Skip to content

Commit 012ddde

Browse files
committed
Fix routing.
1 parent bec8b0f commit 012ddde

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/react-router.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export default {
55
// Server-side render by default, to enable SPA mode set this to `false`
66
ssr: false,
77
appDirectory: "src/app",
8+
basename: "/scheduler-ui",
89
} satisfies Config;

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/app/entry.client.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ async function enableMocking() {
4040
}
4141

4242
enableMocking().then(() => {
43+
// Handle servlet welcome-file redirect to index.html
44+
// React Router doesn't need index.html in the URL, so redirect without it
45+
if (window.location.pathname.endsWith('/index.html')) {
46+
const newPath = window.location.pathname.replace(/\/index\.html$/, '/');
47+
window.history.replaceState(null, '', newPath + window.location.search + window.location.hash);
48+
}
49+
4350
startTransition(() => {
4451
hydrateRoot(
4552
document,

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/app/root.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,21 @@ export default function App() {
5555
</ValidationProvider>
5656
);
5757
}
58+
59+
export function HydrateFallback() {
60+
return (
61+
<div className="flex h-screen items-center justify-center bg-background">
62+
<div className="text-center space-y-4">
63+
<div
64+
className="inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-primary border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]"
65+
role="status"
66+
>
67+
<span className="sr-only">Loading...</span>
68+
</div>
69+
<p className="text-sm text-muted-foreground">
70+
Loading YARN Capacity Scheduler UI...
71+
</p>
72+
</div>
73+
</div>
74+
);
75+
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default defineConfig(({ mode }) => {
1414
const clusterProxyTarget = env.VITE_CLUSTER_PROXY_TARGET;
1515

1616
return {
17+
base: '/scheduler-ui/',
1718
plugins: [
1819
tailwindcss(),
1920
reactRouter(),

0 commit comments

Comments
 (0)