mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	feat: add search functionality
This commit is contained in:
		
							parent
							
								
									512b3d1e12
								
							
						
					
					
						commit
						ddd7a2caaf
					
				| @ -1,4 +1,4 @@ | |||||||
| import { useContext } from 'react'; | import { useContext, useEffect, useState } from 'react'; | ||||||
| import { IconButton } from '@material-ui/core'; | import { IconButton } from '@material-ui/core'; | ||||||
| import { Add } from '@material-ui/icons'; | import { Add } from '@material-ui/icons'; | ||||||
| import FilterListIcon from '@material-ui/icons/FilterList'; | import FilterListIcon from '@material-ui/icons/FilterList'; | ||||||
| @ -31,6 +31,18 @@ const ProjectFeatureToggles = ({ | |||||||
|     const history = useHistory(); |     const history = useHistory(); | ||||||
|     const { hasAccess } = useContext(AccessContext); |     const { hasAccess } = useContext(AccessContext); | ||||||
|     const { uiConfig } = useUiConfig(); |     const { uiConfig } = useUiConfig(); | ||||||
|  |     const [filteredFeatures, setFilteredFeatures] = | ||||||
|  |         useState<IFeatureToggleListItem[]>(features); | ||||||
|  | 
 | ||||||
|  |     const searchFeatures = () => { | ||||||
|  |         const filteredData = features.filter(feature => { | ||||||
|  |             return Object.values(feature) | ||||||
|  |                 .join('') | ||||||
|  |                 .toLowerCase() | ||||||
|  |                 .includes('ENV'.toLowerCase()); | ||||||
|  |         }); | ||||||
|  |         setFilteredFeatures(filteredData); | ||||||
|  |     }; | ||||||
|      |      | ||||||
|     return ( |     return ( | ||||||
|         <PageContent |         <PageContent | ||||||
| @ -39,7 +51,7 @@ const ProjectFeatureToggles = ({ | |||||||
|             headerContent={ |             headerContent={ | ||||||
|                 <HeaderTitle |                 <HeaderTitle | ||||||
|                     className={styles.title} |                     className={styles.title} | ||||||
|                     title={`Feature toggles (${features.length})`} |                     title={`Feature toggles (${filteredFeatures.length})`} | ||||||
|                     actions={ |                     actions={ | ||||||
|                         <> |                         <> | ||||||
|                             <ConditionallyRender |                             <ConditionallyRender | ||||||
| @ -79,10 +91,10 @@ const ProjectFeatureToggles = ({ | |||||||
|             } |             } | ||||||
|         > |         > | ||||||
|             <ConditionallyRender |             <ConditionallyRender | ||||||
|                 condition={features?.length > 0} |                 condition={filteredFeatures?.length > 0} | ||||||
|                 show={ |                 show={ | ||||||
|                     <FeatureToggleListNew |                     <FeatureToggleListNew | ||||||
|                         features={features} |                         features={filteredFeatures} | ||||||
|                         loading={loading} |                         loading={loading} | ||||||
|                         projectId={id} |                         projectId={id} | ||||||
|                     /> |                     /> | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user