Fix output not showing by loading transform

This commit is contained in:
Laurent Nguyen
2020-12-03 08:34:29 +01:00
parent 0c80c45e22
commit 64601693b7

View File

@@ -11,6 +11,7 @@ import { KernelOutputError, StreamText } from "@nteract/outputs";
import TransformMedia from "@nteract/stateful-components/lib/outputs/transform-media"; import TransformMedia from "@nteract/stateful-components/lib/outputs/transform-media";
import { PassedEditorProps } from "@nteract/stateful-components/lib/inputs/editor"; import { PassedEditorProps } from "@nteract/stateful-components/lib/inputs/editor";
import { actions, selectors, AppState, ContentRef, KernelRef } from "@nteract/core"; import { actions, selectors, AppState, ContentRef, KernelRef } from "@nteract/core";
import loadTransform from "../NotebookComponent/loadTransform";
import { connect } from "react-redux"; import { connect } from "react-redux";
interface MongoQueryComponentPureProps { interface MongoQueryComponentPureProps {
@@ -20,6 +21,7 @@ interface MongoQueryComponentPureProps {
interface MongoQueryComponentDispatchProps { interface MongoQueryComponentDispatchProps {
runCell: (contentRef: ContentRef, cellId: string) => void; runCell: (contentRef: ContentRef, cellId: string) => void;
addTransform: (transform: React.ComponentType & { MIMETYPE: string }) => void;
} }
type OutputType = "rich" | "json"; type OutputType = "rich" | "json";
@@ -42,6 +44,10 @@ export class MongoQueryComponent extends React.Component<MongoQueryComponentProp
}; };
} }
componentDidMount(): void {
loadTransform(this.props);
}
private onExecute = () => { private onExecute = () => {
this.props.runCell(this.props.contentRef, this.props.firstCellId); this.props.runCell(this.props.contentRef, this.props.firstCellId);
}; };
@@ -59,7 +65,7 @@ export class MongoQueryComponent extends React.Component<MongoQueryComponentProp
const { firstCellId: id, contentRef } = this.props; const { firstCellId: id, contentRef } = this.props;
if (!id) { if (!id) {
return <>NO FIRST CELL</>; return <></>;
} }
return ( return (
@@ -127,6 +133,14 @@ const makeMapStateToProps = (state: AppState, initialProps: InitialProps) => {
const makeMapDispatchToProps = (/* initialDispatch: Dispatch, initialProps: MongoQueryComponentProps */) => { const makeMapDispatchToProps = (/* initialDispatch: Dispatch, initialProps: MongoQueryComponentProps */) => {
const mapDispatchToProps = (dispatch: Dispatch) => { const mapDispatchToProps = (dispatch: Dispatch) => {
return { return {
addTransform: (transform: React.ComponentType & { MIMETYPE: string }) => {
return dispatch(
actions.addTransform({
mediaType: transform.MIMETYPE,
component: transform
})
);
},
runCell: (contentRef: ContentRef, cellId: string) => { runCell: (contentRef: ContentRef, cellId: string) => {
return dispatch( return dispatch(
actions.executeCell({ actions.executeCell({