diff --git a/package.json b/package.json index 206b822..4e9735c 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "@jupyterlab/apputils": "^4.0.0", "@jupyterlab/mainmenu": "^4.0.0", "@jupyterlab/notebook": "^4.0.0", + "@jupyterlab/services": "^7.0.0", "@jupyterlab/settingregistry": "^4.0.0", "@jupyterlab/statedb": "^4.0.0", "@jupyterlab/translation": "^4.0.0", diff --git a/schema/user-tours.json b/schema/user-tours.json index 8bf8d2b..30c3f4b 100644 --- a/schema/user-tours.json +++ b/schema/user-tours.json @@ -46,6 +46,12 @@ "description": "Other options for the tour", "$ref": "#/definitions/Props" }, + "version": { + "type": "integer", + "title": "The tour version", + "description": "The tour version (prefer calendar versioning YYYYMMDD) to determine if an user should see it again or not.", + "minimum": 0 + }, "translation": { "description": "Translation domain containing strings for this tour", "type": "string" diff --git a/src/__tests__/plugin.spec.ts b/src/__tests__/plugin.spec.ts index bf38efc..9ba772c 100644 --- a/src/__tests__/plugin.spec.ts +++ b/src/__tests__/plugin.spec.ts @@ -6,7 +6,6 @@ import { NotebookPanel } from '@jupyterlab/notebook'; import { ISettingRegistry } from '@jupyterlab/settingregistry'; -import { StateDB } from '@jupyterlab/statedb'; import { CommandRegistry } from '@lumino/commands'; import { ReadonlyJSONObject } from '@lumino/coreutils'; import { DocumentRegistry } from '@jupyterlab/docregistry'; @@ -90,8 +89,7 @@ describe(corePlugin.id, () => { describe('activation', () => { it('should create add-tour command', () => { const app = mockApp(); - const stateDB = new StateDB(); - corePlugin.activate(app as any, stateDB); + corePlugin.activate(app as any); expect(app.commands?.hasCommand(CommandIDs.addTour)).toEqual(true); }); @@ -101,8 +99,7 @@ describe(corePlugin.id, () => { describe(`${CommandIDs.addTour}`, () => { it('should add a tour command', async () => { const app = mockApp(); - const stateDB = new StateDB(); - const manager = corePlugin.activate(app as any, stateDB) as ITourManager; + const manager = corePlugin.activate(app as any) as ITourManager; expect(manager.tours.size).toEqual(0); const tour = await app.commands?.execute(CommandIDs.addTour, { @@ -121,8 +118,7 @@ describe(userPlugin.id, () => { describe('activation', () => { it('should have userTours', async () => { const app = mockApp(); - const stateDB = new StateDB(); - const manager = corePlugin.activate(app as any, stateDB) as ITourManager; + const manager = corePlugin.activate(app as any) as ITourManager; const settings = mockSettingRegistry(); const userManager = userPlugin.activate( app as any, @@ -137,8 +133,7 @@ describe(userPlugin.id, () => { describe('settings', () => { it('should react to settings', async () => { const app = mockApp(); - const stateDB = new StateDB(); - const manager = corePlugin.activate(app as any, stateDB) as ITourManager; + const manager = corePlugin.activate(app as any) as ITourManager; const settingsRegistry = mockSettingRegistry(); const userManager = userPlugin.activate( app as any, @@ -158,8 +153,7 @@ describe(notebookPlugin.id, () => { describe('activation', () => { it('should activate', async () => { const app = mockApp(); - const stateDB = new StateDB(); - const manager = corePlugin.activate(app as any, stateDB) as ITourManager; + const manager = corePlugin.activate(app as any) as ITourManager; const nbTracker = mockNbTracker(); const notebookTourManager = notebookPlugin.activate( app as any, @@ -195,8 +189,7 @@ describe(defaultsPlugin.id, () => { describe('activation', () => { it('should activate', () => { const app = mockApp(); - const stateDB = new StateDB(); - const manager = corePlugin.activate(app as any, stateDB) as ITourManager; + const manager = corePlugin.activate(app as any) as ITourManager; defaultsPlugin.activate(app as any, manager); expect(manager.tours.size).toEqual(DEFAULT_TOURS_SIZE); }); diff --git a/src/defaults.tsx b/src/defaults.tsx index b758388..ead4fdb 100644 --- a/src/defaults.tsx +++ b/src/defaults.tsx @@ -23,13 +23,13 @@ namespace DefaultTours { ): void { const trans = manager.translator; - const welcomeTour = manager.createTour( - WELCOME_ID, - trans.__('Welcome Tour'), - true, - undefined, - defaultTourIcon - ); + const welcomeTour = manager.createTour({ + id: WELCOME_ID, + label: trans.__('Welcome Tour'), + hasHelpEntry: true, + icon: defaultTourIcon, + version: 20231107 + }); welcomeTour.options = { ...welcomeTour.options, @@ -292,13 +292,13 @@ namespace DefaultTours { appName = 'JupyterLab' ): void { const trans = manager.translator; - const notebookTour = manager.createTour( - NOTEBOOK_ID, - trans.__('Notebook Tour'), - true, - undefined, - defaultNotebookTourIcon - ); + const notebookTour = manager.createTour({ + id: NOTEBOOK_ID, + label: trans.__('Notebook Tour'), + hasHelpEntry: true, + icon: defaultNotebookTourIcon, + version: 20231107 + }); notebookTour.options = { ...notebookTour.options, @@ -541,11 +541,12 @@ namespace DefaultTours { ): void { const trans = manager.translator; - const welcomeTour = manager.createTour( - WELCOME_ID, - trans.__('Welcome Tour'), - true - ); + const welcomeTour = manager.createTour({ + id: WELCOME_ID, + label: trans.__('Welcome Tour'), + hasHelpEntry: true, + version: 20231107 + }); welcomeTour.options = { ...welcomeTour.options, diff --git a/src/notebookButton.tsx b/src/notebookButton.tsx index 9befd7c..4dce591 100644 --- a/src/notebookButton.tsx +++ b/src/notebookButton.tsx @@ -56,7 +56,7 @@ export class TourButton extends ReactWidget { title={title} value="" > - + {errors.length ? (