Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the variable inspector to the right area #265

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 8 additions & 52 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import { VariableInspectorManager, IVariableInspectorManager } from './manager';

import { Languages } from './inspectorscripts';

import { ICommandPalette, WidgetTracker } from '@jupyterlab/apputils';
import { WidgetTracker } from '@jupyterlab/apputils';

import {
ILabShell,
ILayoutRestorer,
JupyterFrontEnd,
JupyterFrontEndPlugin,
} from '@jupyterlab/application';
Expand All @@ -26,28 +25,15 @@ import { INotebookTracker, NotebookPanel } from '@jupyterlab/notebook';

import { listIcon } from '@jupyterlab/ui-components';

namespace CommandIDs {
export const open = 'variableinspector:open';
}

/**
* A service providing variable introspection.
*/
const variableinspector: JupyterFrontEndPlugin<IVariableInspectorManager> = {
id: '@lckr/jupyterlab_variableinspector',
requires: [ICommandPalette, ILayoutRestorer, ILabShell],
provides: IVariableInspectorManager,
autoStart: true,
activate: (
app: JupyterFrontEnd,
palette: ICommandPalette,
restorer: ILayoutRestorer,
labShell: ILabShell
): IVariableInspectorManager => {
activate: (app: JupyterFrontEnd): IVariableInspectorManager => {
const manager = new VariableInspectorManager();
const category = 'Variable Inspector';
const command = CommandIDs.open;
const label = 'Open Variable Inspector';
const namespace = 'variableinspector';
const tracker = new WidgetTracker<VariableInspectorPanel>({ namespace });

Expand All @@ -58,7 +44,6 @@ const variableinspector: JupyterFrontEndPlugin<IVariableInspectorManager> = {
const panel = new VariableInspectorPanel();

panel.id = 'jp-variableinspector';
panel.title.label = 'Variable Inspector';
panel.title.icon = listIcon;
panel.title.closable = true;
panel.disposed.connect(() => {
Expand All @@ -67,36 +52,17 @@ const variableinspector: JupyterFrontEndPlugin<IVariableInspectorManager> = {
}
});

//Track the inspector panel
// Track the inspector panel
tracker.add(panel);

return panel;
}

// Enable state restoration
restorer.restore(tracker, {
command,
args: () => null,
name: () => 'variableinspector',
});

// Add command to palette
app.commands.addCommand(command, {
label,
execute: () => {
if (!manager.panel || manager.panel.isDisposed) {
manager.panel = newPanel();
}
if (!manager.panel.isAttached) {
labShell.add(manager.panel, 'main');
}
if (manager.source) {
manager.source.performInspection();
}
labShell.activateById(manager.panel.id);
},
});
palette.addItem({ command, category });
manager.panel = newPanel();
if (manager.source) {
manager.source.performInspection();
}
app.shell.add(manager.panel, 'right');

console.log(
'JupyterLab extension @lckr/jupyterlab_variableinspector is activated!'
Expand Down Expand Up @@ -206,11 +172,6 @@ const consoles: JupyterFrontEndPlugin<void> = {
}
});
});

app.contextMenu.addItem({
command: CommandIDs.open,
selector: '.jp-CodeConsole',
});
},
};

Expand Down Expand Up @@ -302,11 +263,6 @@ const notebooks: JupyterFrontEndPlugin<void> = {
}
});
});

app.contextMenu.addItem({
command: CommandIDs.open,
selector: '.jp-Notebook',
});
},
};

Expand Down
1 change: 1 addition & 0 deletions style/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
flex-direction: column;
overflow: auto;
font-size: var(--jp-ui-font-size1);
background: var(--jp-layout-color1);
}

.jp-VarInspector-table {
Expand Down