Skip to content

Commit 29a4fae

Browse files
committed
add err component and fix errors
1 parent ed55d12 commit 29a4fae

File tree

4 files changed

+54
-53
lines changed

4 files changed

+54
-53
lines changed

client/packages/lowcoder/src/pages/setting/environments/EnvironmentDetail.tsx

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import UserGroupsTab from "./components/UserGroupsTab";
2727
import EnvironmentHeader from "./components/EnvironmentHeader";
2828
import ModernBreadcrumbs from "./components/ModernBreadcrumbs";
2929
import { getEnvironmentTagColor } from "./utils/environmentUtils";
30-
const { Title, Text } = Typography;
30+
import ErrorComponent from './components/ErrorComponent';
3131
const { TabPane } = Tabs;
3232

3333
/**
@@ -80,50 +80,18 @@ const EnvironmentDetail: React.FC = () => {
8080
if (isLoading) {
8181
return (
8282
<div style={{ display: 'flex', justifyContent: 'center', padding: '50px' }}>
83-
<Spin size="large" tip="Loading environment..." />
83+
<Spin size="large" tip="Loading environment..." style={{ display: 'block', textAlign: 'center' }} />
8484
</div>
8585
);
8686
}
8787

8888
if (error || !environment) {
89-
const errorItems = [
90-
{
91-
key: 'environments',
92-
title: (
93-
<span>
94-
<HomeOutlined /> Environments
95-
</span>
96-
),
97-
onClick: () => history.push("/setting/environments")
98-
},
99-
{
100-
key: 'notFound',
101-
title: 'Not Found'
102-
}
103-
];
104-
10589
return (
106-
<div style={{ padding: "24px", flex: 1 }}>
107-
<ModernBreadcrumbs items={errorItems} />
108-
109-
<Card style={{ borderRadius: '8px', boxShadow: '0 2px 8px rgba(0,0,0,0.05)' }}>
110-
<div style={{ textAlign: "center", padding: "40px 0" }}>
111-
<Title level={3} style={{ color: "#ff4d4f" }}>
112-
Environment Not Found
113-
</Title>
114-
<Text type="secondary" style={{ display: "block", margin: "16px 0" }}>
115-
{error || "The environment you're looking for doesn't exist or you don't have permission to view it."}
116-
</Text>
117-
<Button
118-
type="primary"
119-
onClick={() => history.push("/setting/environments")}
120-
style={{ marginTop: "16px" }}
121-
>
122-
Return to Environments List
123-
</Button>
124-
</div>
125-
</Card>
126-
</div>
90+
<ErrorComponent
91+
errorMessage={"Environment Not Found"}
92+
returnPath="/setting/environments"
93+
returnLabel="Return to Environments List"
94+
/>
12795
);
12896
}
12997

client/packages/lowcoder/src/pages/setting/environments/EnvironmentsList.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,7 @@ const EnvironmentsList: React.FC = () => {
139139
borderRadius: '12px',
140140
boxShadow: '0 2px 8px rgba(0,0,0,0.05)'
141141
}}
142-
headStyle={{
143-
borderBottom: '1px solid #f0f0f0',
144-
padding: '16px 24px'
145-
}}
142+
styles={{ header: { borderBottom: '1px solid #f0f0f0', padding: '16px 24px' } }}
146143
bodyStyle={{ padding: '24px' }}
147144
>
148145
<Row gutter={[32, 16]} justify="space-around">
@@ -191,10 +188,7 @@ const EnvironmentsList: React.FC = () => {
191188
borderRadius: '12px',
192189
boxShadow: '0 2px 8px rgba(0,0,0,0.05)',
193190
}}
194-
headStyle={{
195-
borderBottom: '1px solid #f0f0f0',
196-
padding: '16px 24px'
197-
}}
191+
styles={{ header: { borderBottom: '1px solid #f0f0f0', padding: '16px 24px' } }}
198192
bodyStyle={{ padding: '24px' }}
199193
extra={
200194
<Input

client/packages/lowcoder/src/pages/setting/environments/WorkspaceDetail.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import DataSourcesTab from "./components/DataSourcesTab";
2525
import QueriesTab from "./components/QueriesTab";
2626
import ModernBreadcrumbs from "./components/ModernBreadcrumbs";
2727
import WorkspaceHeader from "./components/WorkspaceHeader";
28+
import ErrorComponent from "./components/ErrorComponent";
2829

2930
const { TabPane } = Tabs;
3031

@@ -57,18 +58,18 @@ const WorkspaceDetail: React.FC = () => {
5758
if (isLoading) {
5859
return (
5960
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100%', padding: '50px' }}>
60-
<Spin size="large" tip="Loading workspace details..." />
61+
<Spin size="large" tip="Loading workspace details..." style={{ display: 'block', textAlign: 'center' }} />
6162
</div>
6263
);
6364
}
6465

6566
if (error || !environment || !workspace) {
6667
return (
67-
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100%', padding: '50px' }}>
68-
<Typography.Title level={3}>
69-
{error || "Workspace not found"}
70-
</Typography.Title>
71-
</div>
68+
<ErrorComponent
69+
errorMessage={"Workspace not found"}
70+
returnPath="/setting/environments"
71+
returnLabel="Return to Environments List"
72+
/>
7273
);
7374
}
7475

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React from 'react';
2+
import { Card, Button, Typography } from 'antd';
3+
import { HomeOutlined } from '@ant-design/icons';
4+
import history from '@lowcoder-ee/util/history';
5+
6+
const { Title, Text } = Typography;
7+
8+
interface ErrorComponentProps {
9+
errorMessage: string;
10+
returnPath: string;
11+
returnLabel: string;
12+
}
13+
14+
const ErrorComponent: React.FC<ErrorComponentProps> = ({ errorMessage, returnPath, returnLabel }) => {
15+
return (
16+
<div style={{ padding: '24px', flex: 1 }}>
17+
<Card style={{ borderRadius: '8px', boxShadow: '0 2px 8px rgba(0,0,0,0.05)' }}>
18+
<div style={{ textAlign: 'center', padding: '40px 0' }}>
19+
<Title level={3} style={{ color: '#ff4d4f' }}>
20+
{errorMessage}
21+
</Title>
22+
<Text type="secondary" style={{ display: 'block', margin: '16px 0' }}>
23+
The item you're looking for doesn't exist or you don't have permission to view it.
24+
</Text>
25+
<Button
26+
type="primary"
27+
onClick={() => history.push(returnPath)}
28+
style={{ marginTop: '16px' }}
29+
>
30+
<HomeOutlined /> {returnLabel}
31+
</Button>
32+
</div>
33+
</Card>
34+
</div>
35+
);
36+
};
37+
38+
export default ErrorComponent;

0 commit comments

Comments
 (0)