-
-
Notifications
You must be signed in to change notification settings - Fork 728
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add project owners to personal dashboard project payload (#8248)
This PR adds project owner information to the personal dashboard's project payload. To do so, it uses the existing project owners read model. I've had to make a few changes to the project owners read model to accomodate this: - make the input type to `addOwners` more lenient. We only need the project ids, so we can make that the only required property - fall back to using email as the name if the user has no name or username (such as if you sign up with the demo auth)
- Loading branch information
1 parent
e680921
commit 44bf661
Showing
8 changed files
with
94 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,6 +110,11 @@ test('should return personal dashboard with membered projects', async () => { | |
type: 'root', | ||
}, | ||
], | ||
owners: [ | ||
{ | ||
ownerType: 'system', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: projectA.name, | ||
|
@@ -121,6 +126,15 @@ test('should return personal dashboard with membered projects', async () => { | |
type: 'project', | ||
}, | ||
], | ||
owners: [ | ||
{ | ||
email: '[email protected]', | ||
imageUrl: | ||
'https://gravatar.com/avatar/a8cc79d8407a64b0d8982df34e3525afd298a479fe68f300651380730dbf23e9?s=42&d=retro&r=g', | ||
name: '[email protected]', | ||
ownerType: 'user', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: projectC.name, | ||
|
@@ -132,6 +146,15 @@ test('should return personal dashboard with membered projects', async () => { | |
type: 'project', | ||
}, | ||
], | ||
owners: [ | ||
{ | ||
email: '[email protected]', | ||
imageUrl: | ||
'https://gravatar.com/avatar/706150f3ef810ea66acb30c6d55f1a7e545338747072609e47df71c7c7ccc6a4?s=42&d=retro&r=g', | ||
name: '[email protected]', | ||
ownerType: 'user', | ||
}, | ||
], | ||
}, | ||
], | ||
}); | ||
|
@@ -181,6 +204,11 @@ test('should return projects where users are part of a group', async () => { | |
type: 'root', | ||
}, | ||
], | ||
owners: [ | ||
{ | ||
ownerType: 'system', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: projectA.name, | ||
|
@@ -197,6 +225,19 @@ test('should return projects where users are part of a group', async () => { | |
type: 'project', | ||
}, | ||
], | ||
owners: [ | ||
{ | ||
email: '[email protected]', | ||
imageUrl: | ||
'https://gravatar.com/avatar/a8cc79d8407a64b0d8982df34e3525afd298a479fe68f300651380730dbf23e9?s=42&d=retro&r=g', | ||
name: '[email protected]', | ||
ownerType: 'user', | ||
}, | ||
{ | ||
name: 'groupA', | ||
ownerType: 'group', | ||
}, | ||
], | ||
}, | ||
], | ||
}); | ||
|
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
23 changes: 19 additions & 4 deletions
23
src/lib/features/personal-dashboard/personal-dashboard-service.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 |
---|---|---|
@@ -1,21 +1,36 @@ | ||
import type { IProjectOwnersReadModel } from '../project/project-owners-read-model.type'; | ||
import type { | ||
IPersonalDashboardReadModel, | ||
PersonalFeature, | ||
PersonalProject, | ||
PersonalProjectWithOwners, | ||
} from './personal-dashboard-read-model-type'; | ||
|
||
export class PersonalDashboardService { | ||
private personalDashboardReadModel: IPersonalDashboardReadModel; | ||
|
||
constructor(personalDashboardReadModel: IPersonalDashboardReadModel) { | ||
private projectOwnersReadModel: IProjectOwnersReadModel; | ||
|
||
constructor( | ||
personalDashboardReadModel: IPersonalDashboardReadModel, | ||
projectOwnersReadModel: IProjectOwnersReadModel, | ||
) { | ||
this.personalDashboardReadModel = personalDashboardReadModel; | ||
this.projectOwnersReadModel = projectOwnersReadModel; | ||
} | ||
|
||
getPersonalFeatures(userId: number): Promise<PersonalFeature[]> { | ||
return this.personalDashboardReadModel.getPersonalFeatures(userId); | ||
} | ||
|
||
getPersonalProjects(userId: number): Promise<PersonalProject[]> { | ||
return this.personalDashboardReadModel.getPersonalProjects(userId); | ||
async getPersonalProjects( | ||
userId: number, | ||
): Promise<PersonalProjectWithOwners[]> { | ||
const projects = | ||
await this.personalDashboardReadModel.getPersonalProjects(userId); | ||
|
||
const withOwners = | ||
await this.projectOwnersReadModel.addOwners(projects); | ||
|
||
return withOwners; | ||
} | ||
} |
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
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
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
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
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