-
Notifications
You must be signed in to change notification settings - Fork 270
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
Conversation
|
||
const resultsViewPageStore = new ResultsViewPageStore(appStore, getBrowserWindow().globalStores.routing, urlWrapper); | ||
|
||
// whenever study list changes, reinit driver annotation settings |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
src/shared/lib/URLWrapper.ts
Outdated
|
||
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]; |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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", () => { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
src/shared/lib/URLWrapper.ts
Outdated
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented line
src/shared/lib/URLWrapper.ts
Outdated
@@ -39,6 +52,23 @@ export default class URLWrapper<QueryParamsType> { | |||
this.routing.updateRoute(query as any); | |||
} | |||
|
|||
private setProperty(property:Property<QueryParamsType>, query:QueryParamsType){ |
There was a problem hiding this comment.
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?
src/shared/lib/URLWrapper.ts
Outdated
} | ||
|
||
private _setPropertyAndHandleUndefined(property:Property<QueryParamsType>, value:string|undefined){ | ||
// @ts-ignore |
There was a problem hiding this comment.
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
src/shared/lib/URLWrapper.ts
Outdated
// 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]); |
There was a problem hiding this comment.
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
4db522e
to
1db3f28
Compare
…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]>
…h browser back/forward
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]>
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.