11import React , { useState , useEffect } from 'react' ;
22import { Card , Button , Divider , Alert , message , Table , Tag , Input , Space , Tooltip , Row , Col , Avatar } from 'antd' ;
3- import { SyncOutlined , AuditOutlined , TeamOutlined , CheckCircleFilled , CloudServerOutlined , DisconnectOutlined } from '@ant-design/icons' ;
3+ import { SyncOutlined , AuditOutlined , TeamOutlined , CheckCircleFilled , CloudServerOutlined , DisconnectOutlined , FilterOutlined } from '@ant-design/icons' ;
44import Title from 'antd/lib/typography/Title' ;
55import { Environment } from '../types/environment.types' ;
66import { Workspace } from '../types/workspace.types' ;
@@ -26,6 +26,7 @@ const WorkspacesTab: React.FC<WorkspacesTabProps> = ({ environment }) => {
2626 const [ refreshing , setRefreshing ] = useState ( false ) ;
2727 const [ error , setError ] = useState < string | null > ( null ) ;
2828 const [ searchText , setSearchText ] = useState ( '' ) ;
29+ const [ showManagedOnly , setShowManagedOnly ] = useState ( false ) ;
2930
3031 // Fetch workspaces
3132 const fetchWorkspaces = async ( ) => {
@@ -73,13 +74,17 @@ const WorkspacesTab: React.FC<WorkspacesTabProps> = ({ environment }) => {
7374 history . push ( `/setting/environments/${ environment . environmentId } /workspaces/${ workspace . id } ` ) ;
7475 } ;
7576
76- // Filter workspaces based on search
77+ // Filter workspaces based on search and managed status
7778 const filteredWorkspaces = searchText
7879 ? workspaces . filter ( workspace =>
7980 workspace . name . toLowerCase ( ) . includes ( searchText . toLowerCase ( ) ) ||
8081 workspace . id . toLowerCase ( ) . includes ( searchText . toLowerCase ( ) ) )
8182 : workspaces ;
8283
84+ const displayedWorkspaces = showManagedOnly
85+ ? filteredWorkspaces . filter ( workspace => workspace . managed )
86+ : filteredWorkspaces ;
87+
8388 // Helper function to generate colors from strings
8489 const stringToColor = ( str : string ) => {
8590 let hash = 0 ;
@@ -301,8 +306,8 @@ const WorkspacesTab: React.FC<WorkspacesTabProps> = ({ environment }) => {
301306 />
302307 ) : (
303308 < >
304- { /* Search Bar */ }
305- < div style = { { marginBottom : 20 } } >
309+ { /* Search and Filter Bar */ }
310+ < div style = { { display : 'flex' , justifyContent : 'space-between' , marginBottom : 20 } } >
306311 < Search
307312 placeholder = "Search workspaces by name or ID"
308313 allowClear
@@ -311,16 +316,28 @@ const WorkspacesTab: React.FC<WorkspacesTabProps> = ({ environment }) => {
311316 style = { { width : 300 } }
312317 size = "large"
313318 />
314- { searchText && filteredWorkspaces . length !== workspaces . length && (
315- < div style = { { marginTop : 8 , color : '#8c8c8c' } } >
316- Showing { filteredWorkspaces . length } of { workspaces . length } workspaces
317- </ div >
318- ) }
319+ < Button
320+ onClick = { ( ) => setShowManagedOnly ( ! showManagedOnly ) }
321+ type = "default"
322+ icon = { < FilterOutlined /> }
323+ style = { {
324+ marginLeft : '8px' ,
325+ backgroundColor : showManagedOnly ? '#52c41a' : 'white' ,
326+ color : showManagedOnly ? 'white' : '#52c41a' ,
327+ borderColor : '#52c41a'
328+ } }
329+ />
319330 </ div >
320331
332+ { searchText && displayedWorkspaces . length !== workspaces . length && (
333+ < div style = { { marginTop : 8 , color : '#8c8c8c' } } >
334+ Showing { displayedWorkspaces . length } of { workspaces . length } workspaces
335+ </ div >
336+ ) }
337+
321338 < Table
322339 columns = { columns }
323- dataSource = { filteredWorkspaces }
340+ dataSource = { displayedWorkspaces }
324341 rowKey = "id"
325342 pagination = { {
326343 pageSize : 10 ,
0 commit comments