prodonjs commented on a change in pull request #12770: URL: https://github.com/apache/beam/pull/12770#discussion_r485129135
########## File path: sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/SidePanel.ts ########## @@ -0,0 +1,120 @@ +// Licensed under the Apache License, Version 2.0 (the 'License'); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. + +import { + SessionContext, + ISessionContext, + sessionContextDialogs +} from '@jupyterlab/apputils'; +import { IRenderMimeRegistry } from '@jupyterlab/rendermime'; +import { ServiceManager } from '@jupyterlab/services'; +import { Message } from '@lumino/messaging'; +import { BoxPanel } from '@lumino/widgets'; + +// prettier-ignore +import { + InteractiveInspectorWidget +} from './inspector/InteractiveInspectorWidget'; + +/** + * The side panel: main user interface of the extension. + * + * Multiple instances of the side panel can be opened at the same time. They + * can be operated independently but sharing the same kernel state if connected + * to the same notebook session model or running kernel instance. + */ +export class SidePanel extends BoxPanel { + constructor( + manager: ServiceManager.IManager, + rendermime: IRenderMimeRegistry + ) { + super({ + direction: 'top-to-bottom', + alignment: 'end' + }); + this.id = 'apache-beam-jupyterlab-sidepanel'; + this.title.label = 'Interactive Beam Inspector'; + this.title.closable = true; + + this._sessionContext = new SessionContext({ + sessionManager: manager.sessions, + specsManager: manager.kernelspecs, + name: 'Interactive Beam Inspector Session' + }); + + this._inspector = new InteractiveInspectorWidget(this._sessionContext); + this.addWidget(this._inspector); + + void this._sessionContext Review comment: I would suggest moving this out to a private `async` method for readability. Since you're already using async/await in the `then` handler, it seems like it would be most consistent to use it throughout rather than chaining with `then` and `catch`. ########## File path: sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/style/mdc-theme.css ########## @@ -0,0 +1,43 @@ +/* + * Licensed under the Apache License, Version 2.0 (the 'License'); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +/* + * Theme configured from https://rmwc.io/. + */ +:root { + --mdc-theme-primary: #1a73e8; Review comment: We ran into this issue with some of our extensions this summer and found that it was best if we referenced JupyterLab's CSS variables for colors where possible so we would be able to support users with different JupyterLab themes. - https://jupyterlab.readthedocs.io/en/stable/developer/css.html - https://github.com/jupyterlab/jupyterlab/blob/master/packages/theme-light-extension/style/variables.css ########## File path: sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/SidePanel.ts ########## @@ -0,0 +1,120 @@ +// Licensed under the Apache License, Version 2.0 (the 'License'); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. + +import { + SessionContext, + ISessionContext, + sessionContextDialogs +} from '@jupyterlab/apputils'; +import { IRenderMimeRegistry } from '@jupyterlab/rendermime'; +import { ServiceManager } from '@jupyterlab/services'; +import { Message } from '@lumino/messaging'; +import { BoxPanel } from '@lumino/widgets'; + +// prettier-ignore +import { + InteractiveInspectorWidget +} from './inspector/InteractiveInspectorWidget'; + +/** + * The side panel: main user interface of the extension. + * + * Multiple instances of the side panel can be opened at the same time. They + * can be operated independently but sharing the same kernel state if connected + * to the same notebook session model or running kernel instance. + */ +export class SidePanel extends BoxPanel { + constructor( + manager: ServiceManager.IManager, + rendermime: IRenderMimeRegistry + ) { + super({ + direction: 'top-to-bottom', + alignment: 'end' + }); + this.id = 'apache-beam-jupyterlab-sidepanel'; + this.title.label = 'Interactive Beam Inspector'; + this.title.closable = true; + + this._sessionContext = new SessionContext({ + sessionManager: manager.sessions, + specsManager: manager.kernelspecs, + name: 'Interactive Beam Inspector Session' + }); + + this._inspector = new InteractiveInspectorWidget(this._sessionContext); + this.addWidget(this._inspector); + + void this._sessionContext + .initialize() + .then(async value => { + if (value) { Review comment: If there is no handling if value is falsy, I would suggest `if (!value) return;` to eliminate a layer of nesting. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
