KevinGG commented on a change in pull request #12626: URL: https://github.com/apache/beam/pull/12626#discussion_r478632531
########## File path: sdks/python/apache_beam/runners/interactive/extensions/apache-beam-jupyterlab-sidepanel/src/inspector/InspectableView.tsx ########## @@ -0,0 +1,128 @@ +// 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 * as React from 'react'; + +import { Checkbox } from '@rmwc/checkbox'; + +import { + InspectableViewModel, + IOptions, + IShowOptions +} from './InspectableViewModel'; +import { HtmlView } from '../common/HtmlView'; +import { IHtmlProvider } from '../common/HtmlView'; + +import '@rmwc/checkbox/styles'; + +interface IInspectableViewProps { + model: InspectableViewModel; +} + +interface IInspectableViewState { + inspectableType: string; + // options used in kernel messaging. + options: IOptions; +} + +/** + * The display area of the InteractiveInspector parent component. + * + * The react component is composed with a top checkbox section of display + * options and a main HtmlView area that displays HTML from IOPub messaging of + * its kernel model. + */ +export class InspectableView extends React.Component< + IInspectableViewProps, + IInspectableViewState +> { + constructor(props: IInspectableViewProps) { + super(props); + this.state = { + inspectableType: 'pipeline', + options: props.model.options + }; + } + + componentDidMount(): void { + this._updateRenderTimerId = setInterval(() => this.updateRender(), 1500); + } + + componentWillUnmount(): void { + clearInterval(this._updateRenderTimerId); + } + + updateRender(): void { + if (this.props.model.inspectableType === 'pcollection') { + this.setState({ + inspectableType: 'pcollection', + options: this._buildShowOptions(this.props.model.options) + }); + } else { + this.setState({ + inspectableType: 'pipeline', + options: {} + }); + } + } + + renderOptions(): React.ReactNode { + if (this.props.model.inspectableType === 'pcollection') { Review comment: Inverted the condition and the return statements. ---------------------------------------------------------------- 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]
