mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	feat: display total count (#9753)
This commit is contained in:
		
							parent
							
								
									5b52a6e8d1
								
							
						
					
					
						commit
						e6d55ab17a
					
				| @ -27,6 +27,7 @@ const StyledChip = styled(Chip, { | |||||||
| interface ILifecycleFiltersProps { | interface ILifecycleFiltersProps { | ||||||
|     state: FilterItemParamHolder; |     state: FilterItemParamHolder; | ||||||
|     onChange: (value: FilterItemParamHolder) => void; |     onChange: (value: FilterItemParamHolder) => void; | ||||||
|  |     total?: number; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const Wrapper = styled(Box)(({ theme }) => ({ | const Wrapper = styled(Box)(({ theme }) => ({ | ||||||
| @ -49,6 +50,7 @@ const lifecycleOptions: { | |||||||
| export const LifecycleFilters: FC<ILifecycleFiltersProps> = ({ | export const LifecycleFilters: FC<ILifecycleFiltersProps> = ({ | ||||||
|     state, |     state, | ||||||
|     onChange, |     onChange, | ||||||
|  |     total, | ||||||
| }) => { | }) => { | ||||||
|     const current = state.lifecycle?.values ?? []; |     const current = state.lifecycle?.values ?? []; | ||||||
| 
 | 
 | ||||||
| @ -57,6 +59,10 @@ export const LifecycleFilters: FC<ILifecycleFiltersProps> = ({ | |||||||
|             {lifecycleOptions.map(({ label, value }) => { |             {lifecycleOptions.map(({ label, value }) => { | ||||||
|                 const isActive = |                 const isActive = | ||||||
|                     value === null ? !state.lifecycle : current.includes(value); |                     value === null ? !state.lifecycle : current.includes(value); | ||||||
|  |                 const dynamicLabel = | ||||||
|  |                     isActive && Number.isInteger(total) | ||||||
|  |                         ? `${label} (${total})` | ||||||
|  |                         : label; | ||||||
| 
 | 
 | ||||||
|                 const handleClick = () => |                 const handleClick = () => | ||||||
|                     onChange( |                     onChange( | ||||||
| @ -73,7 +79,7 @@ export const LifecycleFilters: FC<ILifecycleFiltersProps> = ({ | |||||||
|                 return ( |                 return ( | ||||||
|                     <StyledChip |                     <StyledChip | ||||||
|                         key={label} |                         key={label} | ||||||
|                         label={label} |                         label={dynamicLabel} | ||||||
|                         variant='outlined' |                         variant='outlined' | ||||||
|                         isActive={isActive} |                         isActive={isActive} | ||||||
|                         onClick={handleClick} |                         onClick={handleClick} | ||||||
|  | |||||||
| @ -466,6 +466,7 @@ export const FeatureToggleListTable: FC = () => { | |||||||
|                 <LifecycleFilters |                 <LifecycleFilters | ||||||
|                     state={filterState} |                     state={filterState} | ||||||
|                     onChange={setTableState} |                     onChange={setTableState} | ||||||
|  |                     total={loading ? undefined : total} | ||||||
|                 /> |                 /> | ||||||
|             ) : null} |             ) : null} | ||||||
|             <FeatureToggleFilters |             <FeatureToggleFilters | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user