From d2e053f456358dd32bccc204a25aa871b638d042 Mon Sep 17 00:00:00 2001 From: Simon Detheridge Date: Fri, 22 Mar 2019 12:21:00 +0000 Subject: [PATCH] Merge pull request #1610 from sharelatex/cmg-reintroduce-beta Revive the beta program in the settings area GitOrigin-RevId: 40024210cba08de96805d58147b6a0fe166a7d43 --- .../Features/Project/ProjectController.coffee | 2 +- services/web/app/coffee/router.coffee | 6 +-- .../web/app/views/beta_program/opt_in.pug | 2 - services/web/app/views/user/settings.pug | 25 +++++----- .../beta-users/set_rich_text_beta_users.js | 49 +++++++++++++++++++ 5 files changed, 64 insertions(+), 20 deletions(-) create mode 100644 services/web/scripts/beta-users/set_rich_text_beta_users.js diff --git a/services/web/app/coffee/Features/Project/ProjectController.coffee b/services/web/app/coffee/Features/Project/ProjectController.coffee index 712b2444f7..c7e2c00949 100644 --- a/services/web/app/coffee/Features/Project/ProjectController.coffee +++ b/services/web/app/coffee/Features/Project/ProjectController.coffee @@ -391,7 +391,7 @@ module.exports = ProjectController = editorThemes: THEME_LIST maxDocLength: Settings.max_doc_length useV2History: !!project.overleaf?.history?.display - richTextTrackChangesEnabled: req.query?.rttc == 'true' + richTextTrackChangesEnabled: req.query?.rttc == 'true' || user.betaProgram showTestControls: req.query?.tc == 'true' || user.isAdmin brandVariation: brandVariation allowedImageNames: Settings.allowedImageNames || [] diff --git a/services/web/app/coffee/router.coffee b/services/web/app/coffee/router.coffee index d365623bf2..5a98beb284 100644 --- a/services/web/app/coffee/router.coffee +++ b/services/web/app/coffee/router.coffee @@ -382,9 +382,9 @@ module.exports = class Router }), ReferencesController.indexAll # disable beta program while v2 is in beta - # webRouter.get "/beta/participate", AuthenticationController.requireLogin(), BetaProgramController.optInPage - # webRouter.post "/beta/opt-in", AuthenticationController.requireLogin(), BetaProgramController.optIn - # webRouter.post "/beta/opt-out", AuthenticationController.requireLogin(), BetaProgramController.optOut + webRouter.get "/beta/participate", AuthenticationController.requireLogin(), BetaProgramController.optInPage + webRouter.post "/beta/opt-in", AuthenticationController.requireLogin(), BetaProgramController.optIn + webRouter.post "/beta/opt-out", AuthenticationController.requireLogin(), BetaProgramController.optOut webRouter.get "/confirm-password", AuthenticationController.requireLogin(), SudoModeController.sudoModePrompt webRouter.post "/confirm-password", AuthenticationController.requireLogin(), diff --git a/services/web/app/views/beta_program/opt_in.pug b/services/web/app/views/beta_program/opt_in.pug index 7e6af48a00..778f16505d 100644 --- a/services/web/app/views/beta_program/opt_in.pug +++ b/services/web/app/views/beta_program/opt_in.pug @@ -17,8 +17,6 @@ block content p.text-centered | #{translate("beta_program_badge_description")} span.beta-feature-badge - p.text-centered - strong We're currently testing lower latency compilation features in beta. .row.text-centered .col-md-12 if user.betaProgram diff --git a/services/web/app/views/user/settings.pug b/services/web/app/views/user/settings.pug index 509666af6b..4ec4d042a3 100644 --- a/services/web/app/views/user/settings.pug +++ b/services/web/app/views/user/settings.pug @@ -144,20 +144,17 @@ block content ) #{translate("change")} | !{moduleIncludes("userSettings", locals)} - - //- The beta program doesn't make much sense to include while v2 is going - //- but we may want to add it back in later - //- hr - //- - //- h3 - //- | #{translate("sharelatex_beta_program")} - //- - //- if (user.betaProgram) - //- p.small - //- | #{translate("beta_program_already_participating")} - //- - //- div - //- a(id="beta-program-participate-link" href="/beta/participate") #{translate("manage_beta_program_membership")} + hr + + h3 + | #{translate("sharelatex_beta_program")} + + if (user.betaProgram) + p.small + | #{translate("beta_program_already_participating")} + + div + a(id="beta-program-participate-link" href="/beta/participate") #{translate("manage_beta_program_membership")} hr diff --git a/services/web/scripts/beta-users/set_rich_text_beta_users.js b/services/web/scripts/beta-users/set_rich_text_beta_users.js new file mode 100644 index 0000000000..1381d7d732 --- /dev/null +++ b/services/web/scripts/beta-users/set_rich_text_beta_users.js @@ -0,0 +1,49 @@ +const fs = require('fs') +const mongojs = require('../../app/js/infrastructure/mongojs') +const { db, ObjectId } = mongojs +const async = require('async') + +console.log('Finding users for ids specified') + +const text = fs.readFileSync(__dirname + '/beta-users.txt') +const textByLine = text + .toString() + .split('\n') + .map(function(stringId) { + return ObjectId(stringId) + }) + +db.users.find({ _id: { $in: textByLine } }, function(err, users) { + if (err) throw err + + if (users.length) { + console.log('Found ' + users.length + ' users') + + async.each( + users, + function(user, callback) { + console.log('setting betaProgram==true for: ' + user._id) + db.users.update( + { + _id: user._id + }, + { + $set: { + betaProgram: true + } + }, + callback + ) + }, + function(result, err) { + if (err) { + console.log(err) + } + process.exit(0) + } + ) + } else { + console.log('No users found matching those ids') + process.exit(0) + } +})