Skip to content

Commit 5bd776b

Browse files
cutomise error page using error image and text from branding settings
1 parent 5705207 commit 5bd776b

File tree

3 files changed

+79
-37
lines changed

3 files changed

+79
-37
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { ExclamationCircleFilled, WarningFilled } from "@ant-design/icons";
2+
import { ALL_APPLICATIONS_URL } from "@lowcoder-ee/constants/routesURL";
3+
import { getBrandingSetting } from "@lowcoder-ee/redux/selectors/enterpriseSelectors";
4+
import { buildMaterialPreviewURL } from "@lowcoder-ee/util/materialUtils";
5+
import Button from "antd/es/button";
6+
import Flex from "antd/es/flex";
7+
import { useMemo } from "react";
8+
import { useSelector } from "react-redux";
9+
import styled from "styled-components";
10+
import history from "util/history";
11+
12+
const StyledFlex = styled(Flex)`
13+
height: 100vh;
14+
width: 300px;
15+
margin: 0 auto;
16+
`;
17+
18+
const StyledErrorImage = styled.img`
19+
width: 300px;
20+
`;
21+
22+
const StyledErrorIcon = styled(ExclamationCircleFilled)`
23+
svg {
24+
width: 80px;
25+
height: 80px;
26+
color: #ff4d4f;
27+
}
28+
`;
29+
30+
const StyledErrorText = styled.h2`
31+
margin: 1rem 0;
32+
`;
33+
34+
const DefaultErrorMessage = 'Something went wrong while displaying this webpage';
35+
36+
const ErrorFallback = (props: {
37+
errorMessage?: string,
38+
}) => {
39+
const brandingSettings = useSelector(getBrandingSetting);
40+
41+
const errorText = useMemo(() => {
42+
if (props.errorMessage) return props.errorMessage;
43+
if (brandingSettings?.config_set?.errorPageText) return brandingSettings?.config_set?.errorPageText;
44+
return DefaultErrorMessage;
45+
}, [props.errorMessage, brandingSettings?.config_set?.errorPageText]);
46+
47+
const errorImage = useMemo(() => {
48+
const imageUrl = brandingSettings?.config_set?.signUpPageImage || '';
49+
if (Boolean(brandingSettings?.orgId)) {
50+
return buildMaterialPreviewURL(imageUrl);
51+
}
52+
return imageUrl;
53+
}, [brandingSettings?.orgId, brandingSettings?.config_set?.errorPageImage]);
54+
55+
return (
56+
57+
<StyledFlex align="center" justify="center" vertical>
58+
{Boolean(errorImage) && false
59+
? <StyledErrorImage src={errorImage} />
60+
: <StyledErrorIcon />
61+
}
62+
<StyledErrorText>{errorText}</StyledErrorText>
63+
<Button type="primary" onClick={() => history.push(ALL_APPLICATIONS_URL)}>
64+
Go to Apps
65+
</Button>
66+
</StyledFlex>
67+
)
68+
}
69+
70+
export default ErrorFallback;

client/packages/lowcoder/src/pages/editor/AppEditor.tsx

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ import { DatasourceApi } from "api/datasourceApi";
2828
import { useRootCompInstance } from "./useRootCompInstance";
2929
import EditorSkeletonView from "./editorSkeletonView";
3030
import {ErrorBoundary, FallbackProps} from 'react-error-boundary';
31-
import { ALL_APPLICATIONS_URL } from "@lowcoder-ee/constants/routesURL";
32-
import history from "util/history";
33-
import Flex from "antd/es/flex";
3431
import React from "react";
3532
import dayjs from "dayjs";
3633
import { currentApplication } from "@lowcoder-ee/redux/selectors/applicationSelector";
@@ -50,6 +47,8 @@ const AppEditorInternalView = lazy(
5047
.then(moduleExports => ({default: moduleExports.AppEditorInternalView}))
5148
);
5249

50+
const ErrorFallback = lazy(() => import("components/ErrorFallback"));
51+
5352
const AppEditor = React.memo(() => {
5453
const dispatch = useDispatch();
5554
const params = useParams<AppPathParams>();
@@ -209,39 +208,12 @@ const AppEditor = React.memo(() => {
209208
}
210209
}, [isLowcoderCompLoading, fetchApplication]);
211210

212-
const fallbackUI = useMemo(() => (
213-
<Flex align="center" justify="center" vertical style={{
214-
height: '300px',
215-
width: '400px',
216-
margin: '0 auto',
217-
}}>
218-
<h4 style={{margin: 0}}>Something went wrong while displaying this webpage</h4>
219-
<button onClick={() => history.push(ALL_APPLICATIONS_URL)} style={{background: '#4965f2',border: '1px solid #4965f2', color: '#ffffff',borderRadius:'6px'}}>Go to Apps</button>
220-
</Flex>
221-
), []);
222-
223211
if (Boolean(appError)) {
224-
return (
225-
<Flex align="center" justify="center" vertical style={{
226-
height: '300px',
227-
width: '400px',
228-
margin: '0 auto',
229-
}}>
230-
<h4>{appError}</h4>
231-
<button onClick={() => history.push(ALL_APPLICATIONS_URL)} style={{background: '#4965f2',border: '1px solid #4965f2', color: '#ffffff',borderRadius:'6px'}}>Back to Home</button>
232-
</Flex>
233-
)
212+
return <ErrorFallback errorMessage={appError} />
234213
}
235214

236215
return (
237-
<ErrorBoundary fallback={fallbackUI}>
238-
{/*<PaginationComp*/}
239-
{/* currentPage={currentPage}*/}
240-
{/* pageSize={pageSize}*/}
241-
{/* setPageSize={setPageSize}*/}
242-
{/* setCurrentPage={setCurrentPage}*/}
243-
{/* total={elements.total}*/}
244-
{/*/>*/}
216+
<ErrorBoundary fallback={<ErrorFallback />}>
245217
{showAppSnapshot ? (
246218
<Suspense fallback={<EditorSkeletonView />}>
247219
<AppSnapshot

client/packages/lowcoder/src/pages/setting/branding/BrandingSetting.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ enum SettingsEnum {
5555
const defaultSettings = {
5656
logo: null,
5757
squareLogo: null,
58-
mainBrandingColor: "#FF5733",
58+
mainBrandingColor: "#B480DE",
5959
appHeaderColor: "#2c2c2c",
6060
adminSidebarColor: "#f7f9fc",
6161
adminSidebarFontColor: "#000000e0",
6262
adminSidebarActiveBgColor: "#ebf0f7",
6363
adminSidebarActiveFontColor: "#4965f2",
64-
editorSidebarColor: "#f4f4f4",
65-
editorSidebarFontColor: "",
66-
editorSidebarActiveBgColor: "",
67-
editorSidebarActiveFontColor: "",
64+
editorSidebarColor: "#393b47",
65+
editorSidebarFontColor: "#ffffffa6",
66+
editorSidebarActiveBgColor: "#8b8fa37f",
67+
editorSidebarActiveFontColor: "#ffffff",
6868
font: "Roboto",
6969
errorPageText: "Oops! Something went wrong.",
7070
errorPageImage: null,

0 commit comments

Comments
 (0)