diff --git a/app/client/components/BehavioralPromptsManager.ts b/app/client/components/BehavioralPromptsManager.ts index 6d1a2c4f..a48fa88e 100644 --- a/app/client/components/BehavioralPromptsManager.ts +++ b/app/client/components/BehavioralPromptsManager.ts @@ -35,6 +35,8 @@ interface QueuedTip { * Tips are shown in the order that they are attached. */ export class BehavioralPromptsManager extends Disposable { + private _isDisabled: boolean = false; + private readonly _prefs = getUserPrefObs(this._appModel.userPrefsObs, 'behavioralPrompts', { defaultValue: { dontShowTips: false, dismissedTips: [] } }) as Observable; @@ -67,8 +69,17 @@ export class BehavioralPromptsManager extends Disposable { return !this._prefs.get().dontShowTips; } + public enable() { + this._isDisabled = false; + } + + public disable() { + this._isDisabled = true; + } + private _queueTip(refElement: Element, prompt: BehavioralPrompt, options: AttachOptions) { if ( + this._isDisabled || // Don't show tips if surveying is disabled. // TODO: Move this into a dedicated variable - this is only a short-term fix for hiding // tips in grist-core. diff --git a/app/client/components/GristDoc.ts b/app/client/components/GristDoc.ts index 7f776317..03176482 100644 --- a/app/client/components/GristDoc.ts +++ b/app/client/components/GristDoc.ts @@ -332,6 +332,10 @@ export class GristDoc extends DisposableWithEvents { } })); + if (this.docModel.isTutorial()) { + this.behavioralPromptsManager.disable(); + } + let isStartingTourOrTutorial = false; this.autoDispose(subscribe(urlState().state, async (_use, state) => { // Only start a tour or tutorial when the full interface is showing, i.e. not when in diff --git a/test/nbrowser/DocTutorial.ts b/test/nbrowser/DocTutorial.ts index 4a0b46c4..d6ce6c71 100644 --- a/test/nbrowser/DocTutorial.ts +++ b/test/nbrowser/DocTutorial.ts @@ -53,7 +53,7 @@ describe('DocTutorial', function () { let forkUrl: string; before(async () => { - session = await gu.session().teamSite.user('user1').login(); + session = await gu.session().teamSite.user('user1').login({showTips: true}); }); afterEach(() => gu.checkForErrors()); @@ -124,6 +124,13 @@ describe('DocTutorial', function () { /GristDocTutorial/).isPresent()); }); + it('does not show behavioral tips', async function() { + await gu.openPage('Page 1'); + await gu.openAddWidgetToPage(); + assert.equal(await driver.find('.test-behavioral-prompt').isPresent(), false); + await gu.sendKeys(Key.ESCAPE); + }); + it('only allows users access to their own forks', async function() { const otherSession = await gu.session().teamSite.user('user2').login(); await driver.navigate().to(forkUrl);