From 8f1ae8474b10226bbafbbad0971d61622e10ac04 Mon Sep 17 00:00:00 2001 From: alisman Date: Mon, 23 May 2022 14:29:01 -0400 Subject: [PATCH] remove inject decorator which conflicts with react context --- src/pages/resultsView/ResultsViewPage.tsx | 37 ++++++++++++++--------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/pages/resultsView/ResultsViewPage.tsx b/src/pages/resultsView/ResultsViewPage.tsx index d15635d5d93..94a614fb2a1 100644 --- a/src/pages/resultsView/ResultsViewPage.tsx +++ b/src/pages/resultsView/ResultsViewPage.tsx @@ -27,7 +27,7 @@ import { MSKTab, MSKTabs } from '../../shared/components/MSKTabs/MSKTabs'; import { PageLayout } from '../../shared/components/PageLayout/PageLayout'; import autobind from 'autobind-decorator'; import { ITabConfiguration } from '../../shared/model/ITabConfiguration'; -import { remoteData } from 'cbioportal-frontend-commons'; +import { getBrowserWindow, remoteData } from 'cbioportal-frontend-commons'; import CoExpressionTab from './coExpression/CoExpressionTab'; import Helmet from 'react-helmet'; import { @@ -101,12 +101,9 @@ function addOnBecomeVisibleListener(callback: () => void) { } export interface IResultsViewPageProps { - routing: ExtendedRouterStore; - appStore: AppStore; params: any; // from react router } -@inject('appStore', 'routing') @observer export default class ResultsViewPage extends React.Component< IResultsViewPageProps, @@ -127,7 +124,7 @@ export default class ResultsViewPage extends React.Component< makeObservable(this); - this.urlWrapper = new ResultsViewURLWrapper(props.routing); + this.urlWrapper = new ResultsViewURLWrapper(this.routing); handleLegacySubmission(this.urlWrapper); @@ -138,18 +135,30 @@ export default class ResultsViewPage extends React.Component< if (this.urlWrapper.hasSessionId) { onMobxPromise(this.urlWrapper.remoteSessionData, () => { this.resultsViewPageStore = initStore( - props.appStore, + this.appStore, this.urlWrapper ); }); } else { this.resultsViewPageStore = initStore( - props.appStore, + this.appStore, this.urlWrapper ); } } + // this is temporary to allow us to + // get rid of @inject, which is conflicting + // with react context + // ultimately should be replaced with react context + private get appStore(): AppStore { + return getBrowserWindow().globalStores.appStore as AppStore; + } + + private get routing(): ExtendedRouterStore { + return getBrowserWindow().globalStores.routing as ExtendedRouterStore; + } + componentWillUnmount() { this.resultsViewPageStore.destroy(); this.urlWrapper.destroy(); @@ -255,7 +264,7 @@ export default class ResultsViewPage extends React.Component< > @@ -313,7 +322,7 @@ export default class ResultsViewPage extends React.Component< > @@ -456,7 +465,7 @@ export default class ResultsViewPage extends React.Component< > @@ -632,8 +641,8 @@ export default class ResultsViewPage extends React.Component< private getTabHref(tabId: string) { return URL.format({ pathname: buildCBioPortalPageUrl(`./results/${tabId}`), - query: this.props.routing.query, - hash: this.props.routing.location.hash, + query: this.routing.query, + hash: this.routing.location.hash, }); } @@ -729,7 +738,7 @@ export default class ResultsViewPage extends React.Component<
{ runInAction(() => { @@ -792,7 +801,7 @@ export default class ResultsViewPage extends React.Component< contentWindowExtra={