feat(core): Add description to projects (#15611)

This commit is contained in:
Daria
2025-06-12 13:57:23 +03:00
committed by GitHub
parent 46723d3518
commit 1ddbb78909
22 changed files with 235 additions and 35 deletions

View File

@@ -167,7 +167,7 @@ export class ProjectController {
_res: Response,
@Param('projectId') projectId: string,
): Promise<ProjectRequest.ProjectWithRelations> {
const [{ id, name, icon, type }, relations] = await Promise.all([
const [{ id, name, icon, type, description }, relations] = await Promise.all([
this.projectsService.getProject(projectId),
this.projectsService.getProjectRelations(projectId),
]);
@@ -178,6 +178,7 @@ export class ProjectController {
name,
icon,
type,
description,
relations: relations.map((r) => ({
id: r.user.id,
email: r.user.email,
@@ -202,9 +203,9 @@ export class ProjectController {
@Body payload: UpdateProjectDto,
@Param('projectId') projectId: string,
) {
const { name, icon, relations } = payload;
if (name || icon) {
await this.projectsService.updateProject(projectId, { name, icon });
const { name, icon, relations, description } = payload;
if ([name, icon, description].some((data) => typeof data === 'string')) {
await this.projectsService.updateProject(projectId, { name, icon, description });
}
if (relations) {
try {

View File

@@ -294,6 +294,7 @@ export declare namespace ProjectRequest {
name: string | undefined;
icon: ProjectIcon | null;
type: ProjectType;
description: string | null;
relations: ProjectRelationResponse[];
scopes: Scope[];
};

View File

@@ -242,10 +242,13 @@ export class ProjectService {
}
}
async updateProject(projectId: string, { name, icon }: UpdateProjectDto): Promise<void> {
async updateProject(
projectId: string,
{ name, icon, description }: UpdateProjectDto,
): Promise<void> {
const result = await this.projectRepository.update(
{ id: projectId, type: 'team' },
{ name, icon },
{ name, icon, description },
);
if (!result.affected) {
throw new ProjectNotFoundError(projectId);

View File

@@ -1063,6 +1063,7 @@ describe('Public API endpoints with feat:apiKeyScopes enabled', () => {
name: 'some-project',
icon: null,
type: 'team',
description: null,
id: expect.any(String),
createdAt: expect.any(String),
updatedAt: expect.any(String),

View File

@@ -143,6 +143,7 @@ describe('Projects in Public API', () => {
name: 'some-project',
icon: null,
type: 'team',
description: null,
id: expect.any(String),
createdAt: expect.any(String),
updatedAt: expect.any(String),