Files
Verso/services/web/app/src/Features/Tutorial/TutorialController.mjs
T
Mathias Jakobsen a6ba9c1016 Merge pull request #31881 from overleaf/mj-ux-lite-editor-march-26
[web] Prepare re-run of UX lite survey

GitOrigin-RevId: e73249bd43dccfc6a40ee01d58bf01f6c6cf7f79
2026-03-06 09:10:51 +00:00

72 lines
1.9 KiB
JavaScript

import SessionManager from '../Authentication/SessionManager.mjs'
import TutorialHandler from './TutorialHandler.mjs'
import { expressify } from '@overleaf/promise-utils'
const VALID_KEYS = [
'react-history-buttons-tutorial',
'writefull-integration',
'writefull-oauth-promotion',
'bib-file-tpr-prompt',
'ai-error-assistant-consent',
'workbench-consent',
'workbench-consent-release',
'history-restore-promo',
'us-gov-banner',
'us-gov-banner-fedramp',
'editor-popup-ux-survey-03-2026',
'wf-features-moved',
'review-mode',
'new-error-logs-promo',
'try-redesign-again-nudge-promo',
'write-and-cite-nudge-in-linked-file',
'ide-redesign-new-survey-promo',
'ide-redesign-beta-intro',
'ide-redesign-labs-user-beta-promo',
'rolling-compile-image-changed',
'groups-enterprise-banner',
'groups-enterprise-banner-repeat',
'new-editor-opt-in',
'new-editor-intro',
'new-editor-intro-2',
'workbench-rail-popover',
'themed-dashboard-intro',
]
async function completeTutorial(req, res, next) {
const userId = SessionManager.getLoggedInUserId(req.session)
const tutorialKey = req.params.tutorialKey
if (!VALID_KEYS.includes(tutorialKey)) {
return res.sendStatus(404)
}
await TutorialHandler.setTutorialState(userId, tutorialKey, 'completed')
res.sendStatus(204)
}
async function postponeTutorial(req, res, next) {
const userId = SessionManager.getLoggedInUserId(req.session)
const tutorialKey = req.params.tutorialKey
let postponedUntil
if (req.body.postponedUntil) {
postponedUntil = new Date(req.body.postponedUntil)
}
if (!VALID_KEYS.includes(tutorialKey)) {
return res.sendStatus(404)
}
await TutorialHandler.setTutorialState(
userId,
tutorialKey,
'postponed',
postponedUntil
)
res.sendStatus(204)
}
export default {
completeTutorial: expressify(completeTutorial),
postponeTutorial: expressify(postponeTutorial),
}