mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-26 01:17:00 +02:00
feat: return project owners (#8312)
This PR is part 1 of returning project owners and your project roles for the personal dashboard single-project endpoint. It moves the responsibility of adding owners and roles to the project to the service from the controller and adds a new method to the project owners read model to take care of it. I'll add roles and tests in follow-up PRs.
This commit is contained in:
parent
7ac283aa50
commit
050e53e564
@ -17,17 +17,7 @@ import type {
|
||||
} from '../../types';
|
||||
import type { FeatureEventFormatter } from '../../addons/feature-event-formatter-md';
|
||||
import { generateImageUrl } from '../../util';
|
||||
import type { OnboardingStatus } from '../onboarding/onboarding-read-model-type';
|
||||
|
||||
type PersonalProjectDetails = {
|
||||
latestEvents: {
|
||||
summary: string;
|
||||
createdBy: string;
|
||||
id: number;
|
||||
createdByImageUrl: string;
|
||||
}[];
|
||||
onboardingStatus: OnboardingStatus;
|
||||
};
|
||||
import type { PersonalDashboardProjectDetailsSchema } from '../../openapi';
|
||||
|
||||
export class PersonalDashboardService {
|
||||
private personalDashboardReadModel: IPersonalDashboardReadModel;
|
||||
@ -106,7 +96,7 @@ export class PersonalDashboardService {
|
||||
|
||||
async getPersonalProjectDetails(
|
||||
projectId: string,
|
||||
): Promise<PersonalProjectDetails> {
|
||||
): Promise<PersonalDashboardProjectDetailsSchema> {
|
||||
const recentEvents = await this.eventStore.searchEvents(
|
||||
{ limit: 4, offset: 0 },
|
||||
[{ field: 'project', operator: 'IS', values: [projectId] }],
|
||||
@ -124,7 +114,15 @@ export class PersonalDashboardService {
|
||||
createdByImageUrl: generateImageUrl({ email: event.createdBy }),
|
||||
}));
|
||||
|
||||
return { latestEvents: formattedEvents, onboardingStatus };
|
||||
const owners =
|
||||
await this.projectOwnersReadModel.getProjectOwners(projectId);
|
||||
|
||||
return {
|
||||
latestEvents: formattedEvents,
|
||||
onboardingStatus,
|
||||
owners,
|
||||
roles: [],
|
||||
};
|
||||
}
|
||||
|
||||
async getAdmins(): Promise<MinimalUser[]> {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import type {
|
||||
IProjectOwnersReadModel,
|
||||
ProjectOwners,
|
||||
UserProjectOwner,
|
||||
WithProjectOwners,
|
||||
} from './project-owners-read-model.type';
|
||||
@ -17,4 +18,8 @@ export class FakeProjectOwnersReadModel implements IProjectOwnersReadModel {
|
||||
async getAllUserProjectOwners(): Promise<UserProjectOwner[]> {
|
||||
return [];
|
||||
}
|
||||
|
||||
async getProjectOwners(): Promise<ProjectOwners> {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import { generateImageUrl } from '../../util';
|
||||
import type {
|
||||
GroupProjectOwner,
|
||||
IProjectOwnersReadModel,
|
||||
ProjectOwners,
|
||||
ProjectOwnersDictionary,
|
||||
UserProjectOwner,
|
||||
WithProjectOwners,
|
||||
@ -157,4 +158,9 @@ export class ProjectOwnersReadModel implements IProjectOwnersReadModel {
|
||||
|
||||
return ProjectOwnersReadModel.addOwnerData(projects, owners);
|
||||
}
|
||||
|
||||
async getProjectOwners(projectId: string): Promise<ProjectOwners> {
|
||||
const owners = await this.getProjectOwnersDictionary();
|
||||
return owners[projectId] ?? [];
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ export interface IProjectOwnersReadModel {
|
||||
projects: T[],
|
||||
): Promise<WithProjectOwners<T>>;
|
||||
|
||||
getProjectOwners(projectId: string): Promise<ProjectOwners>;
|
||||
|
||||
getAllUserProjectOwners(
|
||||
projects?: Set<string>,
|
||||
): Promise<UserProjectOwner[]>;
|
||||
|
Loading…
Reference in New Issue
Block a user