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>;
 | 
					    isFeatureLimitReached(id: string): Promise<boolean>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    getProjectLinkTemplates(projectId: string): Promise<IProjectLinkTemplate[]>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    getProjectModeCounts(): Promise<ProjectModeCount[]>;
 | 
					    getProjectModeCounts(): Promise<ProjectModeCount[]>;
 | 
				
			||||||
    getApplicationsByProject(
 | 
					    getApplicationsByProject(
 | 
				
			||||||
        searchParams: IProjectApplicationsSearchParams,
 | 
					        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,
 | 
					    IProject,
 | 
				
			||||||
    IProjectApplication,
 | 
					    IProjectApplication,
 | 
				
			||||||
    IProjectApplications,
 | 
					    IProjectApplications,
 | 
				
			||||||
 | 
					    IProjectLinkTemplate,
 | 
				
			||||||
    IProjectUpdate,
 | 
					    IProjectUpdate,
 | 
				
			||||||
    IUnleashConfig,
 | 
					    IUnleashConfig,
 | 
				
			||||||
    ProjectMode,
 | 
					    ProjectMode,
 | 
				
			||||||
@ -122,6 +123,16 @@ class ProjectStore implements IProjectStore {
 | 
				
			|||||||
        return present;
 | 
					        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[]> {
 | 
					    async getAll(query: IProjectQuery = {}): Promise<IProject[]> {
 | 
				
			||||||
        let projects = this.db
 | 
					        let projects = this.db
 | 
				
			||||||
            .select(COLUMNS)
 | 
					            .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,
 | 
					    IEnvironment,
 | 
				
			||||||
    IProject,
 | 
					    IProject,
 | 
				
			||||||
    IProjectApplications,
 | 
					    IProjectApplications,
 | 
				
			||||||
 | 
					    IProjectLinkTemplate,
 | 
				
			||||||
    IProjectStore,
 | 
					    IProjectStore,
 | 
				
			||||||
} from '../../lib/types';
 | 
					} from '../../lib/types';
 | 
				
			||||||
import NotFoundError from '../../lib/error/notfound-error';
 | 
					import NotFoundError from '../../lib/error/notfound-error';
 | 
				
			||||||
@ -190,6 +191,10 @@ export default class FakeProjectStore implements IProjectStore {
 | 
				
			|||||||
        return Promise.resolve(false);
 | 
					        return Promise.resolve(false);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    async getProjectLinkTemplates(id: string): Promise<IProjectLinkTemplate[]> {
 | 
				
			||||||
 | 
					        return [] as IProjectLinkTemplate[];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    getProjectModeCounts(): Promise<ProjectModeCount[]> {
 | 
					    getProjectModeCounts(): Promise<ProjectModeCount[]> {
 | 
				
			||||||
        return Promise.resolve([]);
 | 
					        return Promise.resolve([]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user