Merge pull request #8556 from overleaf/em-tl-image-alpha-only

Show new TeX Live images to alpha users

GitOrigin-RevId: 4a4a96cc1a6661720fcc14dd1ffae275d19a004a
This commit is contained in:
Eric Mc Sween 2022-06-22 15:19:16 -04:00 committed by Copybot
parent a481c66a07
commit 318cf770a7
3 changed files with 8 additions and 9 deletions

View file

@ -961,8 +961,7 @@ const ProjectController = {
req,
projectId
)
const allowedImageNames =
ProjectHelper.getAllowedImagesForUser(sessionUser)
const allowedImageNames = ProjectHelper.getAllowedImagesForUser(user)
AuthorizationManager.getPrivilegeLevelForProject(
userId,

View file

@ -2,7 +2,6 @@ const { ObjectId } = require('mongodb')
const _ = require('lodash')
const { promisify } = require('util')
const Settings = require('@overleaf/settings')
const { hasAdminAccess } = require('../Helpers/AdminAuthorizationHelper')
const ENGINE_TO_COMPILER_MAP = {
latex_dvipdf: 'latex',
@ -164,11 +163,11 @@ function _addNumericSuffixToProjectName(name, allProjectNames, maxLength) {
return null
}
function getAllowedImagesForUser(sessionUser) {
function getAllowedImagesForUser(user) {
const images = Settings.allowedImageNames || []
if (hasAdminAccess(sessionUser)) {
if (user?.alphaProgram) {
return images
} else {
return images.filter(image => !image.adminOnly)
return images.filter(image => !image.alphaOnly)
}
}

View file

@ -19,6 +19,7 @@ describe('ProjectHelper', function () {
this.adminUser = {
_id: 'admin-user-id',
isAdmin: true,
alphaProgram: true,
}
this.Settings = {
@ -29,7 +30,7 @@ describe('ProjectHelper', function () {
{
imageName: 'texlive-full:2020.1',
imageDesc: 'TeX Live 2020',
adminOnly: true,
alphaOnly: true,
},
],
}
@ -267,7 +268,7 @@ describe('ProjectHelper', function () {
})
describe('getAllowedImagesForUser', function () {
it('filters out admin-only images when the user is anonymous', function () {
it('filters out alpha-only images when the user is anonymous', function () {
const images = this.ProjectHelper.getAllowedImagesForUser(null)
const imageNames = images.map(image => image.imageName)
expect(imageNames).to.deep.equal([
@ -276,7 +277,7 @@ describe('ProjectHelper', function () {
])
})
it('filters out admin-only images when the user is not admin', function () {
it('filters out alpha-only images when the user is not admin', function () {
const images = this.ProjectHelper.getAllowedImagesForUser(this.user)
const imageNames = images.map(image => image.imageName)
expect(imageNames).to.deep.equal([