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 a Property Inspector #7665

Merged
merged 3 commits into from Dec 23, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions buildutils/src/ensure-package.ts
Expand Up @@ -193,6 +193,9 @@ export async function ensurePackage(

// write out cssIndexContents, if needed
const cssIndexPath = path.join(pkgPath, 'style/index.css');
if (!fs.existsSync(cssIndexPath)) {
fs.ensureFileSync(cssIndexPath);
}
messages.push(...ensureFile(cssIndexPath, cssIndexContents, false));
}

Expand Down
2 changes: 2 additions & 0 deletions dev_mode/package.json
Expand Up @@ -143,6 +143,7 @@
"@jupyterlab/observables": "~3.0.0-alpha.4",
"@jupyterlab/outputarea": "~2.0.0-alpha.4",
"@jupyterlab/pdf-extension": "~2.0.0-alpha.4",
"@jupyterlab/property-inspector": "~2.0.0-alpha.4",
"@jupyterlab/rendermime": "~2.0.0-alpha.4",
"@jupyterlab/rendermime-extension": "~2.0.0-alpha.4",
"@jupyterlab/rendermime-interfaces": "~2.0.0-alpha.4",
Expand Down Expand Up @@ -328,6 +329,7 @@
"@jupyterlab/observables": "../packages/observables",
"@jupyterlab/outputarea": "../packages/outputarea",
"@jupyterlab/pdf-extension": "../packages/pdf-extension",
"@jupyterlab/property-inspector": "../packages/property-inspector",
"@jupyterlab/rendermime": "../packages/rendermime",
"@jupyterlab/rendermime-extension": "../packages/rendermime-extension",
"@jupyterlab/rendermime-interfaces": "../packages/rendermime-interfaces",
Expand Down
1 change: 1 addition & 0 deletions packages/application-extension/package.json
Expand Up @@ -39,6 +39,7 @@
"@jupyterlab/application": "^2.0.0-alpha.4",
"@jupyterlab/apputils": "^2.0.0-alpha.4",
"@jupyterlab/coreutils": "^4.0.0-alpha.4",
"@jupyterlab/property-inspector": "^2.0.0-alpha.4",
"@lumino/algorithm": "^1.2.1",
"@lumino/widgets": "^1.9.4",
"react": "~16.9.0"
Expand Down
26 changes: 25 additions & 1 deletion packages/application-extension/src/index.tsx
Expand Up @@ -31,6 +31,11 @@ import {
URLExt
} from '@jupyterlab/coreutils';

import {
IPropertyInspectorProvider,
SideBarPropertyInspectorProvider
} from '@jupyterlab/property-inspector';

import { each, iter, toArray } from '@lumino/algorithm';

import { Widget, DockLayout } from '@lumino/widgets';
Expand Down Expand Up @@ -765,6 +770,24 @@ const paths: JupyterFrontEndPlugin<JupyterFrontEnd.IPaths> = {
provides: JupyterFrontEnd.IPaths
};

/**
* Initialization data for the property_inspector extension.
afshin marked this conversation as resolved.
Show resolved Hide resolved
*/
const propertyInspector: JupyterFrontEndPlugin<IPropertyInspectorProvider> = {
id: '@jupyterlab/application-extension:property-inspector',
autoStart: true,
requires: [ILabShell],
provides: IPropertyInspectorProvider,
activate: (app: JupyterFrontEnd, labshell: ILabShell) => {
const widget = new SideBarPropertyInspectorProvider(labshell);
widget.title.iconClass = 'jp-BuildIcon jp-SideBar-tabIcon';
widget.title.caption = 'Property Inspector';
widget.id = 'jp-property-inspector';
labshell.add(widget, 'left');
return widget;
}
};

/**
* Export the plugins as default.
*/
Expand All @@ -779,7 +802,8 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
shell,
status,
info,
paths
paths,
propertyInspector
];

export default plugins;
5 changes: 5 additions & 0 deletions packages/application-extension/style/base.css
@@ -0,0 +1,5 @@
/*-----------------------------------------------------------------------------
| Copyright (c) 2014-2017, Jupyter Development Team.
afshin marked this conversation as resolved.
Show resolved Hide resolved
|
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
8 changes: 6 additions & 2 deletions packages/application-extension/style/index.css
@@ -1,7 +1,11 @@
/*-----------------------------------------------------------------------------
| Copyright (c) 2014-2017, Jupyter Development Team.
|
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/

/* This file was auto-generated by ensurePackage() in @jupyterlab/buildutils */
@import url('~@lumino/widgets/style/index.css');
@import url('~@jupyterlab/application/style/index.css');
@import url('~@jupyterlab/property-inspector/style/index.css');

@import url('./base.css');
3 changes: 3 additions & 0 deletions packages/application-extension/tsconfig.json
Expand Up @@ -14,6 +14,9 @@
},
{
"path": "../coreutils"
},
{
"path": "../property-inspector"
}
]
}
1 change: 1 addition & 0 deletions packages/metapackage/package.json
Expand Up @@ -86,6 +86,7 @@
"@jupyterlab/observables": "^3.0.0-alpha.4",
"@jupyterlab/outputarea": "^2.0.0-alpha.4",
"@jupyterlab/pdf-extension": "^2.0.0-alpha.4",
"@jupyterlab/property-inspector": "^2.0.0-alpha.4",
"@jupyterlab/rendermime": "^2.0.0-alpha.4",
"@jupyterlab/rendermime-extension": "^2.0.0-alpha.4",
"@jupyterlab/rendermime-interfaces": "^2.0.0-alpha.4",
Expand Down
3 changes: 3 additions & 0 deletions packages/metapackage/tsconfig.json
Expand Up @@ -168,6 +168,9 @@
{
"path": "../pdf-extension"
},
{
"path": "../property-inspector"
},
{
"path": "../rendermime"
},
Expand Down
1 change: 1 addition & 0 deletions packages/notebook-extension/package.json
Expand Up @@ -46,6 +46,7 @@
"@jupyterlab/launcher": "^2.0.0-alpha.4",
"@jupyterlab/mainmenu": "^2.0.0-alpha.4",
"@jupyterlab/notebook": "^2.0.0-alpha.4",
"@jupyterlab/property-inspector": "^2.0.0-alpha.4",
"@jupyterlab/rendermime": "^2.0.0-alpha.4",
"@jupyterlab/services": "^5.0.0-alpha.4",
"@jupyterlab/statusbar": "^2.0.0-alpha.4",
Expand Down
62 changes: 16 additions & 46 deletions packages/notebook-extension/src/index.ts
Expand Up @@ -70,13 +70,15 @@ import { ServiceManager } from '@jupyterlab/services';

import { IStatusBar } from '@jupyterlab/statusbar';

import { ReadonlyJSONObject, JSONValue } from '@lumino/coreutils';
import { JSONValue } from '@lumino/coreutils';

import { Message, MessageLoop } from '@lumino/messaging';

import { Panel, Menu } from '@lumino/widgets';
import { CommandRegistry } from '@lumino/commands';

import { IPropertyInspectorProvider } from '@jupyterlab/property-inspector';
afshin marked this conversation as resolved.
Show resolved Hide resolved

/**
* The command IDs used by the notebook plugin.
*/
Expand Down Expand Up @@ -226,11 +228,6 @@ const NOTEBOOK_ICON_CLASS = 'jp-NotebookIcon';
*/
const FACTORY = 'Notebook';

/**
* The rank of the notebook tools tab in the sidebar
*/
const NOTEBOOK_TOOLS_RANK = 400;

/**
* The exluded Export To ...
* (returned from nbconvert's export list)
Expand Down Expand Up @@ -302,8 +299,12 @@ const tools: JupyterFrontEndPlugin<INotebookTools> = {
provides: INotebookTools,
id: '@jupyterlab/notebook-extension:tools',
autoStart: true,
requires: [INotebookTracker, IEditorServices, IStateDB],
optional: [ILabShell]
requires: [
INotebookTracker,
IEditorServices,
IStateDB
],
optional: [ILabShell, IPropertyInspectorProvider]
};

/**
Expand Down Expand Up @@ -405,7 +406,8 @@ function activateNotebookTools(
tracker: INotebookTracker,
editorServices: IEditorServices,
state: IStateDB,
labShell: ILabShell | null
labShell: ILabShell | null,
inspectorProvider: IPropertyInspectorProvider | null
): INotebookTools {
const id = 'notebook-tools';
const notebookTools = new NotebookTools({ tracker });
Expand Down Expand Up @@ -475,44 +477,12 @@ function activateNotebookTools(

MessageLoop.installMessageHook(notebookTools, hook);

// Wait until the application has finished restoring before rendering.
void Promise.all([state.fetch(id), app.restored]).then(([value]) => {
const open = !!(
value && ((value as ReadonlyJSONObject)['open'] as boolean)
);

// After initial restoration, check if the notebook tools should render.
if (tracker.size) {
app.shell.add(notebookTools, 'left', { rank: NOTEBOOK_TOOLS_RANK });
if (open) {
app.shell.activateById(notebookTools.id);
}
}

const updateTools = () => {
// If there are any open notebooks, add notebook tools to the side panel if
// it is not already there.
if (labShell && tracker.size) {
if (!notebookTools.isAttached) {
labShell.add(notebookTools, 'left', { rank: NOTEBOOK_TOOLS_RANK });
}
return;
}
// If there are no notebooks, close notebook tools.
notebookTools.close();
};

// For all subsequent widget changes, check if the notebook tools should render.
if (labShell) {
labShell.currentChanged.connect((sender, args) => {
updateTools();
});
}
// A notebook widget could be closed without a change to labShell.currentWidget
tracker.currentChanged.connect((sender, args) => {
updateTools();
if (inspectorProvider) {
tracker.widgetAdded.connect((sender, panel) => {
const inspector = inspectorProvider.register(panel);
inspector.render(notebookTools);
});
});
}

return notebookTools;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/notebook-extension/tsconfig.json
Expand Up @@ -36,6 +36,9 @@
{
"path": "../notebook"
},
{
"path": "../property-inspector"
},
{
"path": "../rendermime"
},
Expand Down
51 changes: 51 additions & 0 deletions packages/property-inspector/package.json
@@ -0,0 +1,51 @@
{
"name": "@jupyterlab/property-inspector",
"version": "2.0.0-alpha.4",
"description": "A property inspector display for widgets",
"homepage": "https://github.com/jupyterlab/jupyterlab",
"bugs": {
"url": "https://github.com/jupyterlab/jupyterlab/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/jupyterlab/jupyterlab.git"
},
"license": "BSD-3-Clause",
"author": "Project Jupyter",
"files": [
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
"schema/*.json",
"style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}"
],
"sideEffects": [
"style/**/*"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"style": "style/index.css",
"directories": {
"lib": "lib/"
},
"scripts": {
"build": "tsc",
"clean": "rimraf lib",
"prepublishOnly": "npm run build",
"watch": "tsc -w --listEmittedFiles"
},
"dependencies": {
"@jupyterlab/application": "^2.0.0-alpha.4",
"@jupyterlab/apputils": "^2.0.0-alpha.4",
"@lumino/coreutils": "^1.4.0",
"@lumino/disposable": "^1.3.2",
"@lumino/signaling": "^1.3.2",
"@lumino/widgets": "^1.9.4",
"react": "~16.9.0"
},
"devDependencies": {
"rimraf": "~3.0.0",
"typescript": "~3.7.3"
},
"publishConfig": {
"access": "public"
}
}