@@ -32,6 +32,8 @@ import { useManagedWorkspaces } from "./hooks/enterprise/useManagedWorkspaces";
32
32
import { getMergedWorkspaces } from "./utils/getMergedWorkspaces" ;
33
33
import { Workspace } from "./types/workspace.types" ;
34
34
import { connectManagedWorkspace , unconnectManagedWorkspace } from "./services/enterprise.service" ;
35
+ import WorkspacesTab from "./components/WorkspacesTab" ;
36
+ import UserGroupsTab from "./components/UserGroupsTab" ;
35
37
36
38
37
39
const { Title, Text } = Typography ;
@@ -253,105 +255,7 @@ const EnvironmentDetail: React.FC = () => {
253
255
}
254
256
key = "workspaces"
255
257
>
256
- < Card >
257
- { /* Header with refresh button */ }
258
- < div
259
- style = { {
260
- display : "flex" ,
261
- justifyContent : "space-between" ,
262
- alignItems : "center" ,
263
- marginBottom : "16px" ,
264
- } }
265
- >
266
- < Title level = { 5 } > Workspaces in this Environment</ Title >
267
- < Button
268
- icon = { < SyncOutlined /> }
269
- onClick = { refreshWorkspaces }
270
- size = "small"
271
- loading = { workspacesLoading }
272
- >
273
- Refresh Workspaces
274
- </ Button >
275
- </ div >
276
-
277
- { /* Workspace Statistics */ }
278
- < Row gutter = { 16 } style = { { marginBottom : "24px" } } >
279
- < Col span = { 8 } >
280
- < Statistic
281
- title = "Total Workspaces"
282
- value = { workspaceStats . total }
283
- prefix = { < ClusterOutlined /> }
284
- />
285
- </ Col >
286
- < Col span = { 8 } >
287
- < Statistic
288
- title = "Managed Workspaces"
289
- value = { workspaceStats . managed }
290
- prefix = { < ClusterOutlined /> }
291
- />
292
- </ Col >
293
- < Col span = { 8 } >
294
- < Statistic
295
- title = "Unmanaged Workspaces"
296
- value = { workspaceStats . unmanaged }
297
- prefix = { < ClusterOutlined /> }
298
- />
299
- </ Col >
300
- </ Row >
301
-
302
- < Divider style = { { margin : "16px 0" } } />
303
-
304
- { /* Show error if workspace loading failed */ }
305
- { workspacesError && (
306
- < Alert
307
- message = "Error loading workspaces"
308
- description = { workspacesError }
309
- type = "error"
310
- showIcon
311
- style = { { marginBottom : "16px" } }
312
- action = {
313
- workspacesError . includes ( "No API key configured" ) ? (
314
- < Button size = "small" type = "primary" disabled >
315
- API Key Required
316
- </ Button >
317
- ) : (
318
- < Button
319
- size = "small"
320
- type = "primary"
321
- onClick = { refreshWorkspaces }
322
- >
323
- Try Again
324
- </ Button >
325
- )
326
- }
327
- />
328
- ) }
329
-
330
- { ( ! environment . environmentApikey ||
331
- ! environment . environmentApiServiceUrl ) &&
332
- ! workspacesError && (
333
- < Alert
334
- message = "Configuration Issue"
335
- description = {
336
- ! environment . environmentApikey
337
- ? "An API key is required to fetch workspaces for this environment."
338
- : "An API service URL is required to fetch workspaces for this environment."
339
- }
340
- type = "warning"
341
- showIcon
342
- style = { { marginBottom : "16px" } }
343
- />
344
- ) }
345
-
346
- { /* Workspaces List */ }
347
- < WorkspacesList
348
- workspaces = { mergedWorkspaces } // ⬅️ Use local state!
349
- loading = { workspacesLoading && ! workspacesError }
350
- error = { workspacesError }
351
- environmentId = { environment . environmentId }
352
- onToggleManaged = { handleToggleManaged } // ⬅️ Add this to enable toggles
353
- />
354
- </ Card >
258
+ < WorkspacesTab environment = { environment } />
355
259
</ TabPane >
356
260
< TabPane
357
261
tab = {
@@ -360,106 +264,8 @@ const EnvironmentDetail: React.FC = () => {
360
264
</ span >
361
265
}
362
266
key = "userGroups"
363
- >
364
- < Card >
365
- { /* Header with refresh button */ }
366
- < div
367
- style = { {
368
- display : "flex" ,
369
- justifyContent : "space-between" ,
370
- alignItems : "center" ,
371
- marginBottom : "16px" ,
372
- } }
373
- >
374
- < Title level = { 5 } > User Groups in this Environment</ Title >
375
- < Button
376
- icon = { < SyncOutlined /> }
377
- onClick = { refreshUserGroups }
378
- size = "small"
379
- loading = { userGroupsLoading }
380
- >
381
- Refresh User Groups
382
- </ Button >
383
- </ div >
384
-
385
- { /* User Group Statistics */ }
386
- < Row gutter = { 16 } style = { { marginBottom : "24px" } } >
387
- < Col span = { 8 } >
388
- < Statistic
389
- title = "Total User Groups"
390
- value = { userGroupStats . total }
391
- prefix = { < TeamOutlined /> }
392
- />
393
- </ Col >
394
- < Col span = { 8 } >
395
- < Statistic
396
- title = "Total Users"
397
- value = { userGroupStats . totalUsers }
398
- prefix = { < UserOutlined /> }
399
- />
400
- </ Col >
401
- < Col span = { 8 } >
402
- < Statistic
403
- title = "Admin Users"
404
- value = { userGroupStats . adminUsers }
405
- prefix = { < UserOutlined /> }
406
- />
407
- </ Col >
408
- </ Row >
409
-
410
- < Divider style = { { margin : "16px 0" } } />
411
-
412
- { /* Show error if user group loading failed */ }
413
- { userGroupsError && (
414
- < Alert
415
- message = "Error loading user groups"
416
- description = { userGroupsError }
417
- type = "error"
418
- showIcon
419
- style = { { marginBottom : "16px" } }
420
- action = {
421
- userGroupsError . includes ( "No API key configured" ) ||
422
- userGroupsError . includes ( "No API service URL configured" ) ? (
423
- < Button size = "small" type = "primary" disabled >
424
- Configuration Required
425
- </ Button >
426
- ) : (
427
- < Button
428
- size = "small"
429
- type = "primary"
430
- onClick = { refreshUserGroups }
431
- >
432
- Try Again
433
- </ Button >
434
- )
435
- }
436
- />
437
- ) }
438
-
439
- { /* Show warning if no API key or API service URL is configured */ }
440
- { ( ! environment . environmentApikey ||
441
- ! environment . environmentApiServiceUrl ) &&
442
- ! userGroupsError && (
443
- < Alert
444
- message = "Configuration Issue"
445
- description = {
446
- ! environment . environmentApikey
447
- ? "An API key is required to fetch user groups for this environment."
448
- : "An API service URL is required to fetch user groups for this environment."
449
- }
450
- type = "warning"
451
- showIcon
452
- style = { { marginBottom : "16px" } }
453
- />
454
- ) }
455
-
456
- { /* User Groups List */ }
457
- < UserGroupsList
458
- userGroups = { userGroups }
459
- loading = { userGroupsLoading && ! userGroupsError }
460
- error = { userGroupsError }
461
- />
462
- </ Card >
267
+ >
268
+ < UserGroupsTab environment = { environment } />
463
269
</ TabPane >
464
270
</ Tabs >
465
271
</ div >
0 commit comments