Skip to content

Commit

Permalink
remove inject decorator which conflicts with react context
Browse files Browse the repository at this point in the history
  • Loading branch information
alisman committed May 24, 2022
1 parent 66c1846 commit 8f1ae84
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions src/pages/resultsView/ResultsViewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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);

Expand All @@ -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();
Expand Down Expand Up @@ -255,7 +264,7 @@ export default class ResultsViewPage extends React.Component<
>
<Mutations
store={store}
appStore={this.props.appStore}
appStore={this.appStore}
urlWrapper={this.urlWrapper}
/>
</MSKTab>
Expand Down Expand Up @@ -313,7 +322,7 @@ export default class ResultsViewPage extends React.Component<
>
<ComparisonTab
urlWrapper={this.urlWrapper}
appStore={this.props.appStore}
appStore={this.appStore}
store={this.resultsViewPageStore}
/>
</MSKTab>
Expand Down Expand Up @@ -456,7 +465,7 @@ export default class ResultsViewPage extends React.Component<
>
<ResultsViewPathwayMapper
store={store}
appStore={this.props.appStore}
appStore={this.appStore}
urlWrapper={this.urlWrapper}
/>
</MSKTab>
Expand Down Expand Up @@ -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,
});
}

Expand Down Expand Up @@ -729,7 +738,7 @@ export default class ResultsViewPage extends React.Component<
<div>
<div className={'headBlock'}>
<QuerySummary
routingStore={this.props.routing}
routingStore={this.routing}
store={this.resultsViewPageStore}
onToggleQueryFormVisibility={visible => {
runInAction(() => {
Expand Down Expand Up @@ -792,7 +801,7 @@ export default class ResultsViewPage extends React.Component<
contentWindowExtra={
<HelpWidget
path={
this.props.routing.location
this.routing.location
.pathname
}
/>
Expand Down

0 comments on commit 8f1ae84

Please sign in to comment.