-
-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow you to filter for "my projects" (#6855)
This change adds filtering functionality to the project list filter buttons. In this case, "my projects" is defined as any project that is marked as a favorite OR (inclusive or) that you are a part of, as defined by your user profile.
- Loading branch information
1 parent
9aee1a7
commit 3d60c2a
Showing
3 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
frontend/src/component/project/ProjectList/should-display-in-my-projects.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { IProjectCard } from 'interfaces/project'; | ||
import { shouldDisplayInMyProjects } from './should-display-in-my-projects'; | ||
|
||
test('should check that the project is a user project OR that it is a favorite', () => { | ||
const myProjects = new Set(['my1', 'my2', 'my3']); | ||
|
||
const projects: IProjectCard[] = [ | ||
{ id: 'my1', favorite: true }, | ||
{ id: 'my2', favorite: false }, | ||
{ id: 'my3' }, | ||
{ id: 'fave-but-not-mine', favorite: true }, | ||
{ id: 'not-mine-not-fave', favorite: false }, | ||
{ id: 'not-mine-undefined-fave' }, | ||
].map(({ id, favorite }) => ({ | ||
name: 'name', | ||
id, | ||
createdAt: '2024-04-15T11:09:52+02:00', | ||
health: 100, | ||
description: 'description', | ||
featureCount: 100, | ||
mode: 'open', | ||
memberCount: 10, | ||
favorite, | ||
})); | ||
|
||
const filtered = projects.filter(shouldDisplayInMyProjects(myProjects)); | ||
|
||
expect(filtered).toMatchObject([ | ||
{ id: 'my1' }, | ||
{ id: 'my2' }, | ||
{ id: 'my3' }, | ||
{ id: 'fave-but-not-mine' }, | ||
]); | ||
}); |
6 changes: 6 additions & 0 deletions
6
frontend/src/component/project/ProjectList/should-display-in-my-projects.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { IProjectCard } from 'interfaces/project'; | ||
|
||
export const shouldDisplayInMyProjects = | ||
(myProjectIds: Set<string>) => | ||
(project: IProjectCard): boolean => | ||
project.favorite || myProjectIds.has(project.id); |