mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-22 01:16:07 +02:00
feat: query archived projects (#7862)
This commit is contained in:
parent
8ce594ba52
commit
4738d4a61f
@ -47,6 +47,7 @@ export interface IProjectHealthUpdate {
|
||||
|
||||
export interface IProjectQuery {
|
||||
id?: string;
|
||||
archived?: boolean;
|
||||
}
|
||||
|
||||
export type ProjectEnvironment = {
|
||||
|
@ -133,7 +133,11 @@ class ProjectStore implements IProjectStore {
|
||||
.orderBy('projects.name', 'asc');
|
||||
|
||||
if (this.flagResolver.isEnabled('archiveProjects')) {
|
||||
projects = projects.where(`${TABLE}.archived_at`, null);
|
||||
if (query?.archived === true) {
|
||||
projects = projects.whereNot(`${TABLE}.archived_at`, null);
|
||||
} else {
|
||||
projects = projects.where(`${TABLE}.archived_at`, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (query) {
|
||||
|
11
src/test/fixtures/fake-project-store.ts
vendored
11
src/test/fixtures/fake-project-store.ts
vendored
@ -16,6 +16,7 @@ import type {
|
||||
IProjectApplicationsSearchParams,
|
||||
IProjectHealthUpdate,
|
||||
IProjectInsert,
|
||||
IProjectQuery,
|
||||
ProjectEnvironment,
|
||||
} from '../../lib/features/project/project-store-type';
|
||||
|
||||
@ -48,9 +49,15 @@ export default class FakeProjectStore implements IProjectStore {
|
||||
this.projectEnvironment.set(id, environments);
|
||||
}
|
||||
|
||||
async getProjectsWithCounts(): Promise<IProjectWithCount[]> {
|
||||
async getProjectsWithCounts(
|
||||
query?: IProjectQuery,
|
||||
): Promise<IProjectWithCount[]> {
|
||||
return this.projects
|
||||
.filter((project) => project.archivedAt === null)
|
||||
.filter((project) =>
|
||||
query?.archived
|
||||
? project.archivedAt !== null
|
||||
: project.archivedAt === null,
|
||||
)
|
||||
.map((project) => {
|
||||
return {
|
||||
...project,
|
||||
|
Loading…
Reference in New Issue
Block a user