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

URLWrapper: mediate all read/write interaction between app and url #2726

Merged
merged 21 commits into from
Dec 6, 2019

Conversation

alisman
Copy link
Collaborator

@alisman alisman commented Sep 20, 2019

Fixes cBioPortal/cbioportal#6737

The URL wrapper allows app to read and write from the browser URL in a controlled way. Each page has an instance of URLWrapper which defines the parameters used by that page. These params are always observable on the URLWrapper (even when they aren't present in a particular URL).

The URLWrapper also abstracts the loading and creation of "sessions." Sessions are created when URL parameters would create a URL that is too long for the browser. We then store the parameters in a remote session. When the user changes a "session" parameter of the URL, a new session is automatically created. The URLWrapper also loads session data. It allows developers to work without paying mind whether URL is stored in session or in browser url.


const resultsViewPageStore = new ResultsViewPageStore(appStore, getBrowserWindow().globalStores.routing, urlWrapper);

// whenever study list changes, reinit driver annotation settings
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamabeshouse i leave this for reference in this review because it's important to make sure we are accomplishing all this in new model

params.genetic_profile_ids_PROFILE_MRNA_EXPRESSION,
params.genetic_profile_ids_PROFILE_METHYLATION,
params.genetic_profile_ids_PROFILE_PROTEIN_EXPRESSION,
params.genetic_profile_ids_PROFILE_GENESET_SCOR
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i must have reformatted this entire file.


constructor(
protected routing:ExtendedRouterStore,
protected properties:Property<QueryParamsType>[]
) {
const initValues:Partial<QueryParamsType> = {};
for (const property of properties) {
initValues[property.name] = undefined;
initValues[property.name] = (routing.query as QueryParamsType)[property.name];
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as a reminder, we realized we could do this up front instead of starting at undefined

@@ -466,7 +476,7 @@ export default class ResultsViewPage extends React.Component<IResultsViewPagePro
{
// we don't show the result tabs if we don't have valid query
(this.showTabs && !this.resultsViewPageStore.genesInvalid && !this.resultsViewPageStore.isQueryInvalid) && (
<MSKTabs key={this.resultsViewPageStore.rvQuery.hash} activeTabId={this.currentTab(this.resultsViewPageStore.tabId)} unmountOnHide={false}
<MSKTabs activeTabId={this.currentTab(this.resultsViewPageStore.tabId)} unmountOnHide={false}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adam I took the key off of this. We need to discuss why we had key in the first place. Obviously to force re-mounting. But why? There was a reason!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

man I wish we'd left a comment. clearly there was a reason because we went to the trouble of creating that hash.

@@ -1072,6 +1071,7 @@ export default class ResultsViewOncoprint extends React.Component<IResultsViewOn
}

public render() {
console.log("Oncoprint rendering");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log

import ExtendedRouterStore from "shared/lib/ExtendedRouterStore";
import sinon from "sinon";

describe("URLWrapper", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is really ResultsViewURLWRapper.spec.ts

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be ok to test a superclass using it's subclass

this.query[property.name] = query[property.name];
// @ts-ignore
this.setProperty(property, query);
//this.query[property.name] = typeof query[property.name] === "string" ? decodeURIComponent(query[property.name]) : undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented line

@@ -39,6 +52,23 @@ export default class URLWrapper<QueryParamsType> {
this.routing.updateRoute(query as any);
}

private setProperty(property:Property<QueryParamsType>, query:QueryParamsType){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets call this syncProperty for more semantic readability?

}

private _setPropertyAndHandleUndefined(property:Property<QueryParamsType>, value:string|undefined){
// @ts-ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not huge deal, but how about trySyncProperty? a little more readable to me

// if it's still undefined, then check aliases
if (this.query[property.name] === undefined && property.aliases && property.aliases.length) {
for (const alias of property.aliases) {
this._setPropertyAndHandleUndefined(property, query[alias]);
Copy link
Contributor

@adamabeshouse adamabeshouse Oct 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be most idiomatic to have the helper return boolean depending whether it successfully set a value. then you can do if (this.trySyncProperty(..)) break;

a little cleaner I think

but not completely necessary

@alisman alisman force-pushed the urlWrapper branch 3 times, most recently from 4db522e to 1db3f28 Compare October 11, 2019 18:08
@jjgao jjgao temporarily deployed to cbioportal-frontend-pr-2726 October 14, 2019 16:41 Inactive
@jjgao jjgao had a problem deploying to cbioportal-frontend-pr-2726 October 15, 2019 17:14 Failure
@jjgao jjgao temporarily deployed to cbioportal-frontend-pr-2726 October 15, 2019 20:34 Inactive
@jjgao jjgao had a problem deploying to cbioportal-frontend-pr-2726 October 16, 2019 18:02 Failure
@jjgao jjgao temporarily deployed to cbioportal-frontend-pr-2726 October 16, 2019 18:52 Inactive
@jjgao jjgao temporarily deployed to cbioportal-f-urlwrapper-d08qpd December 5, 2019 22:06 Inactive
alisman and others added 21 commits December 5, 2019 19:01
…fix bugs when they change dynamically

Signed-off-by: Abeshouse, Adam A./Sloan Kettering Institute <[email protected]>
… by not rendering unless everything is ready

Signed-off-by: Abeshouse, Adam A./Sloan Kettering Institute <[email protected]>
…on refresh

Signed-off-by: Abeshouse, Adam A./Sloan Kettering Institute <[email protected]>
…oncoprint

Signed-off-by: Abeshouse, Adam A./Sloan Kettering Institute <[email protected]>
Signed-off-by: Abeshouse, Adam A./Sloan Kettering Institute <[email protected]>
…oblems probably due to breaking @computed's connection to the reaction

Signed-off-by: Abeshouse, Adam A./Sloan Kettering Institute <[email protected]>
…pendencies are complete

Signed-off-by: Abeshouse, Adam A./Sloan Kettering Institute <[email protected]>
@jjgao jjgao temporarily deployed to cbioportal-f-urlwrapper-d08qpd December 6, 2019 00:04 Inactive
@alisman alisman merged commit eceb5f8 into cBioPortal:master Dec 6, 2019
@alisman alisman changed the title Url wrapper URLWrapper: mediate all read/write interaction between app and url Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

treatment_list url parameter lost when going from Oncoprint to Plots Tab
4 participants