@jupyter-notebook/lab-extension 7.0.0-alpha.15 → 7.0.0-alpha.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +16 -19
  2. package/package.json +13 -12
package/lib/index.js CHANGED
@@ -1,12 +1,13 @@
1
1
  // Copyright (c) Jupyter Development Team.
2
2
  // Distributed under the terms of the Modified BSD License.
3
- import { ILabShell } from '@jupyterlab/application';
3
+ import { ILabShell, } from '@jupyterlab/application';
4
4
  import { ICommandPalette, IToolbarWidgetRegistry } from '@jupyterlab/apputils';
5
5
  import { PageConfig } from '@jupyterlab/coreutils';
6
6
  import { INotebookTracker } from '@jupyterlab/notebook';
7
7
  import { ITranslator } from '@jupyterlab/translation';
8
8
  import { Menu, MenuBar } from '@lumino/widgets';
9
9
  import { INotebookShell } from '@jupyter-notebook/application';
10
+ import { caretDownIcon } from '@jupyterlab/ui-components';
10
11
  /**
11
12
  * The command IDs used by the application plugin.
12
13
  */
@@ -28,31 +29,27 @@ var CommandIDs;
28
29
  /**
29
30
  * A plugin to add custom toolbar items to the notebook page
30
31
  */
31
- const launchButtons = {
32
+ const interfaceSwitcher = {
32
33
  id: '@jupyter-notebook/lab-extension:interface-switcher',
33
34
  autoStart: true,
34
- requires: [ITranslator],
35
+ requires: [ITranslator, INotebookTracker],
35
36
  optional: [
36
- INotebookTracker,
37
37
  ICommandPalette,
38
38
  INotebookShell,
39
39
  ILabShell,
40
- IToolbarWidgetRegistry
40
+ IToolbarWidgetRegistry,
41
41
  ],
42
42
  activate: (app, translator, notebookTracker, palette, notebookShell, labShell, toolbarRegistry) => {
43
- if (!notebookTracker) {
44
- // to prevent showing the toolbar button in non-notebook pages
45
- return;
46
- }
47
43
  const { commands, shell } = app;
48
44
  const baseUrl = PageConfig.getBaseUrl();
49
45
  const trans = translator.load('notebook');
50
46
  const overflowOptions = {
51
- overflowMenuOptions: { isVisible: false }
47
+ overflowMenuOptions: { isVisible: false },
52
48
  };
53
49
  const menubar = new MenuBar(overflowOptions);
54
50
  const switcher = new Menu({ commands });
55
51
  switcher.title.label = trans.__('Interface');
52
+ switcher.title.icon = caretDownIcon;
56
53
  menubar.addMenu(switcher);
57
54
  const isEnabled = () => {
58
55
  return (notebookTracker.currentWidget !== null &&
@@ -61,7 +58,7 @@ const launchButtons = {
61
58
  const addInterface = (option) => {
62
59
  const { command, commandLabel, urlPrefix } = option;
63
60
  commands.addCommand(command, {
64
- label: args => (args.noLabel ? '' : commandLabel),
61
+ label: (args) => (args.noLabel ? '' : commandLabel),
65
62
  caption: commandLabel,
66
63
  execute: () => {
67
64
  const current = notebookTracker.currentWidget;
@@ -70,7 +67,7 @@ const launchButtons = {
70
67
  }
71
68
  window.open(`${urlPrefix}${current.context.path}`);
72
69
  },
73
- isEnabled
70
+ isEnabled,
74
71
  });
75
72
  if (palette) {
76
73
  palette.addItem({ command, category: 'Other' });
@@ -82,7 +79,7 @@ const launchButtons = {
82
79
  command: CommandIDs.openNotebook,
83
80
  commandLabel: trans.__('Open With %1', 'Jupyter Notebook'),
84
81
  buttonLabel: 'openNotebook',
85
- urlPrefix: `${baseUrl}tree/`
82
+ urlPrefix: `${baseUrl}tree/`,
86
83
  });
87
84
  }
88
85
  if (!labShell) {
@@ -90,18 +87,18 @@ const launchButtons = {
90
87
  command: CommandIDs.openLab,
91
88
  commandLabel: trans.__('Open With %1', 'JupyterLab'),
92
89
  buttonLabel: 'openLab',
93
- urlPrefix: `${baseUrl}doc/tree/`
90
+ urlPrefix: `${baseUrl}doc/tree/`,
94
91
  });
95
92
  }
96
93
  if (toolbarRegistry) {
97
- toolbarRegistry.addFactory('Notebook', 'interfaceSwitcher', panel => {
94
+ toolbarRegistry.addFactory('Notebook', 'interfaceSwitcher', (panel) => {
98
95
  const menubar = new MenuBar(overflowOptions);
99
96
  menubar.addMenu(switcher);
100
97
  menubar.addClass('jp-InterfaceSwitcher');
101
98
  return menubar;
102
99
  });
103
100
  }
104
- }
101
+ },
105
102
  };
106
103
  /**
107
104
  * A plugin to add a command to open the Jupyter Notebook Tree.
@@ -119,18 +116,18 @@ const launchNotebookTree = {
119
116
  label: trans.__('Launch Jupyter Notebook File Browser'),
120
117
  execute: () => {
121
118
  window.open(PageConfig.getBaseUrl() + 'tree');
122
- }
119
+ },
123
120
  });
124
121
  if (palette) {
125
122
  palette.addItem({ command: CommandIDs.launchNotebookTree, category });
126
123
  }
127
- }
124
+ },
128
125
  };
129
126
  /**
130
127
  * Export the plugins as default.
131
128
  */
132
129
  const plugins = [
133
130
  launchNotebookTree,
134
- launchButtons
131
+ interfaceSwitcher,
135
132
  ];
136
133
  export default plugins;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyter-notebook/lab-extension",
3
- "version": "7.0.0-alpha.15",
3
+ "version": "7.0.0-alpha.17",
4
4
  "description": "Jupyter Notebook - Lab Extension",
5
5
  "homepage": "https://github.com/jupyter/notebook",
6
6
  "bugs": {
@@ -43,20 +43,21 @@
43
43
  "watch:src": "tsc -w"
44
44
  },
45
45
  "dependencies": {
46
- "@jupyter-notebook/application": "^7.0.0-alpha.15",
47
- "@jupyterlab/application": "^4.0.0-alpha.20",
48
- "@jupyterlab/apputils": "^4.0.0-alpha.20",
49
- "@jupyterlab/coreutils": "^6.0.0-alpha.20",
50
- "@jupyterlab/docregistry": "^4.0.0-alpha.20",
51
- "@jupyterlab/notebook": "^4.0.0-alpha.20",
52
- "@jupyterlab/translation": "^4.0.0-alpha.20",
53
- "@lumino/commands": "^2.0.0-rc.1",
54
- "@lumino/disposable": "^2.0.0-rc.1"
46
+ "@jupyter-notebook/application": "^7.0.0-alpha.17",
47
+ "@jupyterlab/application": "^4.0.0-alpha.22",
48
+ "@jupyterlab/apputils": "^4.0.0-alpha.22",
49
+ "@jupyterlab/coreutils": "^6.0.0-alpha.22",
50
+ "@jupyterlab/docregistry": "^4.0.0-alpha.22",
51
+ "@jupyterlab/notebook": "^4.0.0-alpha.22",
52
+ "@jupyterlab/translation": "^4.0.0-alpha.22",
53
+ "@jupyterlab/ui-components": "^4.0.0-alpha.37",
54
+ "@lumino/commands": "^2.0.0",
55
+ "@lumino/disposable": "^2.0.0"
55
56
  },
56
57
  "devDependencies": {
57
- "@jupyterlab/builder": "^4.0.0-alpha.20",
58
+ "@jupyterlab/builder": "^4.0.0-alpha.22",
58
59
  "rimraf": "^3.0.2",
59
- "typescript": "5.0.1-rc"
60
+ "typescript": "~5.0.2"
60
61
  },
61
62
  "publishConfig": {
62
63
  "access": "public"