Skip to content

Commit 1d0f7a1

Browse files
authored
Merge pull request #363 from kthcloud/upgrade-react
Upgrade react + migrate to react-oidc-context + general cleanup
2 parents db444e8 + 3ee2751 commit 1d0f7a1

65 files changed

Lines changed: 528 additions & 258 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ VITE_DNS_URL="https://dns.cloud.cbh.kth.se"
88
VITE_MAIA_URL="https://maia.app.cloud.cbh.kth.se/maia"
99
# can be comma separated to add more
1010
VITE_SERVER_PLATFORM="linux/amd64"
11+
VITE_DEPLOYMENT_SSH_BASE="deploy.cloud.cbh.kth.se"
1112
GENERATE_SOURCEMAP=false

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ ENV DNS_URL="https://dns.cloud.cbh.kth.se"
4949
ENV MAIA_URL="https://maia.app.cloud.cbh.kth.se/maia"
5050
# can be comma separated to add more
5151
ENV SERVER_PLATFORM="linux/amd64"
52+
ENV DEPLOYMENT_SSH_BASE="deploy.cloud.cbh.kth.se"
5253

5354
EXPOSE 3000
5455
ENTRYPOINT ["/entrypoint.sh"]

bun.lockb

19.3 KB
Binary file not shown.

package.json

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,40 +17,41 @@
1717
"@emotion/styled": "^11.14.1",
1818
"@iconify/react": "^4.1.1",
1919
"@kthcloud/go-deploy-types": "^1.0.25",
20-
"@mui/icons-material": "^5.18.0",
20+
"@mui/icons-material": "^7.3.9",
2121
"@mui/lab": "^5.0.0-alpha.177",
22-
"@mui/material": "^5.18.0",
22+
"@mui/material": "^7.3.9",
2323
"@mui/material-next": "^6.0.0-alpha.126",
2424
"@mui/x-tree-view": "^7.29.10",
25-
"@react-keycloak/web": "^3.4.0",
26-
"@react-three/fiber": "^8.18.0",
25+
"@react-three/drei": "^10.7.7",
26+
"@react-three/fiber": "^9.5.0",
2727
"@sanity/eventsource": "^5.0.2",
2828
"@types/crypto-js": "^4.2.2",
29-
"@types/lodash": "^4.17.23",
29+
"@types/lodash": "^4.17.24",
3030
"@types/numeral": "^2.0.5",
3131
"@types/punycode": "^2.1.4",
3232
"@types/three": "^0.164.1",
3333
"apexcharts": "^3.54.1",
34-
"bun": "^1.3.9",
34+
"bun": "^1.3.10",
3535
"change-case": "^5.4.4",
3636
"crypto-js": "^4.2.0",
3737
"http-status-codes": "^2.3.0",
3838
"i18next": "^23.16.8",
3939
"i18next-browser-languagedetector": "^7.2.2",
4040
"js-base64": "^3.7.8",
41-
"keycloak-js": "^24.0.5",
4241
"lodash": "^4.17.23",
4342
"million": "latest",
4443
"notistack": "^3.0.2",
4544
"numeral": "^2.0.6",
45+
"oidc-client-ts": "^3.4.1",
4646
"punycode": "^2.3.1",
47-
"react": "^18.3.1",
47+
"react": "^19.2.4",
4848
"react-apexcharts": "^1.9.0",
4949
"react-cookie": "^7.2.2",
50-
"react-copy-to-clipboard": "^5.1.0",
51-
"react-dom": "^18.3.1",
50+
"react-copy-to-clipboard": "^5.1.1",
51+
"react-dom": "^19.2.4",
5252
"react-helmet-async": "^2.0.5",
5353
"react-i18next": "^14.1.3",
54+
"react-oidc-context": "^3.3.0",
5455
"react-router-dom": "^6.30.3",
5556
"simplebar": "^6.3.3",
5657
"simplebar-react": "^3.3.2",
@@ -60,15 +61,16 @@
6061
},
6162
"devDependencies": {
6263
"@faker-js/faker": "^8.4.1",
63-
"@types/bun": "^1.3.9",
64+
"@types/bun": "^1.3.10",
6465
"@types/react": "^18.3.28",
6566
"@types/react-copy-to-clipboard": "^5.0.7",
6667
"@types/react-dom": "^18.3.7",
6768
"@typescript-eslint/eslint-plugin": "^7.18.0",
6869
"@typescript-eslint/parser": "^7.18.0",
6970
"@vitejs/plugin-react": "^4.7.0",
7071
"@vitejs/plugin-react-swc": "^3.11.0",
71-
"eslint": "^9.39.2",
72+
"babel-plugin-react-compiler": "^1.0.0",
73+
"eslint": "^9.39.4",
7274
"eslint-plugin-react": "^7.37.5",
7375
"eslint-plugin-react-hooks": "^4.6.2",
7476
"eslint-plugin-react-refresh": "^0.4.26",

public/static/models/Brain.glb

-34 MB
Binary file not shown.

public/static/models/brain.glb

1.7 MB
Binary file not shown.

src/App.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// keycloak
2-
import { AuthContextWrapperProvider } from "./contexts/AuthContextWrapper";
3-
import { keycloak } from "./keycloak";
2+
import { oidcConfig } from "./keycloak";
3+
import { AuthProvider } from "react-oidc-context";
4+
45
// routes
56
import Router from "./Router";
67
// theme
@@ -18,7 +19,7 @@ import { AdminResourceContextProvider } from "./contexts/AdminResourceContext";
1819

1920
export default function App() {
2021
return (
21-
<AuthContextWrapperProvider authClient={keycloak}>
22+
<AuthProvider {...oidcConfig}>
2223
<AlertContextProvider>
2324
<ResourceContextProvider>
2425
<AdminResourceContextProvider>
@@ -48,6 +49,6 @@ export default function App() {
4849
</AdminResourceContextProvider>
4950
</ResourceContextProvider>
5051
</AlertContextProvider>
51-
</AuthContextWrapperProvider>
52+
</AuthProvider>
5253
);
5354
}

src/Router.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import Onboarding from "./pages/onboarding";
1818
import Inbox from "./pages/inbox/Inbox";
1919
import Teams from "./pages/teams/Teams";
2020
import { GPU } from "./pages/gpu/GPU";
21+
import Callback from "./components/Callback";
2122

2223
export default function Router() {
2324
return useRoutes([
@@ -28,6 +29,7 @@ export default function Router() {
2829
{ path: "/", element: <Landing /> },
2930
{ path: "/status", element: <Status /> },
3031
{ path: "tiers", element: <Tiers /> },
32+
{ path: "oauth2/callback", element: <Callback /> },
3133
{
3234
path: "deploy",
3335
element: (

src/components/Callback.tsx

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { useEffect } from "react";
2+
import { useNavigate } from "react-router-dom";
3+
import { useAuth } from "react-oidc-context";
4+
5+
import {
6+
Box,
7+
Button,
8+
CircularProgress,
9+
Paper,
10+
Typography,
11+
} from "@mui/material";
12+
import Page from "./Page";
13+
14+
export default function Callback() {
15+
const navigate = useNavigate();
16+
const auth = useAuth();
17+
18+
useEffect(() => {
19+
if (!auth.isLoading) {
20+
if (auth.isAuthenticated) {
21+
// Clean up the URL
22+
const url = new URL(window.location.href);
23+
url.searchParams.delete("code");
24+
url.searchParams.delete("state");
25+
window.history.replaceState({}, document.title, url.pathname);
26+
27+
// Redirect to /deploy
28+
navigate("/deploy", { replace: true });
29+
}
30+
}
31+
}, [auth.isLoading, auth.isAuthenticated, navigate]);
32+
33+
if (auth.isLoading) {
34+
return (
35+
<Page>
36+
<Box component="div" sx={{ minHeight: "100vh" }}>
37+
<CircularProgress />
38+
<Typography mt={2} variant="h6">
39+
Authenticating...
40+
</Typography>
41+
</Box>
42+
</Page>
43+
);
44+
}
45+
46+
if (auth.error) {
47+
return (
48+
<Page>
49+
<Box
50+
display="flex"
51+
justifyContent="center"
52+
alignItems="center"
53+
height="100vh"
54+
>
55+
<Paper
56+
elevation={3}
57+
sx={{ padding: 4, textAlign: "center", maxWidth: 400 }}
58+
>
59+
<Typography variant="h5" color="error" gutterBottom>
60+
Authentication Failed
61+
</Typography>
62+
<Typography variant="body1" sx={{ wordBreak: "break-word" }}>
63+
{auth.error?.message || "Unknown error occurred during login."}
64+
</Typography>
65+
<Button
66+
variant="contained"
67+
color="primary"
68+
sx={{ mt: 2 }}
69+
onClick={() => auth.signinRedirect()}
70+
>
71+
Try Again
72+
</Button>
73+
</Paper>
74+
</Box>
75+
</Page>
76+
);
77+
}
78+
79+
return null;
80+
}

src/components/LoadingPage.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ const LoadingPage = () => {
5858
direction="column"
5959
alignItems="center"
6060
justifyContent="center"
61-
style={{ minHeight: "100vh" }}
61+
sx={{ minHeight: "100vh", textAlign: "center" }}
6262
>
63-
<Grid item xs={3} m={1}>
63+
<Grid size={{ xs: 3 }} m={1}>
6464
<CircularProgress />
6565
</Grid>
66-
<Grid item xs={3} m={1}>
66+
<Grid size={{ xs: 3 }} m={1}>
6767
<div>{getLoadingMessage()}</div>
6868
</Grid>
6969
{connectionError && retryIn > 0 && (
70-
<Grid item xs={3} m={1}>
70+
<Grid size={{ xs: 3 }} m={1}>
7171
<div>{`${t("retrying-in")} ${retryIn} ${t("seconds")}`}</div>
7272
</Grid>
7373
)}

0 commit comments

Comments
 (0)