Skip to content

Commit

Permalink
feat: return all project owners (including groups and system)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasheartman committed Oct 1, 2024
1 parent b14bbf5 commit 95f5635
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class PersonalDashboardService {
}));

const owners =
await this.projectOwnersReadModel.getUserProjectOwners(projectId);
await this.projectOwnersReadModel.getProjectOwners(projectId);

return {
latestEvents: formattedEvents,
Expand Down
3 changes: 2 additions & 1 deletion src/lib/features/project/fake-project-owners-read-model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {
IProjectOwnersReadModel,
ProjectOwners,
UserProjectOwner,
WithProjectOwners,
} from './project-owners-read-model.type';
Expand All @@ -18,7 +19,7 @@ export class FakeProjectOwnersReadModel implements IProjectOwnersReadModel {
return [];
}

async getUserProjectOwners(projectId: string): Promise<UserProjectOwner[]> {
async getUserProjectOwners(projectId: string): Promise<ProjectOwners> {
return [];
}
}
10 changes: 4 additions & 6 deletions src/lib/features/project/project-owners-read-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { generateImageUrl } from '../../util';
import type {
GroupProjectOwner,
IProjectOwnersReadModel,
ProjectOwners,
ProjectOwnersDictionary,
UserProjectOwner,
WithProjectOwners,
Expand Down Expand Up @@ -158,11 +159,8 @@ export class ProjectOwnersReadModel implements IProjectOwnersReadModel {
return ProjectOwnersReadModel.addOwnerData(projects, owners);
}

async getUserProjectOwners(projectId: string): Promise<UserProjectOwner[]> {
const ownerRole = await this.db(T.ROLES)
.where({ name: RoleName.OWNER })
.first();
const usersDict = await this.getAllProjectUsersByRole(ownerRole.id);
return usersDict[projectId] ?? [];
async getProjectOwners(projectId: string): Promise<ProjectOwners> {
const owners = await this.getProjectOwnersDictionary();
return owners[projectId] ?? [];
}
}
2 changes: 1 addition & 1 deletion src/lib/features/project/project-owners-read-model.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface IProjectOwnersReadModel {
projects: T[],
): Promise<WithProjectOwners<T>>;

getUserProjectOwners(projectId: string): Promise<UserProjectOwner[]>;
getProjectOwners(projectId: string): Promise<ProjectOwners>;

getAllUserProjectOwners(
projects?: Set<string>,
Expand Down

0 comments on commit 95f5635

Please sign in to comment.