1
1
import React , { useState } from "react" ;
2
- import { useParams } from "react-router-dom" ;
3
2
import {
4
3
Spin ,
5
4
Typography ,
@@ -8,25 +7,18 @@ import {
8
7
Tabs ,
9
8
Alert ,
10
9
Descriptions ,
11
- Dropdown ,
12
10
Menu ,
13
11
Button ,
14
12
Breadcrumb ,
15
13
} from "antd" ;
16
14
import {
17
- ReloadOutlined ,
18
15
LinkOutlined ,
19
- ClusterOutlined ,
20
16
TeamOutlined ,
21
- UserOutlined ,
22
- SyncOutlined ,
23
17
EditOutlined ,
24
- EllipsisOutlined ,
25
- MoreOutlined ,
26
18
HomeOutlined
27
19
} from "@ant-design/icons" ;
28
20
29
- import { useEnvironmentContext } from "./context/EnvironmentContext " ;
21
+ import { useSingleEnvironmentContext } from "./context/SingleEnvironmentContext " ;
30
22
import { workspaceConfig } from "./config/workspace.config" ;
31
23
import { userGroupsConfig } from "./config/usergroups.config" ;
32
24
import DeployableItemsTab from "./components/DeployableItemsTab" ;
@@ -37,21 +29,18 @@ import history from "@lowcoder-ee/util/history";
37
29
const { Title, Text } = Typography ;
38
30
const { TabPane } = Tabs ;
39
31
40
-
41
32
/**
42
33
* Environment Detail Page Component
43
34
* Shows detailed information about a specific environment
44
35
*/
45
36
const EnvironmentDetail : React . FC = ( ) => {
46
- // Get environment ID from URL params
37
+ // Use the SingleEnvironmentContext instead of EnvironmentContext
47
38
const {
48
39
environment,
49
- isLoadingEnvironment ,
40
+ isLoading ,
50
41
error,
51
42
updateEnvironmentData
52
- } = useEnvironmentContext ( ) ;
53
-
54
-
43
+ } = useSingleEnvironmentContext ( ) ;
55
44
56
45
const [ isEditModalVisible , setIsEditModalVisible ] = useState ( false ) ;
57
46
const [ isUpdating , setIsUpdating ] = useState ( false ) ;
@@ -67,11 +56,16 @@ const EnvironmentDetail: React.FC = () => {
67
56
} ;
68
57
69
58
// Handle save environment
70
- const handleSaveEnvironment = async ( environmentId : string , data : Partial < Environment > ) => {
59
+ const handleSaveEnvironment = async ( data : Partial < Environment > ) => {
60
+ if ( ! environment ) return ;
61
+
71
62
setIsUpdating ( true ) ;
72
63
try {
73
- await updateEnvironmentData ( environmentId , data ) ;
64
+ // Close the modal first, before the update completes
74
65
handleCloseModal ( ) ;
66
+
67
+ // Then update the environment data
68
+ await updateEnvironmentData ( data ) ;
75
69
} catch ( error ) {
76
70
console . error ( 'Failed to update environment:' , error ) ;
77
71
} finally {
@@ -89,7 +83,7 @@ const EnvironmentDetail: React.FC = () => {
89
83
</ Menu >
90
84
) ;
91
85
92
- if ( isLoadingEnvironment ) {
86
+ if ( isLoading ) {
93
87
return (
94
88
< div style = { { display : 'flex' , justifyContent : 'center' , padding : '50px' } } >
95
89
< Spin size = "large" tip = "Loading environment..." />
@@ -107,6 +101,7 @@ const EnvironmentDetail: React.FC = () => {
107
101
/>
108
102
) ;
109
103
}
104
+
110
105
return (
111
106
< div
112
107
className = "environment-detail-container"
@@ -124,7 +119,6 @@ const EnvironmentDetail: React.FC = () => {
124
119
< Breadcrumb . Item > { environment . environmentName } </ Breadcrumb . Item >
125
120
</ Breadcrumb >
126
121
127
- { /* Header with environment name and controls */ }
128
122
{ /* Header with environment name and controls */ }
129
123
< div
130
124
className = "environment-header"
@@ -231,6 +225,7 @@ const EnvironmentDetail: React.FC = () => {
231
225
/>
232
226
</ TabPane >
233
227
</ Tabs >
228
+
234
229
{ /* Edit Environment Modal */ }
235
230
{ environment && (
236
231
< EditEnvironmentModal
@@ -245,4 +240,4 @@ const EnvironmentDetail: React.FC = () => {
245
240
) ;
246
241
} ;
247
242
248
- export default EnvironmentDetail ;
243
+ export default EnvironmentDetail ;
0 commit comments