From 5adad1a3b162c7bf9a9528661d171616c648be01 Mon Sep 17 00:00:00 2001 From: MFA-X-AI Date: Mon, 19 Aug 2024 16:37:45 +0900 Subject: [PATCH 1/4] add open tutorial help item --- package.json | 1 + src/commands/CommandIDs.tsx | 3 ++- src/index.tsx | 20 +++++++++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index de4ce6e7..fa82f452 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "@jupyterlab/fileeditor": "4.0.9", "@jupyterlab/launcher": "^4.0.9", "@jupyterlab/logconsole": "^4.0.9", + "@jupyterlab/mainmenu": "^4.0.9", "@jupyterlab/services": "^7.0.0", "@jupyterlab/settingregistry": "^4.0.0", "@projectstorm/geometry": "^7.0.2", diff --git a/src/commands/CommandIDs.tsx b/src/commands/CommandIDs.tsx index 66b54437..76cb0444 100644 --- a/src/commands/CommandIDs.tsx +++ b/src/commands/CommandIDs.tsx @@ -35,5 +35,6 @@ export const commandIDs = { executeToOutputPanel: "Xircuit-output-panel:execute", createNewComponentLibrary: "Xircuit-editor:new-component-library", refreshComponentList: "xircuits-sidebar:refresh-component-list", - toggleDisplayNodesInLibrary: "xircuits-sidebar:toggle-display-nodes-in-library" + toggleDisplayNodesInLibrary: "xircuits-sidebar:toggle-display-nodes-in-library", + helpOpenTutorials: "xircuits-help:open-tutorials" }; \ No newline at end of file diff --git a/src/index.tsx b/src/index.tsx index b8472479..9b12409e 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -31,6 +31,7 @@ import type { CommandRegistry } from "@lumino/commands/src"; import type { Signal } from "@lumino/signaling"; import { commandIDs } from "./commands/CommandIDs"; import { IEditorTracker } from '@jupyterlab/fileeditor'; +import { IMainMenu } from '@jupyterlab/mainmenu'; const FACTORY = 'Xircuits editor'; @@ -57,8 +58,9 @@ const xircuits: JupyterFrontEndPlugin = { ILayoutRestorer, IRenderMimeRegistry, IDocumentManager, + IMainMenu, ITranslator, - IEditorTracker + IEditorTracker, ], provides: IXircuitsDocTracker, activate: async ( @@ -68,6 +70,7 @@ const xircuits: JupyterFrontEndPlugin = { restorer: ILayoutRestorer, rendermime: IRenderMimeRegistry, docmanager: IDocumentManager, + mainMenu?: IMainMenu, translator?: ITranslator, editorTracker?: IEditorTracker, ) => { @@ -365,6 +368,21 @@ const xircuits: JupyterFrontEndPlugin = { selector: '.jp-DirListing-item[data-file-type="xircuits"]', }); + // Help Items + app.commands.addCommand(commandIDs.helpOpenTutorials, { + label: 'Tutorials', + icon: xircuitsIcon, + execute: () => { + window.open('https://xircuits.io/docs/category/tutorials'); + } + }); + + mainMenu.helpMenu.addItem({ + command: commandIDs.helpOpenTutorials, + args: { url: 'https://xircuits.io/docs/category/tutorials', + }, + }); + // Add a launcher item if the launcher is available. if (launcher) { launcher.add({ From 29c8f78f3be4fa69fcb630226ba43f4702093767 Mon Sep 17 00:00:00 2001 From: MFA-X-AI Date: Mon, 19 Aug 2024 23:02:19 +0900 Subject: [PATCH 2/4] refactor help resources as group --- src/commands/CommandIDs.tsx | 2 +- src/helpers/HelpResources.tsx | 48 +++++++++++++++++++++++++++++++++++ src/index.tsx | 18 +++---------- 3 files changed, 52 insertions(+), 16 deletions(-) create mode 100644 src/helpers/HelpResources.tsx diff --git a/src/commands/CommandIDs.tsx b/src/commands/CommandIDs.tsx index 76cb0444..dfdd500a 100644 --- a/src/commands/CommandIDs.tsx +++ b/src/commands/CommandIDs.tsx @@ -36,5 +36,5 @@ export const commandIDs = { createNewComponentLibrary: "Xircuit-editor:new-component-library", refreshComponentList: "xircuits-sidebar:refresh-component-list", toggleDisplayNodesInLibrary: "xircuits-sidebar:toggle-display-nodes-in-library", - helpOpenTutorials: "xircuits-help:open-tutorials" + helpOpenResource: "xircuits-help:open-resource" }; \ No newline at end of file diff --git a/src/helpers/HelpResources.tsx b/src/helpers/HelpResources.tsx new file mode 100644 index 00000000..24110cc3 --- /dev/null +++ b/src/helpers/HelpResources.tsx @@ -0,0 +1,48 @@ +import { JupyterFrontEnd } from '@jupyterlab/application'; +import { IMainMenu } from '@jupyterlab/mainmenu'; +import { ITranslator } from '@jupyterlab/translation'; +import { xircuitsIcon } from '../ui-components/icons'; +import { commandIDs } from '../commands/CommandIDs'; + +interface HelpResource { + text: string; + url: string; +} + +export function addHelpResources( + app: JupyterFrontEnd, + mainMenu: IMainMenu, + translator: ITranslator +): void { + const { commands } = app; + const trans = translator.load('xircuits'); + + const resources: HelpResource[] = [ + { + text: trans.__('Xircuits Tutorials'), + url: 'https://xircuits.io/docs/category/tutorials' + }, + { + text: trans.__('Xircuits Documentation'), + url: 'https://xircuits.io/docs' + }, + ]; + + const xircuitsHelpGroup = []; + + resources.forEach((resource, index) => { + const commandId = `${commandIDs.helpOpenResource}:${index}`; + commands.addCommand(commandId, { + label: resource.text, + icon: xircuitsIcon, + execute: () => { + window.open(resource.url); + } + }); + + xircuitsHelpGroup.push({ command: commandId }); + }); + + // Add the Xircuits help group to the beginning of the Help menu + mainMenu.helpMenu.addGroup(xircuitsHelpGroup, -1); +} \ No newline at end of file diff --git a/src/index.tsx b/src/index.tsx index 9b12409e..7a2fbc7c 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -27,6 +27,7 @@ import { Token } from '@lumino/coreutils'; import { DockLayout } from '@lumino/widgets'; import { xircuitsIcon, componentLibIcon, changeFavicon, xircuitsFaviconLink } from './ui-components/icons'; import { createInitXircuits } from './helpers/CanvasInitializer'; +import { addHelpResources } from './helpers/HelpResources'; import type { CommandRegistry } from "@lumino/commands/src"; import type { Signal } from "@lumino/signaling"; import { commandIDs } from "./commands/CommandIDs"; @@ -163,6 +164,8 @@ const xircuits: JupyterFrontEndPlugin = { // Additional commands for chat actions addLibraryActionCommands(app, tracker, translator, widgetFactory); + // Additional main menu options for help resources + addHelpResources(app, mainMenu, translator); // Commands to emit WidgetFactory signals const emitSignal = (signal: Signal) => (args: unknown) => signal.emit(args); @@ -368,21 +371,6 @@ const xircuits: JupyterFrontEndPlugin = { selector: '.jp-DirListing-item[data-file-type="xircuits"]', }); - // Help Items - app.commands.addCommand(commandIDs.helpOpenTutorials, { - label: 'Tutorials', - icon: xircuitsIcon, - execute: () => { - window.open('https://xircuits.io/docs/category/tutorials'); - } - }); - - mainMenu.helpMenu.addItem({ - command: commandIDs.helpOpenTutorials, - args: { url: 'https://xircuits.io/docs/category/tutorials', - }, - }); - // Add a launcher item if the launcher is available. if (launcher) { launcher.add({ From 07f4ab106465ced18e926cfd2f8d2c3bb3eb4312 Mon Sep 17 00:00:00 2001 From: MFA-X-AI Date: Wed, 21 Aug 2024 11:57:05 +0900 Subject: [PATCH 3/4] add yarn.lock, add How-Tos --- src/helpers/HelpResources.tsx | 10 +- yarn.lock | 202 ++++++++++++++++++++++++++++++++++ 2 files changed, 209 insertions(+), 3 deletions(-) diff --git a/src/helpers/HelpResources.tsx b/src/helpers/HelpResources.tsx index 24110cc3..73616cf4 100644 --- a/src/helpers/HelpResources.tsx +++ b/src/helpers/HelpResources.tsx @@ -19,12 +19,16 @@ export function addHelpResources( const resources: HelpResource[] = [ { - text: trans.__('Xircuits Tutorials'), + text: trans.__('Xircuits Documentation'), + url: 'https://xircuits.io/docs/main/' + }, + { + text: trans.__('Tutorials'), url: 'https://xircuits.io/docs/category/tutorials' }, { - text: trans.__('Xircuits Documentation'), - url: 'https://xircuits.io/docs' + text: trans.__('How-Tos'), + url: 'https://xircuits.io/docs/category/how-tos' }, ]; diff --git a/yarn.lock b/yarn.lock index 1020ee34..7f2ab054 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2530,6 +2530,35 @@ __metadata: languageName: node linkType: hard +"@jupyterlab/apputils@npm:^4.3.4": + version: 4.3.4 + resolution: "@jupyterlab/apputils@npm:4.3.4" + dependencies: + "@jupyterlab/coreutils": ^6.2.4 + "@jupyterlab/observables": ^5.2.4 + "@jupyterlab/rendermime-interfaces": ^3.10.4 + "@jupyterlab/services": ^7.2.4 + "@jupyterlab/settingregistry": ^4.2.4 + "@jupyterlab/statedb": ^4.2.4 + "@jupyterlab/statusbar": ^4.2.4 + "@jupyterlab/translation": ^4.2.4 + "@jupyterlab/ui-components": ^4.2.4 + "@lumino/algorithm": ^2.0.1 + "@lumino/commands": ^2.3.0 + "@lumino/coreutils": ^2.1.2 + "@lumino/disposable": ^2.1.2 + "@lumino/domutils": ^2.0.1 + "@lumino/messaging": ^2.0.1 + "@lumino/signaling": ^2.1.2 + "@lumino/virtualdom": ^2.0.1 + "@lumino/widgets": ^2.3.2 + "@types/react": ^18.0.26 + react: ^18.2.0 + sanitize-html: ~2.12.1 + checksum: 403e1090506d36eac46191147e832b8897c8daf5981104a085ed654338c9fbb44594d7b63fde219ba22fb94c8070c8cf5fca50a78f0728aafb4a4e2e795eb719 + languageName: node + linkType: hard + "@jupyterlab/attachments@npm:^4.1.0": version: 4.1.0 resolution: "@jupyterlab/attachments@npm:4.1.0" @@ -2781,6 +2810,20 @@ __metadata: languageName: node linkType: hard +"@jupyterlab/coreutils@npm:^6.2.4": + version: 6.2.4 + resolution: "@jupyterlab/coreutils@npm:6.2.4" + dependencies: + "@lumino/coreutils": ^2.1.2 + "@lumino/disposable": ^2.1.2 + "@lumino/signaling": ^2.1.2 + minimist: ~1.2.0 + path-browserify: ^1.0.0 + url-parse: ~1.5.4 + checksum: 4ce2c660dea8a174e805b00cdecfa0b00fd7500cd07f5fbb62c69b48722728162baf90dc9c86c8e72044052d9c0217a53d12a7a5ebdbe9714865d18b8e66593f + languageName: node + linkType: hard + "@jupyterlab/docmanager@npm:^4.1.0": version: 4.1.0 resolution: "@jupyterlab/docmanager@npm:4.1.0" @@ -3030,6 +3073,21 @@ __metadata: languageName: node linkType: hard +"@jupyterlab/mainmenu@npm:^4.0.9": + version: 4.2.4 + resolution: "@jupyterlab/mainmenu@npm:4.2.4" + dependencies: + "@jupyterlab/apputils": ^4.3.4 + "@jupyterlab/translation": ^4.2.4 + "@jupyterlab/ui-components": ^4.2.4 + "@lumino/algorithm": ^2.0.1 + "@lumino/commands": ^2.3.0 + "@lumino/coreutils": ^2.1.2 + "@lumino/widgets": ^2.3.2 + checksum: 1142080fa199eb737b1057d7287979f387273b5338869e46f8cc4187098512db83c2644db438a42899d737f842e0b3dde6861b709e9b55ebfaac28bedfa5ab22 + languageName: node + linkType: hard + "@jupyterlab/nbformat@npm:^3.0.0 || ^4.0.0-alpha.21 || ^4.0.0, @jupyterlab/nbformat@npm:^4.1.0": version: 4.1.0 resolution: "@jupyterlab/nbformat@npm:4.1.0" @@ -3048,6 +3106,15 @@ __metadata: languageName: node linkType: hard +"@jupyterlab/nbformat@npm:^4.2.4": + version: 4.2.4 + resolution: "@jupyterlab/nbformat@npm:4.2.4" + dependencies: + "@lumino/coreutils": ^2.1.2 + checksum: 61ac75dbaa32ef196eb9e177529ba259c6b0648601646b52ec8a1b25dbca4fce8c6d78090b47fd0674bf993f883fa62223dc52e50a59f1b2c843a9d5c8d02ef4 + languageName: node + linkType: hard + "@jupyterlab/notebook@npm:^4.1.0": version: 4.1.0 resolution: "@jupyterlab/notebook@npm:4.1.0" @@ -3111,6 +3178,19 @@ __metadata: languageName: node linkType: hard +"@jupyterlab/observables@npm:^5.2.4": + version: 5.2.4 + resolution: "@jupyterlab/observables@npm:5.2.4" + dependencies: + "@lumino/algorithm": ^2.0.1 + "@lumino/coreutils": ^2.1.2 + "@lumino/disposable": ^2.1.2 + "@lumino/messaging": ^2.0.1 + "@lumino/signaling": ^2.1.2 + checksum: 48af3aadfafa8707643678f127d6c9e4e9a2b9ad009cfdbf9de5df7212bfbbb213ab786b05364d647477416a790580b4fd9aa8ade817fd9108df23a815741b05 + languageName: node + linkType: hard + "@jupyterlab/outputarea@npm:^4.1.0": version: 4.1.0 resolution: "@jupyterlab/outputarea@npm:4.1.0" @@ -3143,6 +3223,16 @@ __metadata: languageName: node linkType: hard +"@jupyterlab/rendermime-interfaces@npm:^3.10.4": + version: 3.10.4 + resolution: "@jupyterlab/rendermime-interfaces@npm:3.10.4" + dependencies: + "@lumino/coreutils": ^1.11.0 || ^2.1.2 + "@lumino/widgets": ^1.37.2 || ^2.3.2 + checksum: 9671389dc1714a1c12e1c5a7b7b28388f75e28a53a05721f26035a731578a36ab88c3805dd7425a74857142100ac1b6ec3edf2bd131430a3bac0a9b23ab1fccd + languageName: node + linkType: hard + "@jupyterlab/rendermime-interfaces@npm:^3.9.0": version: 3.9.0 resolution: "@jupyterlab/rendermime-interfaces@npm:3.9.0" @@ -3231,6 +3321,25 @@ __metadata: languageName: node linkType: hard +"@jupyterlab/services@npm:^7.2.4": + version: 7.2.4 + resolution: "@jupyterlab/services@npm:7.2.4" + dependencies: + "@jupyter/ydoc": ^2.0.1 + "@jupyterlab/coreutils": ^6.2.4 + "@jupyterlab/nbformat": ^4.2.4 + "@jupyterlab/settingregistry": ^4.2.4 + "@jupyterlab/statedb": ^4.2.4 + "@lumino/coreutils": ^2.1.2 + "@lumino/disposable": ^2.1.2 + "@lumino/polling": ^2.1.2 + "@lumino/properties": ^2.0.1 + "@lumino/signaling": ^2.1.2 + ws: ^8.11.0 + checksum: 7262d6ac6bc8a41e03ec45c7d4dd8e8eb2547dff315a9be9c81cff0e5f4f9e3fb12fd3d008cb4132efced9800023470fb5fef5f446307903b8cdee8c1ca96d34 + languageName: node + linkType: hard + "@jupyterlab/settingregistry@npm:^4.0.0, @jupyterlab/settingregistry@npm:^4.1.0": version: 4.1.0 resolution: "@jupyterlab/settingregistry@npm:4.1.0" @@ -3269,6 +3378,25 @@ __metadata: languageName: node linkType: hard +"@jupyterlab/settingregistry@npm:^4.2.4": + version: 4.2.4 + resolution: "@jupyterlab/settingregistry@npm:4.2.4" + dependencies: + "@jupyterlab/nbformat": ^4.2.4 + "@jupyterlab/statedb": ^4.2.4 + "@lumino/commands": ^2.3.0 + "@lumino/coreutils": ^2.1.2 + "@lumino/disposable": ^2.1.2 + "@lumino/signaling": ^2.1.2 + "@rjsf/utils": ^5.13.4 + ajv: ^8.12.0 + json5: ^2.2.3 + peerDependencies: + react: ">=16" + checksum: c4d1bfef80811697c0979f76b3a0c1f6597d6f07fd227004fd7f1237abc20ac6dda4cfffcb487166625e3c72ffa5c9e25e0a865c86217e9280207362b8864247 + languageName: node + linkType: hard + "@jupyterlab/statedb@npm:^4.1.0": version: 4.1.0 resolution: "@jupyterlab/statedb@npm:4.1.0" @@ -3295,6 +3423,19 @@ __metadata: languageName: node linkType: hard +"@jupyterlab/statedb@npm:^4.2.4": + version: 4.2.4 + resolution: "@jupyterlab/statedb@npm:4.2.4" + dependencies: + "@lumino/commands": ^2.3.0 + "@lumino/coreutils": ^2.1.2 + "@lumino/disposable": ^2.1.2 + "@lumino/properties": ^2.0.1 + "@lumino/signaling": ^2.1.2 + checksum: 63d2eeab1e4f45593b417f7aa4bbff5a78703858d2c49497632f37d262acca37e4600766dcd3d744de4048ba8e6726dcbe44718453a1d43eb088380f48e70609 + languageName: node + linkType: hard + "@jupyterlab/statusbar@npm:^4.0.9, @jupyterlab/statusbar@npm:^4.2.3": version: 4.2.3 resolution: "@jupyterlab/statusbar@npm:4.2.3" @@ -3327,6 +3468,22 @@ __metadata: languageName: node linkType: hard +"@jupyterlab/statusbar@npm:^4.2.4": + version: 4.2.4 + resolution: "@jupyterlab/statusbar@npm:4.2.4" + dependencies: + "@jupyterlab/ui-components": ^4.2.4 + "@lumino/algorithm": ^2.0.1 + "@lumino/coreutils": ^2.1.2 + "@lumino/disposable": ^2.1.2 + "@lumino/messaging": ^2.0.1 + "@lumino/signaling": ^2.1.2 + "@lumino/widgets": ^2.3.2 + react: ^18.2.0 + checksum: 0c7a79473bfe2cfafcd20f3f3ffe5de4192edcf3bcd0a2cb2ac1e1c9aaf49be31d5f70da0c8301d1d347d87400100a570f00a914367150948eb914dbf480d787 + languageName: node + linkType: hard + "@jupyterlab/testing@npm:^4.1.0": version: 4.1.0 resolution: "@jupyterlab/testing@npm:4.1.0" @@ -3435,6 +3592,19 @@ __metadata: languageName: node linkType: hard +"@jupyterlab/translation@npm:^4.2.4": + version: 4.2.4 + resolution: "@jupyterlab/translation@npm:4.2.4" + dependencies: + "@jupyterlab/coreutils": ^6.2.4 + "@jupyterlab/rendermime-interfaces": ^3.10.4 + "@jupyterlab/services": ^7.2.4 + "@jupyterlab/statedb": ^4.2.4 + "@lumino/coreutils": ^2.1.2 + checksum: 9551517b95431dd74e68b1cde2931eb4a4a1edfd21562f8c658ea75c4d3e7c66ecc232e441c8e903639517c3495d2fd367c61418266823491c8e665f5880df1a + languageName: node + linkType: hard + "@jupyterlab/ui-components@npm:^4.0.9, @jupyterlab/ui-components@npm:^4.2.3": version: 4.2.3 resolution: "@jupyterlab/ui-components@npm:4.2.3" @@ -3497,6 +3667,37 @@ __metadata: languageName: node linkType: hard +"@jupyterlab/ui-components@npm:^4.2.4": + version: 4.2.4 + resolution: "@jupyterlab/ui-components@npm:4.2.4" + dependencies: + "@jupyter/react-components": ^0.15.3 + "@jupyter/web-components": ^0.15.3 + "@jupyterlab/coreutils": ^6.2.4 + "@jupyterlab/observables": ^5.2.4 + "@jupyterlab/rendermime-interfaces": ^3.10.4 + "@jupyterlab/translation": ^4.2.4 + "@lumino/algorithm": ^2.0.1 + "@lumino/commands": ^2.3.0 + "@lumino/coreutils": ^2.1.2 + "@lumino/disposable": ^2.1.2 + "@lumino/messaging": ^2.0.1 + "@lumino/polling": ^2.1.2 + "@lumino/properties": ^2.0.1 + "@lumino/signaling": ^2.1.2 + "@lumino/virtualdom": ^2.0.1 + "@lumino/widgets": ^2.3.2 + "@rjsf/core": ^5.13.4 + "@rjsf/utils": ^5.13.4 + react: ^18.2.0 + react-dom: ^18.2.0 + typestyle: ^2.0.4 + peerDependencies: + react: ^18.2.0 + checksum: 79282488905776378976516fee64df86be06fdfd838f702048cccc90870ea6b0ac972f24f305416e48deb15470594f31a9b1245ad6b5a6141643397fb94644af + languageName: node + linkType: hard + "@lezer/common@npm:^1.0.0, @lezer/common@npm:^1.0.2, @lezer/common@npm:^1.1.0, @lezer/common@npm:^1.2.0, @lezer/common@npm:^1.2.1": version: 1.2.1 resolution: "@lezer/common@npm:1.2.1" @@ -11648,6 +11849,7 @@ __metadata: "@jupyterlab/fileeditor": 4.0.9 "@jupyterlab/launcher": ^4.0.9 "@jupyterlab/logconsole": ^4.0.9 + "@jupyterlab/mainmenu": ^4.0.9 "@jupyterlab/services": ^7.0.0 "@jupyterlab/settingregistry": ^4.0.0 "@jupyterlab/testutils": ^4.0.0 From 0239b7569703f81fd7bb557d485ea33a7b0d9929 Mon Sep 17 00:00:00 2001 From: MFA-X-AI Date: Wed, 21 Aug 2024 19:35:04 +0900 Subject: [PATCH 4/4] update xircuits help strings --- src/helpers/HelpResources.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/helpers/HelpResources.tsx b/src/helpers/HelpResources.tsx index 73616cf4..fe61643c 100644 --- a/src/helpers/HelpResources.tsx +++ b/src/helpers/HelpResources.tsx @@ -19,16 +19,16 @@ export function addHelpResources( const resources: HelpResource[] = [ { - text: trans.__('Xircuits Documentation'), - url: 'https://xircuits.io/docs/main/' + text: trans.__('Xircuits Tutorials'), + url: 'https://xircuits.io/docs/category/tutorials' }, { - text: trans.__('Tutorials'), - url: 'https://xircuits.io/docs/category/tutorials' + text: trans.__('Xircuits Concepts'), + url: 'https://xircuits.io/docs/category/explanations' }, { - text: trans.__('How-Tos'), - url: 'https://xircuits.io/docs/category/how-tos' + text: trans.__('More Xircuits Documentation'), + url: 'https://xircuits.io/docs/main/' }, ];