mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	refactor: remove unused component UserSeats (#8757)
https://linear.app/unleash/issue/2-2974/remove-unused-component-userseats Removes the unused component `UserSeats`.
This commit is contained in:
		
							parent
							
								
									5a2663a451
								
							
						
					
					
						commit
						6db6cc2bd6
					
				| @ -1,31 +0,0 @@ | |||||||
| import { testServerRoute, testServerSetup } from '../../../../utils/testServer'; |  | ||||||
| import { screen } from '@testing-library/react'; |  | ||||||
| import { render } from 'utils/testRenderer'; |  | ||||||
| import { UserSeats } from './UserSeats'; |  | ||||||
| import { BILLING_PRO_DEFAULT_INCLUDED_SEATS } from 'component/admin/billing/BillingDashboard/BillingPlan/BillingPlan'; |  | ||||||
| 
 |  | ||||||
| const server = testServerSetup(); |  | ||||||
| const user1 = {}; |  | ||||||
| const user2 = {}; |  | ||||||
| 
 |  | ||||||
| const setupApi = () => { |  | ||||||
|     testServerRoute(server, '/api/admin/user-admin', { |  | ||||||
|         users: [user1, user2], |  | ||||||
|     }); |  | ||||||
|     testServerRoute(server, '/api/admin/ui-config', { |  | ||||||
|         flags: { |  | ||||||
|             UNLEASH_CLOUD: true, |  | ||||||
|         }, |  | ||||||
|     }); |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| test('User seats display when seats are available', async () => { |  | ||||||
|     setupApi(); |  | ||||||
| 
 |  | ||||||
|     render(<UserSeats />); |  | ||||||
| 
 |  | ||||||
|     await screen.findByText('User seats'); |  | ||||||
|     await screen.findByText( |  | ||||||
|         `2/${BILLING_PRO_DEFAULT_INCLUDED_SEATS} seats used`, |  | ||||||
|     ); |  | ||||||
| }); |  | ||||||
| @ -1,61 +0,0 @@ | |||||||
| import LicenseIcon from '@mui/icons-material/ReceiptLongOutlined'; |  | ||||||
| import { Box, styled, Typography } from '@mui/material'; |  | ||||||
| import LinearProgress from '@mui/material/LinearProgress'; |  | ||||||
| import { useUsers } from 'hooks/api/getters/useUsers/useUsers'; |  | ||||||
| import { BILLING_PRO_DEFAULT_INCLUDED_SEATS } from 'component/admin/billing/BillingDashboard/BillingPlan/BillingPlan'; |  | ||||||
| 
 |  | ||||||
| const SeatsUsageBar = styled(LinearProgress)(({ theme }) => ({ |  | ||||||
|     marginTop: theme.spacing(0.5), |  | ||||||
|     height: theme.spacing(0.5), |  | ||||||
|     borderRadius: theme.shape.borderRadiusMedium, |  | ||||||
| })); |  | ||||||
| 
 |  | ||||||
| const TotalSeatsRow = styled(Box)(({ theme }) => ({ |  | ||||||
|     display: 'flex', |  | ||||||
|     gap: 1, |  | ||||||
|     alignItems: 'center', |  | ||||||
| })); |  | ||||||
| 
 |  | ||||||
| const TotalSeats = styled(Typography)(({ theme }) => ({ |  | ||||||
|     fontWeight: theme.typography.fontWeightBold, |  | ||||||
|     fontSize: theme.typography.h1.fontSize, |  | ||||||
|     color: theme.palette.primary.main, |  | ||||||
| })); |  | ||||||
| 
 |  | ||||||
| const SeatsUsageRow = styled(Box)(({ theme }) => ({ |  | ||||||
|     marginTop: theme.spacing(2), |  | ||||||
| })); |  | ||||||
| 
 |  | ||||||
| const SeatsUsageText = styled(Box)(({ theme }) => ({ |  | ||||||
|     textAlign: 'right', |  | ||||||
| })); |  | ||||||
| 
 |  | ||||||
| export const UserSeats = () => { |  | ||||||
|     const { users } = useUsers(); |  | ||||||
|     const seats = BILLING_PRO_DEFAULT_INCLUDED_SEATS; |  | ||||||
| 
 |  | ||||||
|     if (typeof seats === 'number') { |  | ||||||
|         const percentageSeats = Math.floor((users.length / seats) * 100); |  | ||||||
| 
 |  | ||||||
|         return ( |  | ||||||
|             <Box> |  | ||||||
|                 <TotalSeatsRow> |  | ||||||
|                     <LicenseIcon /> |  | ||||||
|                     <Typography sx={{ flex: 1 }}>User seats</Typography> |  | ||||||
|                     <TotalSeats>{seats}</TotalSeats> |  | ||||||
|                 </TotalSeatsRow> |  | ||||||
|                 <SeatsUsageRow> |  | ||||||
|                     <SeatsUsageText> |  | ||||||
|                         {users.length}/{seats} seats used |  | ||||||
|                     </SeatsUsageText> |  | ||||||
|                     <SeatsUsageBar |  | ||||||
|                         variant='determinate' |  | ||||||
|                         value={Math.min(100, percentageSeats)} |  | ||||||
|                     /> |  | ||||||
|                 </SeatsUsageRow> |  | ||||||
|             </Box> |  | ||||||
|         ); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     return null; |  | ||||||
| }; |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user