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

expose component renderers for legacy project #89

Merged
merged 1 commit into from
Dec 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' }} />;
}
}
};
};