Skip to content

Commit 9b886ab

Browse files
fix types and fallback (#210)
1 parent 7a81794 commit 9b886ab

File tree

6 files changed

+131
-46
lines changed

6 files changed

+131
-46
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* CLOUDERA APPLIED MACHINE LEARNING PROTOTYPE (AMP)
3+
* (C) Cloudera, Inc. 2025
4+
* All rights reserved.
5+
*
6+
* Applicable Open Source License: Apache 2.0
7+
*
8+
* NOTE: Cloudera open source products are modular software products
9+
* made up of hundreds of individual components, each of which was
10+
* individually copyrighted. Each Cloudera open source product is a
11+
* collective work under U.S. Copyright Law. Your license to use the
12+
* collective work is as provided in your written agreement with
13+
* Cloudera. Used apart from the collective work, this file is
14+
* licensed for your use pursuant to the open source license
15+
* identified above.
16+
*
17+
* This code is provided to you pursuant a written agreement with
18+
* (i) Cloudera, Inc. or (ii) a third-party authorized to distribute
19+
* this code. If you do not have a written agreement with Cloudera nor
20+
* with an authorized and properly licensed third party, you do not
21+
* have any rights to access nor to use this code.
22+
*
23+
* Absent a written agreement with Cloudera, Inc. ("Cloudera") to the
24+
* contrary, A) CLOUDERA PROVIDES THIS CODE TO YOU WITHOUT WARRANTIES OF ANY
25+
* KIND; (B) CLOUDERA DISCLAIMS ANY AND ALL EXPRESS AND IMPLIED
26+
* WARRANTIES WITH RESPECT TO THIS CODE, INCLUDING BUT NOT LIMITED TO
27+
* IMPLIED WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND
28+
* FITNESS FOR A PARTICULAR PURPOSE; (C) CLOUDERA IS NOT LIABLE TO YOU,
29+
* AND WILL NOT DEFEND, INDEMNIFY, NOR HOLD YOU HARMLESS FOR ANY CLAIMS
30+
* ARISING FROM OR RELATED TO THE CODE; AND (D)WITH RESPECT TO YOUR EXERCISE
31+
* OF ANY RIGHTS GRANTED TO YOU FOR THE CODE, CLOUDERA IS NOT LIABLE FOR ANY
32+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR
33+
* CONSEQUENTIAL DAMAGES INCLUDING, BUT NOT LIMITED TO, DAMAGES
34+
* RELATED TO LOST REVENUE, LOST PROFITS, LOSS OF INCOME, LOSS OF
35+
* BUSINESS ADVANTAGE OR UNAVAILABILITY, OR LOSS OR CORRUPTION OF
36+
* DATA.
37+
*/
38+
39+
import { ErrorComponent } from "@tanstack/react-router";
40+
41+
export const CustomUnhandledError = ({ error }: { error: Error }) => {
42+
return <ErrorComponent error={error} />;
43+
};
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* CLOUDERA APPLIED MACHINE LEARNING PROTOTYPE (AMP)
3+
* (C) Cloudera, Inc. 2025
4+
* All rights reserved.
5+
*
6+
* Applicable Open Source License: Apache 2.0
7+
*
8+
* NOTE: Cloudera open source products are modular software products
9+
* made up of hundreds of individual components, each of which was
10+
* individually copyrighted. Each Cloudera open source product is a
11+
* collective work under U.S. Copyright Law. Your license to use the
12+
* collective work is as provided in your written agreement with
13+
* Cloudera. Used apart from the collective work, this file is
14+
* licensed for your use pursuant to the open source license
15+
* identified above.
16+
*
17+
* This code is provided to you pursuant a written agreement with
18+
* (i) Cloudera, Inc. or (ii) a third-party authorized to distribute
19+
* this code. If you do not have a written agreement with Cloudera nor
20+
* with an authorized and properly licensed third party, you do not
21+
* have any rights to access nor to use this code.
22+
*
23+
* Absent a written agreement with Cloudera, Inc. ("Cloudera") to the
24+
* contrary, A) CLOUDERA PROVIDES THIS CODE TO YOU WITHOUT WARRANTIES OF ANY
25+
* KIND; (B) CLOUDERA DISCLAIMS ANY AND ALL EXPRESS AND IMPLIED
26+
* WARRANTIES WITH RESPECT TO THIS CODE, INCLUDING BUT NOT LIMITED TO
27+
* IMPLIED WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND
28+
* FITNESS FOR A PARTICULAR PURPOSE; (C) CLOUDERA IS NOT LIABLE TO YOU,
29+
* AND WILL NOT DEFEND, INDEMNIFY, NOR HOLD YOU HARMLESS FOR ANY CLAIMS
30+
* ARISING FROM OR RELATED TO THE CODE; AND (D)WITH RESPECT TO YOUR EXERCISE
31+
* OF ANY RIGHTS GRANTED TO YOU FOR THE CODE, CLOUDERA IS NOT LIABLE FOR ANY
32+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR
33+
* CONSEQUENTIAL DAMAGES INCLUDING, BUT NOT LIMITED TO, DAMAGES
34+
* RELATED TO LOST REVENUE, LOST PROFITS, LOSS OF INCOME, LOSS OF
35+
* BUSINESS ADVANTAGE OR UNAVAILABILITY, OR LOSS OR CORRUPTION OF
36+
* DATA.
37+
*/
38+
39+
import { useNavigate } from "@tanstack/react-router";
40+
import { Button, Flex, Result } from "antd";
41+
import Images from "src/components/images/Images.ts";
42+
43+
export const NotFoundComponent = () => {
44+
const navigate = useNavigate();
45+
return (
46+
<Flex
47+
align="center"
48+
justify="center"
49+
style={{ height: "100vh", width: "100%" }}
50+
>
51+
<Result
52+
icon={
53+
<img
54+
src={Images.image404}
55+
alt="Page not found"
56+
height={300}
57+
style={{ borderRadius: 20 }}
58+
/>
59+
}
60+
title="404"
61+
subTitle="Sorry, the page you visited does not exist."
62+
extra={
63+
<Button
64+
type="primary"
65+
onClick={() => {
66+
navigate({ to: "/" }).catch(() => null);
67+
}}
68+
>
69+
Back Home
70+
</Button>
71+
}
72+
/>
73+
</Flex>
74+
);
75+
};

ui/src/main.tsx

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,21 @@ import React from "react";
4040
import ReactDOM from "react-dom/client";
4141
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
4242
import { routeTree } from "./routeTree.gen";
43-
import {
44-
createRouter,
45-
ErrorComponent,
46-
RouterProvider,
47-
useNavigate,
48-
} from "@tanstack/react-router";
43+
import { createRouter, RouterProvider } from "@tanstack/react-router";
4944
import "./index.css";
5045
import { ApiError } from "./api/utils";
51-
import { Button, Flex, Result, Spin, Typography } from "antd";
52-
import Images from "src/components/images/Images.ts";
46+
import { Flex, Spin, Typography } from "antd";
47+
import { NotFoundComponent } from "src/components/ErrorComponents/NotFoundComponent.tsx";
48+
import { CustomUnhandledError } from "src/components/ErrorComponents/CustomUnhandledError.tsx";
5349

5450
const queryClient = new QueryClient({
5551
defaultOptions: {
5652
queries: {
5753
retry: (_, error: Error) => {
5854
if (error instanceof ApiError) {
55+
if (error.message.includes("No such file or directory: '/tmp/jwt'")) {
56+
return false;
57+
}
5958
return error.status >= 500;
6059
}
6160
return true;
@@ -64,44 +63,10 @@ const queryClient = new QueryClient({
6463
},
6564
});
6665

67-
export const NotFoundComponent = () => {
68-
const navigate = useNavigate();
69-
return (
70-
<Flex
71-
align="center"
72-
justify="center"
73-
style={{ height: "100vh", width: "100%" }}
74-
>
75-
<Result
76-
icon={
77-
<img
78-
src={Images.image404}
79-
alt="Page not found"
80-
height={300}
81-
style={{ borderRadius: 20 }}
82-
/>
83-
}
84-
title="404"
85-
subTitle="Sorry, the page you visited does not exist."
86-
extra={
87-
<Button
88-
type="primary"
89-
onClick={() => {
90-
navigate({ to: "/" }).catch(() => null);
91-
}}
92-
>
93-
Back Home
94-
</Button>
95-
}
96-
/>
97-
</Flex>
98-
);
99-
};
100-
10166
const router = createRouter({
10267
routeTree,
10368
context: { queryClient: queryClient },
104-
defaultErrorComponent: ({ error }) => <ErrorComponent error={error} />,
69+
defaultErrorComponent: ({ error }) => <CustomUnhandledError error={error} />,
10570
defaultNotFoundComponent: () => <NotFoundComponent />,
10671
defaultPendingComponent: () => (
10772
<Flex

ui/src/routes/_layout/chats/_layout-chats/projects/$projectId/index.lazy.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ import { ProjectProvider } from "pages/Projects/ProjectContext.tsx";
4242
import ProjectPage from "pages/Projects/ProjectPage/ProjectPage.tsx";
4343
import { useSuspenseQuery } from "@tanstack/react-query";
4444
import { getProjectsQueryOptions } from "src/api/projectsApi.ts";
45-
import { NotFoundComponent } from "src/main.tsx";
45+
46+
import { NotFoundComponent } from "src/components/ErrorComponents/NotFoundComponent.tsx";
4647

4748
export const Route = createLazyFileRoute(
4849
"/_layout/chats/_layout-chats/projects/$projectId/",

ui/src/routes/_layout/projects/_layout-projects/$projectId.lazy.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ import { ProjectProvider } from "pages/Projects/ProjectContext.tsx";
4242
import { Flex } from "antd";
4343
import { getProjectsQueryOptions } from "src/api/projectsApi.ts";
4444
import { useSuspenseQuery } from "@tanstack/react-query";
45-
import { NotFoundComponent } from "src/main.tsx";
45+
46+
import { NotFoundComponent } from "src/components/ErrorComponents/NotFoundComponent.tsx";
4647

4748
export const Route = createLazyFileRoute(
4849
"/_layout/projects/_layout-projects/$projectId",

ui/src/routes/_layout/settings/_layout-settings/index.lazy.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838

3939
import { createLazyFileRoute } from "@tanstack/react-router";
4040
import SettingsPage from "pages/Settings/SettingsPage.tsx";
41-
import { NotFoundComponent } from "src/main.tsx";
4241
import { Flex, Layout, Typography } from "antd";
4342
import { cdlGray300 } from "src/cuix/variables.ts";
4443
import { useSuspenseQuery } from "@tanstack/react-query";
4544
import { getAmpConfigQueryOptions } from "src/api/ampMetadataApi.ts";
45+
import { NotFoundComponent } from "src/components/ErrorComponents/NotFoundComponent.tsx";
4646

4747
const { Content, Header } = Layout;
4848

0 commit comments

Comments
 (0)