1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-08-13 13:48:59 +02: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:
Tymoteusz Czech 2025-05-13 11:21:18 +02:00 committed by GitHub
parent 3c42edfbe8
commit 309816ca38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 0 deletions

View File

@ -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,

View File

@ -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}}',
}),
]),
);
});

View File

@ -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)

View File

@ -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([]);
}