-
Notifications
You must be signed in to change notification settings - Fork 97
Load and save variable filters #293
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "title": "Variable Inspector", | ||
| "description": "jupyterlab-variableinspector settings.", | ||
| "type": "object", | ||
| "properties": { | ||
| "filteredTypes": { | ||
| "type": "array", | ||
| "title": "Filter variables by type", | ||
| "description": "Filters out all variables with types matching the given filter", | ||
| "default": [] | ||
| }, | ||
| "filteredNames": { | ||
| "type": "array", | ||
| "title": "Filter variables by name", | ||
| "description": "Filters out all variables with names matching the given filter", | ||
| "default": [] | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ import { VariableInspectorManager } from './manager'; | |
| import { VariableInspectorPanel } from './variableinspector'; | ||
|
|
||
| import { IVariableInspector, IVariableInspectorManager } from './tokens'; | ||
| import { ISettingRegistry } from '@jupyterlab/settingregistry'; | ||
|
|
||
| namespace CommandIDs { | ||
| export const open = 'variableinspector:open'; | ||
|
|
@@ -33,28 +34,36 @@ namespace CommandIDs { | |
| * A service providing variable introspection. | ||
| */ | ||
| const variableinspector: JupyterFrontEndPlugin<IVariableInspectorManager> = { | ||
| id: '@lckr/jupyterlab_variableinspector', | ||
| requires: [ICommandPalette, ILayoutRestorer, ILabShell], | ||
| id: '@lckr/jupyterlab_variableinspector:plugin', | ||
| requires: [ICommandPalette, ILayoutRestorer, ILabShell, ISettingRegistry], | ||
| provides: IVariableInspectorManager, | ||
| autoStart: true, | ||
| activate: ( | ||
| activate: async ( | ||
| app: JupyterFrontEnd, | ||
| palette: ICommandPalette, | ||
| restorer: ILayoutRestorer, | ||
| labShell: ILabShell | ||
| ): IVariableInspectorManager => { | ||
| labShell: ILabShell, | ||
| settingRegistry: ISettingRegistry | ||
| ): Promise<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 }); | ||
| let settings: ISettingRegistry.ISettings; | ||
|
|
||
| try { | ||
| settings = await settingRegistry.load(variableinspector.id); | ||
| } catch (error) { | ||
| console.error('Failed to load settings for the Git Extension', error); | ||
| } | ||
|
|
||
| /** | ||
| * Create and track a new inspector. | ||
| */ | ||
| function newPanel(): VariableInspectorPanel { | ||
| const panel = new VariableInspectorPanel(); | ||
| const panel = new VariableInspectorPanel(settings); | ||
|
||
|
|
||
| panel.id = 'jp-variableinspector'; | ||
| panel.title.label = 'Variable Inspector'; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good practice wants that asynchronous code should not block the activation of the plugin as it may delay the full application start up.
A better pattern is therefore to use a Promise approach: