Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC-5119-Prevent-creating-new-neXboards (Server) #4522

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { ApiTags } from '@nestjs/swagger';
import { RequestTimeout } from '@shared/common';
import { ICurrentUser, Authenticate, CurrentUser } from '@modules/authentication';
import { CopyApiResponse, CopyMapper } from '@modules/copy-helper';
import { CopyApiResponse, CopyElementType, CopyMapper } from '@modules/copy-helper';

Check failure on line 5 in apps/server/src/modules/learnroom/controller/rooms.controller.ts

View workflow job for this annotation

GitHub Actions / nest_lint

'CopyElementType' is defined but never used
Michaellinaresxk marked this conversation as resolved.
Show resolved Hide resolved
import { serverConfig } from '@modules/server/server.config';
import { RoomBoardResponseMapper } from '../mapper/room-board-response.mapper';
import { CourseCopyUC } from '../uc/course-copy.uc';
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remember to use prettier.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert formating changes on this file

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class BoardCopyService {
const references: BoardElement[] = this.extractReferences(elements);

let boardCopy: Board = new Board({ references, course: destinationCourse });

let status: CopyStatus = {
title: 'board',
type: CopyElementType.BOARD,
Expand Down Expand Up @@ -84,7 +85,6 @@ export class BoardCopyService {
if (element.target === undefined) {
return Promise.reject(new Error('Broken boardelement - not pointing to any target entity'));
}

if (element.boardElementType === BoardElementType.Task && isTask(element.target)) {
return this.copyTask(element.target, user, destinationCourse).then((status) => [pos, status]);
}
Expand Down
16 changes: 13 additions & 3 deletions apps/server/src/modules/learnroom/service/course-copy.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,25 @@
const existingNames = existingCourses.map((course: Course) => course.name);
const copyName = this.copyHelperService.deriveCopyName(newName || originalCourse.name, existingNames);

// copy course and board
// copy course and board

Check failure on line 46 in apps/server/src/modules/learnroom/service/course-copy.service.ts

View workflow job for this annotation

GitHub Actions / nest_lint

Delete `↹`
Michaellinaresxk marked this conversation as resolved.
Show resolved Hide resolved
const courseCopy = await this.copyCourseEntity({ user, originalCourse, copyName });
const boardStatus = await this.boardCopyService.copyBoard({ originalBoard, destinationCourse: courseCopy, user });
const filteredBoardStatus = this.filterOutNeXboardFromCopyStatus(boardStatus);

Check failure on line 49 in apps/server/src/modules/learnroom/service/course-copy.service.ts

View workflow job for this annotation

GitHub Actions / nest_lint

'filteredBoardStatus' is assigned a value but never used
Michaellinaresxk marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too should use the new feature flag condition...

const finishedCourseCopy = await this.finishCourseCopying(courseCopy);

const courseStatus = this.deriveCourseStatus(originalCourse, finishedCourseCopy, boardStatus);

return courseStatus;
}

private filterOutNeXboardFromCopyStatus(boardStatus: CopyStatus): CopyStatus {
if (boardStatus.elements) {
boardStatus.elements = boardStatus.elements.filter(elementStatus =>

Check failure on line 58 in apps/server/src/modules/learnroom/service/course-copy.service.ts

View workflow job for this annotation

GitHub Actions / nest_lint

Replace `elementStatus·=>⏎↹↹↹↹` with `⏎↹↹↹↹(elementStatus)·=>·`
elementStatus.type !== CopyElementType.LESSON_CONTENT_NEXBOARD
);
}
return boardStatus;
}

private async copyCourseEntity(params: CourseCopyParams): Promise<Course> {
const { originalCourse, user, copyName } = params;
const courseCopy = new Course({
Expand Down Expand Up @@ -100,7 +109,6 @@
if (courseGroupsExist) {
elements.push({ type: CopyElementType.COURSEGROUP_GROUP, status: CopyStatusEnum.NOT_IMPLEMENTED });
}

const status = {
title: courseCopy.name,
type: CopyElementType.COURSE,
Expand All @@ -110,5 +118,7 @@
elements,
};
return status;
}

Check failure on line 121 in apps/server/src/modules/learnroom/service/course-copy.service.ts

View workflow job for this annotation

GitHub Actions / nest_lint

Delete `⏎⏎`


}
Loading