Просмотр исходного кода

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

Show new TeX Live images to alpha users

GitOrigin-RevId: 4a4a96cc1a6661720fcc14dd1ffae275d19a004a
Eric Mc Sween 4 лет назад
Родитель
Сommit
318cf770a7

+ 1 - 2
services/web/app/src/Features/Project/ProjectController.js

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

+ 3 - 4
services/web/app/src/Features/Project/ProjectHelper.js

@@ -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)
   }
 }

+ 4 - 3
services/web/test/unit/src/Project/ProjectHelperTests.js

@@ -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([