mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	feat: add getProjectLinkTemplates method (#9971)
Add `getProjectLinkTemplates` method to ProjectStore and corresponding test. Ideally this should be in a read-model, but let's finish link templates end to end
This commit is contained in:
		
							parent
							
								
									3c42edfbe8
								
							
						
					
					
						commit
						309816ca38
					
				| @ -130,6 +130,8 @@ export interface IProjectStore extends Store<IProject, string> { | ||||
| 
 | ||||
|     isFeatureLimitReached(id: string): Promise<boolean>; | ||||
| 
 | ||||
|     getProjectLinkTemplates(projectId: string): Promise<IProjectLinkTemplate[]>; | ||||
| 
 | ||||
|     getProjectModeCounts(): Promise<ProjectModeCount[]>; | ||||
|     getApplicationsByProject( | ||||
|         searchParams: IProjectApplicationsSearchParams, | ||||
|  | ||||
| @ -229,4 +229,17 @@ test('should update project enterprise settings', async () => { | ||||
|             }), | ||||
|         ]), | ||||
|     ); | ||||
| 
 | ||||
|     const linkTemplates = await projectStore.getProjectLinkTemplates( | ||||
|         project.id, | ||||
|     ); | ||||
| 
 | ||||
|     expect(linkTemplates).toEqual( | ||||
|         expect.arrayContaining([ | ||||
|             expect.objectContaining({ | ||||
|                 title: 'My Link', | ||||
|                 urlTemplate: 'https://example.com/{{flag}}', | ||||
|             }), | ||||
|         ]), | ||||
|     ); | ||||
| }); | ||||
|  | ||||
| @ -7,6 +7,7 @@ import type { | ||||
|     IProject, | ||||
|     IProjectApplication, | ||||
|     IProjectApplications, | ||||
|     IProjectLinkTemplate, | ||||
|     IProjectUpdate, | ||||
|     IUnleashConfig, | ||||
|     ProjectMode, | ||||
| @ -122,6 +123,16 @@ class ProjectStore implements IProjectStore { | ||||
|         return present; | ||||
|     } | ||||
| 
 | ||||
|     async getProjectLinkTemplates(id: string): Promise<IProjectLinkTemplate[]> { | ||||
|         const result = await this.db | ||||
|             .select('link_templates') | ||||
|             .from(SETTINGS_TABLE) | ||||
|             .where({ project: id }) | ||||
|             .first(); | ||||
| 
 | ||||
|         return result?.link_templates || []; | ||||
|     } | ||||
| 
 | ||||
|     async getAll(query: IProjectQuery = {}): Promise<IProject[]> { | ||||
|         let projects = this.db | ||||
|             .select(COLUMNS) | ||||
|  | ||||
							
								
								
									
										5
									
								
								src/test/fixtures/fake-project-store.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								src/test/fixtures/fake-project-store.ts
									
									
									
									
										vendored
									
									
								
							| @ -2,6 +2,7 @@ import type { | ||||
|     IEnvironment, | ||||
|     IProject, | ||||
|     IProjectApplications, | ||||
|     IProjectLinkTemplate, | ||||
|     IProjectStore, | ||||
| } from '../../lib/types'; | ||||
| import NotFoundError from '../../lib/error/notfound-error'; | ||||
| @ -190,6 +191,10 @@ export default class FakeProjectStore implements IProjectStore { | ||||
|         return Promise.resolve(false); | ||||
|     } | ||||
| 
 | ||||
|     async getProjectLinkTemplates(id: string): Promise<IProjectLinkTemplate[]> { | ||||
|         return [] as IProjectLinkTemplate[]; | ||||
|     } | ||||
| 
 | ||||
|     getProjectModeCounts(): Promise<ProjectModeCount[]> { | ||||
|         return Promise.resolve([]); | ||||
|     } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user