8
8
Tabs ,
9
9
Alert ,
10
10
Descriptions ,
11
+ Dropdown ,
12
+ Menu ,
13
+ Button ,
11
14
} from "antd" ;
12
15
import {
13
16
ReloadOutlined ,
@@ -16,18 +19,22 @@ import {
16
19
TeamOutlined ,
17
20
UserOutlined ,
18
21
SyncOutlined ,
22
+ EditOutlined ,
23
+ EllipsisOutlined ,
24
+ MoreOutlined ,
19
25
} from "@ant-design/icons" ;
20
26
21
27
import { useEnvironmentContext } from "./context/EnvironmentContext" ;
22
28
import { workspaceConfig } from "./config/workspace.config" ;
23
29
import { userGroupsConfig } from "./config/usergroups.config" ;
24
30
import DeployableItemsTab from "./components/DeployableItemsTab" ;
25
-
26
-
31
+ import EditEnvironmentModal from "./components/EditEnvironmentModal" ;
32
+ import { Environment } from "./types/environment.types" ;
27
33
28
34
const { Title, Text } = Typography ;
29
35
const { TabPane } = Tabs ;
30
36
37
+
31
38
/**
32
39
* Environment Detail Page Component
33
40
* Shows detailed information about a specific environment
@@ -37,11 +44,48 @@ const EnvironmentDetail: React.FC = () => {
37
44
const {
38
45
environment,
39
46
isLoadingEnvironment,
40
- error
47
+ error,
48
+ updateEnvironmentData
41
49
} = useEnvironmentContext ( ) ;
42
50
43
51
44
52
53
+ const [ isEditModalVisible , setIsEditModalVisible ] = useState ( false ) ;
54
+ const [ isUpdating , setIsUpdating ] = useState ( false ) ;
55
+
56
+ // Handle edit menu item click
57
+ const handleEditClick = ( ) => {
58
+ setIsEditModalVisible ( true ) ;
59
+ } ;
60
+
61
+ // Handle modal close
62
+ const handleCloseModal = ( ) => {
63
+ setIsEditModalVisible ( false ) ;
64
+ } ;
65
+
66
+ // Handle save environment
67
+ const handleSaveEnvironment = async ( environmentId : string , data : Partial < Environment > ) => {
68
+ setIsUpdating ( true ) ;
69
+ try {
70
+ await updateEnvironmentData ( environmentId , data ) ;
71
+ handleCloseModal ( ) ;
72
+ } catch ( error ) {
73
+ console . error ( 'Failed to update environment:' , error ) ;
74
+ } finally {
75
+ setIsUpdating ( false ) ;
76
+ }
77
+ } ;
78
+
79
+ // Dropdown menu for environment actions
80
+ const actionsMenu = (
81
+ < Menu >
82
+ < Menu . Item key = "edit" icon = { < EditOutlined /> } onClick = { handleEditClick } >
83
+ Edit Environment
84
+ </ Menu . Item >
85
+ { /* Add more menu items here if needed */ }
86
+ </ Menu >
87
+ ) ;
88
+
45
89
if ( isLoadingEnvironment ) {
46
90
return (
47
91
< div style = { { display : 'flex' , justifyContent : 'center' , padding : '50px' } } >
@@ -78,6 +122,13 @@ const EnvironmentDetail: React.FC = () => {
78
122
</ Title >
79
123
< Text type = "secondary" > ID: { environment . environmentId } </ Text >
80
124
</ div >
125
+ < Dropdown overlay = { actionsMenu } trigger = { [ 'click' ] } >
126
+ < Button
127
+ icon = { < MoreOutlined /> }
128
+ shape = "circle"
129
+ size = "large"
130
+ />
131
+ </ Dropdown >
81
132
</ div >
82
133
83
134
{ /* Basic Environment Information Card */ }
@@ -156,6 +207,17 @@ const EnvironmentDetail: React.FC = () => {
156
207
157
208
</ TabPane >
158
209
</ Tabs >
210
+ { /* Edit Environment Modal */ }
211
+ { environment && (
212
+ < EditEnvironmentModal
213
+ visible = { isEditModalVisible }
214
+ environment = { environment }
215
+ onClose = { handleCloseModal }
216
+ onSave = { handleSaveEnvironment }
217
+ loading = { isUpdating }
218
+ />
219
+ ) }
220
+
159
221
</ div >
160
222
) ;
161
223
} ;
0 commit comments