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

Personal Board Access fixed #642

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 6 additions & 2 deletions backend/src/api/boards.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Router } from 'express';
import { BoardModel, BoardScope } from '../models/Board';
import { BoardModel, BoardScope, ViewSettings } from '../models/Board';

Check warning on line 2 in backend/src/api/boards.ts

View workflow job for this annotation

GitHub Actions / Linting and Code Formating Check CI (backend)

'ViewSettings' is defined but never used
import { ProjectModel } from '../models/Project';
import { UserModel } from '../models/User';
import dalBoard from '../repository/dalBoard';
Expand Down Expand Up @@ -98,7 +98,11 @@
board.bgImage === undefined ? null : { bgImage: board.bgImage },
board.tags === undefined ? null : { tags: board.tags },
board.initialZoom === undefined ? null : { initialZoom: board.initialZoom },
board.upvoteLimit === undefined ? null : { upvoteLimit: board.upvoteLimit }
board.upvoteLimit === undefined ? null : { upvoteLimit: board.upvoteLimit },
board.defaultView === undefined ? null : { defaultView: board.defaultView },
board.viewSettings === undefined
? null
: { viewSettings: board.viewSettings }
);

await dalBoard.updateMany(boards, updatedBoard);
Expand Down
5 changes: 4 additions & 1 deletion backend/src/api/projects.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Router } from 'express';
import { mongo } from 'mongoose';
import { BoardScope } from '../models/Board';
import { BoardScope, ViewSettings, ViewType } from '../models/Board';

Check warning on line 3 in backend/src/api/projects.ts

View workflow job for this annotation

GitHub Actions / Linting and Code Formating Check CI (backend)

'ViewSettings' is defined but never used
import { ProjectModel } from '../models/Project';
import { UserModel } from '../models/User';
import dalBoard from '../repository/dalBoard';
import dalProject from '../repository/dalProject';
import {
getAllViewsAllowed,
getDefaultBoardPermissions,
getDefaultBoardTags,
} from '../utils/board.helpers';
Expand Down Expand Up @@ -41,6 +42,8 @@
initialZoom: 100,
upvoteLimit: 5,
visible: true,
defaultView: ViewType.CANVAS,
viewSettings: getAllViewsAllowed(),
});
savedProject = await savedProject.updateOne({ boards: [board.boardID] });
}
Expand Down
14 changes: 12 additions & 2 deletions backend/src/utils/board.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
STUDENT_POST_COLOR,
TEACHER_POST_COLOR,
} from '../constants';
import { PermissionsModel } from '../models/Board';
import { PermissionsModel, ViewSettings } from '../models/Board';
import Tag, { TagModel } from '../models/Tag';
import { Role } from '../models/User';
import dalPost from '../repository/dalPost';
Expand All @@ -21,7 +21,7 @@ export function getDefaultBoardPermissions(): PermissionsModel {
showAuthorNameStudent: true,
showAuthorNameTeacher: true,
showBucketStudent: true,
showSnackBarStudent: true,
showSnackBarStudent: false,
allowTracing: false,
};
}
Expand Down Expand Up @@ -51,3 +51,13 @@ export async function getDefaultPostColor(

return user.role == Role.STUDENT ? STUDENT_POST_COLOR : TEACHER_POST_COLOR;
}

export function getAllViewsAllowed(): ViewSettings {
console.log('all views allowed');
return {
allowBuckets: true,
allowCanvas: true,
allowMonitor: true,
allowWorkspace: true,
};
}
5 changes: 4 additions & 1 deletion backend/src/utils/project.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import {
UnauthorizedError,
} from '../errors/client.errors';
import { InternalServerError } from '../errors/server.errors';
import { BoardScope, BoardType } from '../models/Board';
import { BoardScope, BoardType, ViewType } from '../models/Board';
import Project, { ProjectModel } from '../models/Project';
import { Role, UserModel } from '../models/User';
import dalBoard from '../repository/dalBoard';
import dalLearnerModel from '../repository/dalLearnerModel';
import dalProject from '../repository/dalProject';
import dalUser from '../repository/dalUser';
import {
getAllViewsAllowed,
getDefaultBoardPermissions,
getDefaultBoardTags,
} from './board.helpers';
Expand Down Expand Up @@ -61,6 +62,8 @@ export async function addUserToProject(
initialZoom: 100,
upvoteLimit: 5,
visible: true,
defaultView: ViewType.CANVAS,
viewSettings: getAllViewsAllowed(),
});
updatedProject = await Project.findOneAndUpdate(
{ projectID: updatedProject.projectID },
Expand Down
Loading