@@ -11,21 +11,29 @@ import {
1111 Alert ,
1212 Button ,
1313 Breadcrumb ,
14+ Space ,
15+ Tag ,
16+ Switch ,
17+ message
1418} from "antd" ;
1519import {
1620 AppstoreOutlined ,
1721 DatabaseOutlined ,
1822 CodeOutlined ,
1923 HomeOutlined ,
2024 TeamOutlined ,
21- ArrowLeftOutlined
25+ ArrowLeftOutlined ,
26+ CloudUploadOutlined
2227} from "@ant-design/icons" ;
2328import { useEnvironmentContext } from "./context/EnvironmentContext" ;
2429import { useWorkspace } from "./hooks/useWorkspace" ;
2530import DeployableItemsTab from "./components/DeployableItemsTab" ;
2631import { appsConfig } from "./config/apps.config" ;
2732import { dataSourcesConfig } from "./config/data-sources.config" ;
2833import { queryConfig } from "./config/query.config" ;
34+ import { useDeployableItems } from "./hooks/useDeployableItems" ;
35+ import { workspaceConfig } from "./config/workspace.config" ;
36+ import { useDeployModal } from "./context/DeployModalContext" ;
2937
3038const { Title, Text } = Typography ;
3139const { TabPane } = Tabs ;
@@ -45,12 +53,36 @@ const WorkspaceDetail: React.FC = () => {
4553 error : envError ,
4654 } = useEnvironmentContext ( ) ;
4755
48- const {
49- workspace,
50- loading : workspaceLoading ,
51- error : workspaceError ,
52- } = useWorkspace ( environment , workspaceId ) ;
56+ const { openDeployModal} = useDeployModal ( ) ;
57+
58+ // Use our generic hook with the workspace config
59+ const {
60+ items : workspaces ,
61+ stats : workspaceStats ,
62+ loading : workspaceLoading ,
63+ error : workspaceError ,
64+ toggleManagedStatus,
65+ refreshItems
66+ } = useDeployableItems (
67+ workspaceConfig ,
68+ environment ,
69+ { workspaceId } // Additional params if needed
70+ ) ;
71+
72+ // Find the current workspace in the items array
73+ const workspace = workspaces . find ( w => w . id === workspaceId ) ;
74+
75+ const handleToggleManaged = async ( checked : boolean ) => {
76+ if ( ! workspace ) return ;
5377
78+ const success = await toggleManagedStatus ( workspace , checked ) ;
79+ if ( success ) {
80+ message . success ( `Workspace is now ${ checked ? 'Managed' : 'Unmanaged' } ` ) ;
81+ } else {
82+ message . error ( 'Failed to change managed status' ) ;
83+ }
84+ } ;
85+
5486 if ( envLoading || workspaceLoading ) {
5587 return (
5688 < div style = { { display : 'flex' , justifyContent : 'center' , alignItems : 'center' , height : '100%' , padding : '50px' } } >
@@ -93,6 +125,34 @@ const WorkspaceDetail: React.FC = () => {
93125
94126 { /* Header with workspace name and controls */ }
95127 < div className = "workspace-header" style = { { marginBottom : '24px' , display : 'flex' , justifyContent : 'space-between' , alignItems : 'center' } } >
128+ < div style = { { display : 'flex' , justifyContent : 'space-between' , alignItems : 'center' } } >
129+
130+ < div >
131+ < Title level = { 4 } style = { { margin : 0 } } > { workspace . name } </ Title >
132+ < Tag color = { workspace . managed ? 'green' : 'default' } style = { { marginTop : '8px' } } >
133+ { workspace . managed ? 'Managed' : 'Unmanaged' }
134+ </ Tag >
135+ </ div >
136+
137+ < Space >
138+ < Switch
139+ checked = { workspace . managed }
140+ onChange = { handleToggleManaged }
141+ checkedChildren = "Managed"
142+ unCheckedChildren = "Unmanaged"
143+ />
144+ < Button
145+ type = "primary"
146+ icon = { < CloudUploadOutlined /> }
147+ onClick = { ( ) => openDeployModal ( workspace , workspaceConfig , environment ) }
148+ disabled = { ! workspace . managed }
149+ >
150+ Deploy
151+ </ Button >
152+ </ Space >
153+ </ div >
154+
155+
96156 < div >
97157 < Button
98158 type = "link"
0 commit comments