11import React , { useState } from "react" ;
2- import { useParams } from "react-router-dom" ;
32import {
43 Spin ,
54 Typography ,
@@ -8,25 +7,18 @@ import {
87 Tabs ,
98 Alert ,
109 Descriptions ,
11- Dropdown ,
1210 Menu ,
1311 Button ,
1412 Breadcrumb ,
1513} from "antd" ;
1614import {
17- ReloadOutlined ,
1815 LinkOutlined ,
19- ClusterOutlined ,
2016 TeamOutlined ,
21- UserOutlined ,
22- SyncOutlined ,
2317 EditOutlined ,
24- EllipsisOutlined ,
25- MoreOutlined ,
2618 HomeOutlined
2719} from "@ant-design/icons" ;
2820
29- import { useEnvironmentContext } from "./context/EnvironmentContext " ;
21+ import { useSingleEnvironmentContext } from "./context/SingleEnvironmentContext " ;
3022import { workspaceConfig } from "./config/workspace.config" ;
3123import { userGroupsConfig } from "./config/usergroups.config" ;
3224import DeployableItemsTab from "./components/DeployableItemsTab" ;
@@ -37,21 +29,18 @@ import history from "@lowcoder-ee/util/history";
3729const { Title, Text } = Typography ;
3830const { TabPane } = Tabs ;
3931
40-
4132/**
4233 * Environment Detail Page Component
4334 * Shows detailed information about a specific environment
4435 */
4536const EnvironmentDetail : React . FC = ( ) => {
46- // Get environment ID from URL params
37+ // Use the SingleEnvironmentContext instead of EnvironmentContext
4738 const {
4839 environment,
49- isLoadingEnvironment ,
40+ isLoading ,
5041 error,
5142 updateEnvironmentData
52- } = useEnvironmentContext ( ) ;
53-
54-
43+ } = useSingleEnvironmentContext ( ) ;
5544
5645 const [ isEditModalVisible , setIsEditModalVisible ] = useState ( false ) ;
5746 const [ isUpdating , setIsUpdating ] = useState ( false ) ;
@@ -67,11 +56,16 @@ const EnvironmentDetail: React.FC = () => {
6756 } ;
6857
6958 // Handle save environment
70- const handleSaveEnvironment = async ( environmentId : string , data : Partial < Environment > ) => {
59+ const handleSaveEnvironment = async ( data : Partial < Environment > ) => {
60+ if ( ! environment ) return ;
61+
7162 setIsUpdating ( true ) ;
7263 try {
73- await updateEnvironmentData ( environmentId , data ) ;
64+ // Close the modal first, before the update completes
7465 handleCloseModal ( ) ;
66+
67+ // Then update the environment data
68+ await updateEnvironmentData ( data ) ;
7569 } catch ( error ) {
7670 console . error ( 'Failed to update environment:' , error ) ;
7771 } finally {
@@ -89,7 +83,7 @@ const EnvironmentDetail: React.FC = () => {
8983 </ Menu >
9084 ) ;
9185
92- if ( isLoadingEnvironment ) {
86+ if ( isLoading ) {
9387 return (
9488 < div style = { { display : 'flex' , justifyContent : 'center' , padding : '50px' } } >
9589 < Spin size = "large" tip = "Loading environment..." />
@@ -107,6 +101,7 @@ const EnvironmentDetail: React.FC = () => {
107101 />
108102 ) ;
109103 }
104+
110105 return (
111106 < div
112107 className = "environment-detail-container"
@@ -124,7 +119,6 @@ const EnvironmentDetail: React.FC = () => {
124119 < Breadcrumb . Item > { environment . environmentName } </ Breadcrumb . Item >
125120 </ Breadcrumb >
126121
127- { /* Header with environment name and controls */ }
128122 { /* Header with environment name and controls */ }
129123 < div
130124 className = "environment-header"
@@ -231,6 +225,7 @@ const EnvironmentDetail: React.FC = () => {
231225 />
232226 </ TabPane >
233227 </ Tabs >
228+
234229 { /* Edit Environment Modal */ }
235230 { environment && (
236231 < EditEnvironmentModal
@@ -245,4 +240,4 @@ const EnvironmentDetail: React.FC = () => {
245240 ) ;
246241} ;
247242
248- export default EnvironmentDetail ;
243+ export default EnvironmentDetail ;
0 commit comments