mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	feat: remove applications from project list that do not exist (#6377)
This commit is contained in:
		
							parent
							
								
									4392fa5890
								
							
						
					
					
						commit
						df93827002
					
				| @ -10,6 +10,11 @@ const StyledTag = styled('div')(({ theme }) => ({ | ||||
|     fontSize: theme.fontSizes.smallerBody, | ||||
| })); | ||||
| 
 | ||||
| const StyledList = styled('ul')(({ theme }) => ({ | ||||
|     padding: theme.spacing(0, 0, 0.5, 2), | ||||
|     margin: theme.spacing(0), | ||||
| })); | ||||
| 
 | ||||
| interface ISdkCellProps { | ||||
|     row: { | ||||
|         original: ProjectApplicationSchema; | ||||
| @ -42,7 +47,7 @@ export const SdkCell: VFC<ISdkCellProps> = ({ row }) => { | ||||
|                                 <Highlighter search={searchQuery}> | ||||
|                                     {sdk.name} | ||||
|                                 </Highlighter> | ||||
|                                 <ul> | ||||
|                                 <StyledList> | ||||
|                                     {sdk.versions.map((version) => ( | ||||
|                                         <li key={version}> | ||||
|                                             <Highlighter search={searchQuery}> | ||||
| @ -50,7 +55,7 @@ export const SdkCell: VFC<ISdkCellProps> = ({ row }) => { | ||||
|                                             </Highlighter> | ||||
|                                         </li> | ||||
|                                     ))} | ||||
|                                 </ul> | ||||
|                                 </StyledList> | ||||
|                             </StyledTag> | ||||
|                         ))} | ||||
|                     </> | ||||
|  | ||||
| @ -56,6 +56,7 @@ beforeAll(async () => { | ||||
| afterEach(async () => { | ||||
|     await db.stores.clientMetricsStoreV2.deleteAll(); | ||||
|     await db.stores.clientInstanceStore.deleteAll(); | ||||
|     await db.stores.clientApplicationsStore.deleteAll(); | ||||
|     await db.stores.featureToggleStore.deleteAll(); | ||||
| }); | ||||
| 
 | ||||
| @ -388,3 +389,25 @@ test('should show correct number of total', async () => { | ||||
|         total: 2, | ||||
|     }); | ||||
| }); | ||||
| 
 | ||||
| test('should not show if metrics exist, but application does not', async () => { | ||||
|     await app.createFeature('toggle-name-1'); | ||||
| 
 | ||||
|     await app.request | ||||
|         .post('/api/client/metrics') | ||||
|         .set('Authorization', defaultToken.secret) | ||||
|         .send(metrics) | ||||
|         .expect(202); | ||||
| 
 | ||||
|     await app.services.clientMetricsServiceV2.bulkAdd(); | ||||
| 
 | ||||
|     const { body } = await app.request | ||||
|         .get('/api/admin/projects/default/applications?sortOrder=desc&limit=1') | ||||
|         .expect('Content-Type', /json/) | ||||
|         .expect(200); | ||||
| 
 | ||||
|     expect(body).toMatchObject({ | ||||
|         applications: [], | ||||
|         total: 0, | ||||
|     }); | ||||
| }); | ||||
|  | ||||
| @ -614,6 +614,11 @@ class ProjectStore implements IProjectStore { | ||||
|                     ), | ||||
|                 ) | ||||
|                     .from('applications as a') | ||||
|                     .innerJoin( | ||||
|                         'client_applications as ca', | ||||
|                         'a.app_name', | ||||
|                         'ca.app_name', | ||||
|                     ) | ||||
|                     .leftJoin('client_instances as ci', function () { | ||||
|                         this.on('ci.app_name', '=', 'a.app_name').andOn( | ||||
|                             'ci.environment', | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user