(core) Replace questionnaire for new users with a popup asking for just their primary use-case.

Summary:
- WelcomeQuestions implements the new popup.
- Popup shows up on any doc-list page, the first time the user visits one after
  signing up and setting their name.
- Submits responses to the same "New User Questions" doc, which has been
  changed to accept two new columns (ChoiceList of use_cases, and Text for
  use_other).
- Improve modals on mobile along the way.

Test Plan: Added browser tests and tested manually

Reviewers: alexmojaki

Reviewed By: alexmojaki

Subscribers: jarek

Differential Revision: https://phab.getgrist.com/D3213
This commit is contained in:
Dmitry S
2022-01-13 21:55:55 -05:00
parent ba6ecc5e9e
commit 215bb90e68
19 changed files with 335 additions and 47 deletions

View File

@@ -1095,10 +1095,20 @@ export class FlexServer implements GristServer {
if (req.params.page === 'user') {
const name: string|undefined = req.body && req.body.username || undefined;
// Reset isFirstTimeUser flag, used to redirect a new user to the /welcome/user page.
await this._dbManager.updateUser(userId, {name, isFirstTimeUser: false});
redirectPath = '/welcome/info';
// This is a good time to set another flag (showNewUserQuestions), to show a popup with
// welcome question(s) to this new user. Both flags are scoped to the user, but
// isFirstTimeUser has a dedicated DB field because it predates userPrefs. Note that the
// updateOrg() method handles all levels of prefs (for user, user+org, or org).
await this._dbManager.updateOrg(getScope(req), 0, {userPrefs: {showNewUserQuestions: true}});
} else if (req.params.page === 'info') {
// The /welcome/info page is no longer part of any flow, but if visited, will still submit
// here and redirect. The new form with new-user questions appears in a modal popup. It
// also posts here to save answers, but ignores the response.
const user = getUser(req);
const row = {...req.body, UserID: userId, Name: user.name, Email: user.loginEmail};
this._recordNewUserInfo(row)
@@ -1106,14 +1116,14 @@ export class FlexServer implements GristServer {
// If we failed to record, at least log the data, so we could potentially recover it.
log.rawWarn(`Failed to record new user info: ${e.message}`, {newUserQuestions: row});
});
}
// redirect to teams page if users has access to more than one org. Otherwise redirect to
// personal org.
const result = await this._dbManager.getMergedOrgs(userId, userId, domain || null);
const orgs = (result.status === 200) ? result.data : null;
if (orgs && orgs.length > 1) {
redirectPath = '/welcome/teams';
}
// redirect to teams page if users has access to more than one org. Otherwise redirect to
// personal org.
const result = await this._dbManager.getMergedOrgs(userId, userId, domain || null);
const orgs = (result.status === 200) ? result.data : null;
if (orgs && orgs.length > 1) {
redirectPath = '/welcome/teams';
}
const mergedOrgDomain = this._dbManager.mergedOrgDomain();