mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-18 00:19:49 +01:00
feat: filter out archived projects from the main project list (#7803)
This commit is contained in:
parent
3fe385e127
commit
fffed5d8dc
@ -79,7 +79,10 @@ beforeAll(async () => {
|
||||
email: 'test@example.com',
|
||||
});
|
||||
await stores.accessStore.addUserToRole(opsUser.id, 1, '');
|
||||
const config = createTestConfig({ getLogger });
|
||||
const config = createTestConfig({
|
||||
getLogger,
|
||||
experimental: { flags: { archiveProjects: true } },
|
||||
});
|
||||
eventService = new EventService(stores, config);
|
||||
accessService = createAccessService(db.rawDatabase, config);
|
||||
|
||||
@ -299,6 +302,10 @@ test('should archive project', async () => {
|
||||
type: 'project-archived',
|
||||
createdBy: TEST_AUDIT_USER.username,
|
||||
});
|
||||
|
||||
const projects = await projectService.getProjects();
|
||||
expect(projects.find((p) => p.id === project.id)).toBeUndefined();
|
||||
expect(projects.length).not.toBe(0);
|
||||
});
|
||||
|
||||
test('should not be able to archive project with flags', async () => {
|
||||
|
@ -140,6 +140,9 @@ class ProjectStore implements IProjectStore {
|
||||
)
|
||||
.leftJoin('project_stats', 'project_stats.project', 'projects.id')
|
||||
.orderBy('projects.name', 'asc');
|
||||
if (this.flagResolver.isEnabled('archiveProjects')) {
|
||||
projects = projects.where('projects.archived_at', null);
|
||||
}
|
||||
|
||||
if (query) {
|
||||
projects = projects.where(query);
|
||||
|
19
src/test/fixtures/fake-project-store.ts
vendored
19
src/test/fixtures/fake-project-store.ts
vendored
@ -19,8 +19,10 @@ import type {
|
||||
ProjectEnvironment,
|
||||
} from '../../lib/features/project/project-store-type';
|
||||
|
||||
type ArchivableProject = IProject & { archivedAt: null | Date };
|
||||
|
||||
export default class FakeProjectStore implements IProjectStore {
|
||||
projects: IProject[] = [];
|
||||
projects: ArchivableProject[] = [];
|
||||
|
||||
projectEnvironment: Map<string, Set<string>> = new Map();
|
||||
|
||||
@ -47,7 +49,9 @@ export default class FakeProjectStore implements IProjectStore {
|
||||
}
|
||||
|
||||
async getProjectsWithCounts(): Promise<IProjectWithCount[]> {
|
||||
return this.projects.map((project) => {
|
||||
return this.projects
|
||||
.filter((project) => project.archivedAt !== null)
|
||||
.map((project) => {
|
||||
return {
|
||||
...project,
|
||||
memberCount: 0,
|
||||
@ -60,12 +64,13 @@ export default class FakeProjectStore implements IProjectStore {
|
||||
}
|
||||
|
||||
private createInternal(project: IProjectInsert): IProject {
|
||||
const newProj: IProject = {
|
||||
const newProj: ArchivableProject = {
|
||||
...project,
|
||||
health: 100,
|
||||
createdAt: new Date(),
|
||||
mode: 'open',
|
||||
defaultStickiness: 'default',
|
||||
archivedAt: null,
|
||||
};
|
||||
this.projects.push(newProj);
|
||||
return newProj;
|
||||
@ -215,5 +220,11 @@ export default class FakeProjectStore implements IProjectStore {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
async archive(id: string): Promise<void> {}
|
||||
async archive(id: string): Promise<void> {
|
||||
this.projects = this.projects.map((project) =>
|
||||
project.id === id
|
||||
? { ...project, archivedAt: new Date() }
|
||||
: project,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user