[web] Add new admin tool for surveys (#8356)

* Setup survey module and admin page skeleton

* Replace survey staff access permission with admin-only

* Manage survey config with admin tool

* Display configurable survey in project list + add preview in admin

* Fix linting errors and unit tests

* Add acceptance tests for survey module

* Move survey-form to survey components

* Add configuration option for Recurly group subscription users on surveys

* Change survey pre-link text to a lighter gray for accessibility

* Cleanup survey options implementation after review

GitOrigin-RevId: 8f621951efeae458d1ab081fe98b8d0d539cca1a
This commit is contained in:
Alexandre Bourdin
2022-06-22 11:34:25 +02:00
committed by Copybot
parent 29cd233c29
commit f50fe3be14
14 changed files with 259 additions and 0 deletions

View File

@@ -42,6 +42,7 @@ const UserPrimaryEmailCheckHandler = require('../User/UserPrimaryEmailCheckHandl
const { hasAdminAccess } = require('../Helpers/AdminAuthorizationHelper')
const InstitutionsFeatures = require('../Institutions/InstitutionsFeatures')
const SubscriptionViewModelBuilder = require('../Subscription/SubscriptionViewModelBuilder')
const SurveyHandler = require('../Survey/SurveyHandler')
const _ssoAvailable = (affiliation, session, linkedInstitutionIds) => {
if (!affiliation.institution) return false
@@ -471,6 +472,17 @@ const ProjectController = {
}
)
},
survey(cb) {
SurveyHandler.getSurvey(userId, (err, survey) => {
if (err) {
logger.warn({ err }, 'failed to get survey')
// do not fail loading the project list if we fail to load the survey
cb(null, null)
} else {
cb(null, survey)
}
})
},
},
(err, results) => {
if (err != null) {
@@ -630,6 +642,7 @@ const ProjectController = {
metadata: { viewport: false },
showThinFooter: true, // don't show the fat footer on the projects dashboard, as there's a fixed space available
usersBestSubscription: results.usersBestSubscription,
survey: results.survey,
}
const paidUser =