@@ -34,6 +34,7 @@ import { useManagedApps } from "./hooks/enterprise/useManagedApps";
34
34
import { App } from "./types/app.types" ;
35
35
import { getMergedApps } from "./utils/getMergedApps" ;
36
36
import { connectManagedApp , unconnectManagedApp } from "./services/enterprise.service" ;
37
+ import AppsTab from "./components/AppsTab" ;
37
38
38
39
const { Title, Text } = Typography ;
39
40
const { TabPane } = Tabs ;
@@ -60,14 +61,6 @@ const WorkspaceDetail: React.FC = () => {
60
61
refresh : refreshWorkspace
61
62
} = useWorkspace ( environment , workspaceId ) ;
62
63
63
- const {
64
- apps,
65
- loading : appsLoading ,
66
- error : appsError ,
67
- refresh : refreshApps ,
68
- appStats,
69
- } = useWorkspaceApps ( environment , workspaceId ) ;
70
-
71
64
const {
72
65
dataSources,
73
66
loading : dataSourcesLoading ,
@@ -76,35 +69,6 @@ const WorkspaceDetail: React.FC = () => {
76
69
dataSourceStats,
77
70
} = useWorkspaceDataSources ( environment , workspaceId ) ;
78
71
79
- const { managedApps } = useManagedApps ( environmentId ) ;
80
- const [ mergedApps , setMergedApps ] = useState < App [ ] > ( [ ] ) ;
81
-
82
- useEffect ( ( ) => {
83
- setMergedApps ( getMergedApps ( apps , managedApps ) ) ;
84
- } , [ apps , managedApps ] ) ;
85
-
86
-
87
-
88
-
89
- const handleToggleManagedApp = async ( app : App , checked : boolean ) => {
90
- try {
91
- if ( checked ) {
92
- await connectManagedApp ( environmentId , app . name , app . applicationGid ! ) ;
93
- } else {
94
- await unconnectManagedApp ( app . applicationGid ! ) ;
95
- }
96
-
97
- setMergedApps ( ( currentApps ) =>
98
- currentApps . map ( ( a ) =>
99
- a . applicationId === app . applicationId ? { ...a , managed : checked } : a
100
- )
101
- ) ;
102
-
103
- message . success ( `${ app . name } is now ${ checked ? "Managed" : "Unmanaged" } ` ) ;
104
- } catch {
105
- message . error ( `Failed to toggle ${ app . name } ` ) ;
106
- }
107
- } ;
108
72
if ( envLoading || workspaceLoading ) {
109
73
return (
110
74
< div style = { { display : 'flex' , justifyContent : 'center' , alignItems : 'center' , height : '100%' , padding : '50px' } } >
@@ -167,64 +131,7 @@ const WorkspaceDetail: React.FC = () => {
167
131
tab = { < span > < AppstoreOutlined /> Apps</ span > }
168
132
key = "apps"
169
133
>
170
- < Card >
171
- { /* Header with refresh button */ }
172
- < div style = { { display : 'flex' , justifyContent : 'space-between' , alignItems : 'center' , marginBottom : '16px' } } >
173
- < Title level = { 5 } > Apps in this Workspace</ Title >
174
- < Button
175
- icon = { < SyncOutlined /> }
176
- onClick = { refreshApps }
177
- size = "small"
178
- loading = { appsLoading }
179
- >
180
- Refresh Apps
181
- </ Button >
182
- </ div >
183
-
184
- { /* App Statistics */ }
185
- < Row gutter = { 16 } style = { { marginBottom : '24px' } } >
186
- < Col span = { 8 } >
187
- < Statistic
188
- title = "Total Apps"
189
- value = { appStats . total }
190
- prefix = { < AppstoreOutlined /> }
191
- />
192
- </ Col >
193
- < Col span = { 8 } >
194
- < Statistic
195
- title = "Published Apps"
196
- value = { appStats . published }
197
- prefix = { < AppstoreOutlined /> }
198
- />
199
- </ Col >
200
- </ Row >
201
-
202
- < Divider style = { { margin : '16px 0' } } />
203
-
204
- { /* Show error if apps loading failed */ }
205
- { appsError && (
206
- < Alert
207
- message = "Error loading apps"
208
- description = { appsError }
209
- type = "error"
210
- showIcon
211
- style = { { marginBottom : '16px' } }
212
- action = {
213
- < Button size = "small" type = "primary" onClick = { refreshApps } >
214
- Try Again
215
- </ Button >
216
- }
217
- />
218
- ) }
219
-
220
- { /* Apps List */ }
221
- < AppsList
222
- apps = { mergedApps }
223
- loading = { appsLoading }
224
- error = { appsError }
225
- onToggleManaged = { handleToggleManagedApp }
226
- />
227
- </ Card >
134
+ < AppsTab environment = { environment } workspaceId = { workspaceId } />
228
135
</ TabPane >
229
136
230
137
{ /* Update the TabPane in WorkspaceDetail.tsx */ }
0 commit comments