mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
List projects where user is added as reviewer (#22347)
* Support for adding reviewer role * added collaboratorsGetter tests * emit toggle-track-changes when reviewer is added * List projects where user is added as reviewer GitOrigin-RevId: 8ec9e59e4c0b65167705b0a56be3e309ef6af3e7
This commit is contained in:
committed by
Copybot
parent
53dc5fbafe
commit
db9dba4b7a
@@ -224,9 +224,10 @@ async function getPublicShareTokens(userId, projectId) {
|
||||
// token access has been disabled.
|
||||
async function getProjectsUserIsMemberOf(userId, fields) {
|
||||
const limit = pLimit(2)
|
||||
const [readAndWrite, readOnly, tokenReadAndWrite, tokenReadOnly] =
|
||||
const [readAndWrite, review, readOnly, tokenReadAndWrite, tokenReadOnly] =
|
||||
await Promise.all([
|
||||
limit(() => Project.find({ collaberator_refs: userId }, fields).exec()),
|
||||
limit(() => Project.find({ reviewer_refs: userId }, fields).exec()),
|
||||
limit(() => Project.find({ readOnly_refs: userId }, fields).exec()),
|
||||
limit(() =>
|
||||
Project.find(
|
||||
@@ -247,7 +248,7 @@ async function getProjectsUserIsMemberOf(userId, fields) {
|
||||
).exec()
|
||||
),
|
||||
])
|
||||
return { readAndWrite, readOnly, tokenReadAndWrite, tokenReadOnly }
|
||||
return { readAndWrite, review, readOnly, tokenReadAndWrite, tokenReadOnly }
|
||||
}
|
||||
|
||||
// This function returns all the projects that a user is a member of, regardless of
|
||||
|
||||
@@ -904,8 +904,14 @@ const _ProjectController = {
|
||||
},
|
||||
_buildProjectList(allProjects, userId) {
|
||||
let project
|
||||
const { owned, readAndWrite, readOnly, tokenReadAndWrite, tokenReadOnly } =
|
||||
allProjects
|
||||
const {
|
||||
owned,
|
||||
review,
|
||||
readAndWrite,
|
||||
readOnly,
|
||||
tokenReadAndWrite,
|
||||
tokenReadOnly,
|
||||
} = allProjects
|
||||
const projects = []
|
||||
for (project of owned) {
|
||||
projects.push(
|
||||
@@ -928,6 +934,16 @@ const _ProjectController = {
|
||||
)
|
||||
)
|
||||
}
|
||||
for (project of review) {
|
||||
projects.push(
|
||||
ProjectController._buildProjectViewModel(
|
||||
project,
|
||||
'review',
|
||||
Sources.INVITE,
|
||||
userId
|
||||
)
|
||||
)
|
||||
}
|
||||
for (project of readOnly) {
|
||||
projects.push(
|
||||
ProjectController._buildProjectViewModel(
|
||||
|
||||
@@ -102,6 +102,7 @@ const ProjectGetter = {
|
||||
readOnly: projects.readOnly || [],
|
||||
tokenReadAndWrite: projects.tokenReadAndWrite || [],
|
||||
tokenReadOnly: projects.tokenReadOnly || [],
|
||||
review: projects.review || [],
|
||||
}
|
||||
|
||||
// Remove duplicate projects. The order of result values is determined by the order they occur.
|
||||
|
||||
@@ -540,8 +540,14 @@ async function _getProjects(
|
||||
* @private
|
||||
*/
|
||||
function _formatProjects(projects, userId) {
|
||||
const { owned, readAndWrite, readOnly, tokenReadAndWrite, tokenReadOnly } =
|
||||
projects
|
||||
const {
|
||||
owned,
|
||||
review,
|
||||
readAndWrite,
|
||||
readOnly,
|
||||
tokenReadAndWrite,
|
||||
tokenReadOnly,
|
||||
} = projects
|
||||
|
||||
const formattedProjects = /** @type {Project[]} **/ []
|
||||
for (const project of owned) {
|
||||
@@ -555,6 +561,11 @@ function _formatProjects(projects, userId) {
|
||||
_formatProjectInfo(project, 'readWrite', Sources.INVITE, userId)
|
||||
)
|
||||
}
|
||||
for (const project of review) {
|
||||
formattedProjects.push(
|
||||
_formatProjectInfo(project, 'review', Sources.INVITE, userId)
|
||||
)
|
||||
}
|
||||
for (const project of readOnly) {
|
||||
formattedProjects.push(
|
||||
_formatProjectInfo(project, 'readOnly', Sources.INVITE, userId)
|
||||
|
||||
Reference in New Issue
Block a user