Skip to content

Commit 039eab7

Browse files
committed
Add setting to hide notifications for the default tours
1 parent c3b438a commit 039eab7

File tree

2 files changed

+49
-19
lines changed

2 files changed

+49
-19
lines changed

schema/user-tours.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
},
1010
"type": "object",
1111
"properties": {
12+
"autoLaunchDefaultTours": {
13+
"type": "boolean",
14+
"title": "Auto-Launch Default Tours",
15+
"description": "Whether to automatically launch default tours (Welcome Tour, Notebook Tour) on first use. Tours can still be launched manually from the Help menu.",
16+
"default": true
17+
},
1218
"tours": {
1319
"type": "array",
1420
"description": "An array of a tours. Each requires an `id`, `label` and `steps[]`, and may have `options`, see https://docs.react-joyride.com",

src/plugin.tsx

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -222,38 +222,62 @@ const defaultsPlugin: JupyterFrontEndPlugin<void> = {
222222
autoStart: true,
223223
activate: activateDefaults,
224224
requires: [ITourManager],
225-
optional: [INotebookTracker]
225+
optional: [ISettingRegistry, INotebookTracker]
226226
};
227227

228228
function activateDefaults(
229229
app: JupyterFrontEnd,
230230
tourManager: ITourManager,
231+
settings?: ISettingRegistry | null,
231232
nbTracker?: INotebookTracker
232233
): void {
233234
addTours(tourManager, app, nbTracker);
234235

235-
if (
236-
nbTracker &&
237-
(app.name !== 'Jupyter Notebook' ||
238-
window.location.pathname.match(/\/notebooks\/.+$/))
239-
) {
240-
nbTracker.widgetAdded.connect(() => {
241-
if (tourManager.tours.has(NOTEBOOK_ID)) {
242-
tourManager.launch([NOTEBOOK_ID], false);
243-
}
244-
});
245-
}
246-
247-
Promise.all([app.restored, tourManager.ready]).then(() => {
236+
const setupTours = () => {
248237
if (
249-
tourManager.tours.has(WELCOME_ID) &&
238+
nbTracker &&
250239
(app.name !== 'Jupyter Notebook' ||
251-
window.location.pathname.match(/\/tree(\/.+)?$/))
240+
window.location.pathname.match(/\/notebooks\/.+$/))
252241
) {
253-
// Wait 3s before launching the first tour - to be sure element are loaded
254-
setTimeout(() => tourManager.launch([WELCOME_ID], false), 3000);
242+
nbTracker.widgetAdded.connect(() => {
243+
if (tourManager.tours.has(NOTEBOOK_ID)) {
244+
tourManager.launch([NOTEBOOK_ID], false);
245+
}
246+
});
255247
}
256-
});
248+
249+
Promise.all([app.restored, tourManager.ready]).then(() => {
250+
if (
251+
tourManager.tours.has(WELCOME_ID) &&
252+
(app.name !== 'Jupyter Notebook' ||
253+
window.location.pathname.match(/\/tree(\/.+)?$/))
254+
) {
255+
// Wait 3s before launching the first tour - to be sure element are loaded
256+
setTimeout(() => tourManager.launch([WELCOME_ID], false), 3000);
257+
}
258+
});
259+
};
260+
261+
// Load settings to check if auto-launch is enabled
262+
if (settings) {
263+
settings
264+
.load(USER_PLUGIN_ID)
265+
.then(userSettings => {
266+
const autoLaunch = userSettings.get('autoLaunchDefaultTours')
267+
.composite as boolean;
268+
269+
if (autoLaunch) {
270+
setupTours();
271+
}
272+
})
273+
.catch(() => {
274+
// If settings fail to load, default to showing tours
275+
setupTours();
276+
});
277+
} else {
278+
// If no settings registry, default to showing tours
279+
setupTours();
280+
}
257281
}
258282

259283
export default [corePlugin, userPlugin, notebookPlugin, defaultsPlugin];

0 commit comments

Comments
 (0)