Skip to content

Commit

Permalink
expose component renderers for legacy project
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronlisman committed Dec 1, 2016
1 parent a3c3a50 commit 37d4800
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
2 changes: 0 additions & 2 deletions dist/reactapp/js/3.chunk.js

This file was deleted.

3 changes: 2 additions & 1 deletion my-index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title><%= htmlWebpackPlugin.options.title %></title>
<script>
window.defaultRoute = "/dataset";
//window.devContext = true;
window.defaultRoute = "/patient";
// Set default API in case none is specified in .env
__API_ROOT__ = 'cbioportal-rc.herokuapp.com/api';
</script>
Expand Down
25 changes: 24 additions & 1 deletion src/pages/patientView/PatientViewPage.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { connect } from 'react-redux';

import { Component } from 'react';
import ClinicalInformationContainer from './clinicalInformation/ClinicalInformationContainer';
import PatientHeaderUnconnected from './patientHeader/PatientHeader';
import {IPatientHeaderProps} from './patientHeader/PatientHeader';
import {RootState} from "../../redux/rootReducer";
import PageDecorator from '../../shared/components/PageDecorator/PageDecorator';

interface IPatientViewPageProps {
store?: RootState;
Expand Down Expand Up @@ -35,6 +36,28 @@ export default class PatientViewPage extends React.Component<IPatientViewPagePro
clinicalDiv
);
}


this.exposeComponentRenderersToParentScript();


}

// this gives the parent (legacy) cbioportal code control to mount
// these components whenever and wherever it wants
exposeComponentRenderersToParentScript(){

const win: any = window;

if(win) {
win.renderPatientView = (mountNode: HTMLElement): void => {
ReactDOM.render(
<ClinicalInformationContainer store={ this.props.store } />,
mountNode
);
};
}

}

public render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface IClinicalInformationContainerProps {
nodes?: TODO;//PDXNode[];
loadClinicalInformationTableData?: () => void;
setTab?: (activeTab:number) => void;
store?: any;
};

@Connector.decorator
Expand All @@ -29,6 +30,7 @@ export default class ClinicalInformationContainer extends React.Component<IClini
return (
<div>
<ClinicalInformationPatientTable showTitleBar={true} data={this.props.patient && this.props.patient.clinicalData} />
<hr />
<ClinicalInformationSamples samples={this.props.samples} />
</div>
);
Expand All @@ -43,7 +45,7 @@ export default class ClinicalInformationContainer extends React.Component<IClini
return <div>{ this.buildTabs() }</div>;

case 'error':
return <div>There was an error.</div>;
return <div>There was a loading error. Please try refreshing your browser.</div>;

default:
return <div />;
Expand Down
13 changes: 13 additions & 0 deletions src/shared/components/PageDecorator/PageDecorator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as React from 'react';

export default function (component: typeof React.Component): any {
return class extends component<any, any> {
render() {
if ((window as any).devContext) {
return super.render();
} else {
return <span style={{ display:'none' }} />;
}
}
};
};

0 comments on commit 37d4800

Please sign in to comment.