Skip to content

Commit

Permalink
N21-1833 load media board (#4897)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinOehlerkingCap authored Apr 8, 2024
1 parent 5decd66 commit 0779c6f
Show file tree
Hide file tree
Showing 106 changed files with 4,330 additions and 95 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { ObjectId } from '@mikro-orm/mongodb';
import { Test, TestingModule } from '@nestjs/testing';
import { BoardDoAuthorizable, BoardRoles } from '@shared/domain/domainobject';
import { Permission } from '@shared/domain/interface';
import {
columnBoardFactory,
drawingElementFactory,
Expand All @@ -8,11 +11,8 @@ import {
submissionItemFactory,
userFactory,
} from '@shared/testing';
import { ObjectId } from '@mikro-orm/mongodb';
import { BoardDoAuthorizable, BoardRoles } from '@shared/domain/domainobject';
import { Permission } from '@shared/domain/interface';
import { Action } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';
import { Action } from '../type';
import { BoardDoRule } from './board-do.rule';

describe(BoardDoRule.name, () => {
Expand Down Expand Up @@ -62,7 +62,7 @@ describe(BoardDoRule.name, () => {

it('should return false', () => {
const { user } = setup();
// @ts-expect-error test wrong entity

const result = service.isApplicable(user, user);

expect(result).toStrictEqual(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import { Injectable } from '@nestjs/common';
import { BoardDoAuthorizable, BoardRoles, UserWithBoardRoles } from '@shared/domain/domainobject/board/types';
import { User } from '@shared/domain/entity/user.entity';
import {
ColumnBoard,
isDrawingElement,
isSubmissionItem,
isSubmissionItemContent,
SubmissionItem,
} from '@shared/domain/domainobject';
import { EntityId } from '@shared/domain/types';
import { BoardDoAuthorizable, BoardRoles, UserWithBoardRoles } from '@shared/domain/domainobject/board/types';
import { User } from '@shared/domain/entity/user.entity';
import { Permission } from '@shared/domain/interface';
import { Action, AuthorizationContext, Rule } from '../type';
import { EntityId } from '@shared/domain/types';
import { AuthorizationHelper } from '../service/authorization.helper';
import { Action, AuthorizationContext, Rule } from '../type';

@Injectable()
export class BoardDoRule implements Rule {
constructor(private readonly authorizationHelper: AuthorizationHelper) {}

public isApplicable(user: User, boardDoAuthorizable: BoardDoAuthorizable): boolean {
public isApplicable(user: User, boardDoAuthorizable: unknown): boolean {
const isMatched = boardDoAuthorizable instanceof BoardDoAuthorizable;

return isMatched;
Expand All @@ -33,7 +34,11 @@ export class BoardDoRule implements Rule {
return false;
}

if (boardDoAuthorizable.rootDo.isVisible !== true && !this.isBoardEditor(userWithBoardRoles)) {
if (
boardDoAuthorizable.rootDo instanceof ColumnBoard &&
!boardDoAuthorizable.rootDo.isVisible &&
!this.isBoardEditor(userWithBoardRoles)
) {
return false;
}

Expand Down
13 changes: 13 additions & 0 deletions apps/server/src/modules/board/board.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ToolConfigModule } from '@modules/tool/tool-config.module';
import { UserModule } from '@modules/user';
import { HttpModule } from '@nestjs/axios';
import { Module } from '@nestjs/common';
import { CqrsModule } from '@nestjs/cqrs';
import { ContentElementFactory } from '@shared/domain/domainobject';
import { CourseRepo } from '@shared/repo';
import { LoggerModule } from '@src/core/logger';
Expand All @@ -18,7 +19,11 @@ import {
ColumnBoardService,
ColumnService,
ContentElementService,
MediaBoardService,
MediaElementService,
MediaLineService,
SubmissionItemService,
UserDeletedEventHandlerService,
} from './service';
import { BoardDoCopyService, SchoolSpecificFileCopyServiceFactory } from './service/board-do-copy-service';
import { ColumnBoardCopyService } from './service/column-board-copy.service';
Expand All @@ -34,6 +39,7 @@ import { ColumnBoardCopyService } from './service/column-board-copy.service';
HttpModule,
ToolConfigModule,
TldrawClientModule,
CqrsModule,
],
providers: [
BoardDoAuthorizableService,
Expand All @@ -51,6 +57,10 @@ import { ColumnBoardCopyService } from './service/column-board-copy.service';
BoardDoCopyService,
ColumnBoardCopyService,
SchoolSpecificFileCopyServiceFactory,
MediaBoardService,
MediaLineService,
MediaElementService,
UserDeletedEventHandlerService,
],
exports: [
BoardDoAuthorizableService,
Expand All @@ -64,6 +74,9 @@ import { ColumnBoardCopyService } from './service/column-board-copy.service';
* @deprecated - exported only deprecated learnraum module
*/
BoardNodeRepo,
MediaBoardService,
MediaLineService,
MediaElementService,
],
})
export class BoardModule {}
1 change: 1 addition & 0 deletions apps/server/src/modules/board/controller/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './board.controller';
export * from './card.controller';
export * from './column.controller';
export * from './element.controller';
export * from './media-board';
Loading

0 comments on commit 0779c6f

Please sign in to comment.