(core) Allow creating custom document tours with a special table

Summary:
Like the welcome tour, a special URL hash triggers startDocTour which uses data from a table GristDocTour to construct the appropriate popups.

This is the basic version described in https://grist.quip.com/sN2RAHI2dchm/Document-tours

Test Plan:
Added a new nbrowser test which tests the data produced by makeDocTour. The general behaviour of the UI and popups has hardly changed so existing tests cover that well enough.

The new test uses a new fixture document which you can open to easily experience the tour.

Error cases where there's no valid document tour are not tested because that behaviour is likely to change significantly and this feature is still quite 'private'.

Reviewers: georgegevoian

Reviewed By: georgegevoian

Subscribers: jarek, dsagal

Differential Revision: https://phab.getgrist.com/D2938
This commit is contained in:
Alex Hall
2021-07-23 18:24:17 +02:00
parent 04e5d90f86
commit 15f1ef96fa
6 changed files with 145 additions and 40 deletions

View File

@@ -35,6 +35,7 @@ import {showDocSettingsModal} from 'app/client/ui/DocumentSettings';
import {IPageWidget, toPageWidget} from 'app/client/ui/PageWidgetPicker';
import {IPageWidgetLink, linkFromId, selectBy} from 'app/client/ui/selectBy';
import {startWelcomeTour} from 'app/client/ui/welcomeTour';
import {startDocTour} from "app/client/ui/DocTour";
import {mediaSmall, testId} from 'app/client/ui2018/cssVars';
import {IconName} from 'app/client/ui2018/IconList';
import {ActionGroup} from 'app/common/ActionGroup';
@@ -196,7 +197,7 @@ export class GristDoc extends DisposableWithEvents {
// Start welcome tour if flag is present in the url hash.
this.autoDispose(subscribe(urlState().state, async (_use, state) => {
if (state.welcomeTour) {
if (state.welcomeTour || state.docTour) {
await this._waitForView();
await delay(0); // we need to wait an extra bit.
// TODO:
@@ -207,7 +208,11 @@ export class GristDoc extends DisposableWithEvents {
// of the messages relates to that part of the UI.
// 3) On boarding tours were not designed with mobile support in mind. So probably a
// good idea to disable.
startWelcomeTour(() => null);
if (state.welcomeTour) {
startWelcomeTour(() => null);
} else {
await startDocTour(this.docData, () => null);
}
}
}));