-
Notifications
You must be signed in to change notification settings - Fork 318
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
Query component #107
Query component #107
Conversation
src/appShell/App/App.tsx
Outdated
} | ||
} | ||
} | ||
|
||
render () { | ||
return ( | ||
<Provider store={this.props.store}> | ||
<div style={{ height: '100%' }}> | ||
<div style={{ height: 700 }}> |
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.
why are we putting a fixed height on this?
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 was the easiest way to keep the contents on the screen - had a lot of trouble trying to make bootstrap do that. This change can be reverted.
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.
Yeah, I think this component itself should accept an optional fixed height prop, which would be put on its outermost el.
src/appShell/App/Container.tsx
Outdated
if (children.length == 1) | ||
return children[0]; | ||
|
||
return <div style={{width:"100%", height: "100%", flex: 1}}>{children}</div>; |
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.
What is the reason for the height, width here?
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.
Because I wanted it to fill the parent. Is there some problem?
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.
A couple things. This div does't actually seem to get rendered because, thus far, there's only every one child. Also, it's not clear to me why manipulating something at the app level would be necessary for the component you are building, which should be self contained and not care about it's surrounding circumstance. Lets remove this unless there's a demonstrable reason for it that I don't understand.
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 had to modify this file because the double nested divs that were previously being rendered were interfering with the layout of the child. Line 39 returns the child by itself, which fixes that issue. I added line 41 so the app would display something in the event of unexpected children content. We could throw an error instead if you prefer.
@@ -22,10 +24,10 @@ export default class DataSetPageUnconnected extends React.Component<IDatasetPage | |||
if (this.props.datasets) { | |||
const rows: Array<any> = []; | |||
this.props.datasets.forEach((item) => { | |||
const tempObj: any = { | |||
rows.push({ |
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.
jiaojiao will replace with unsafe with the custom column component
|
||
export class SampleLabelHTML extends React.Component { | ||
constructor(props) { | ||
export class SampleLabelHTML extends React.Component<ISampleLabelHTMLProps, void> { |
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.
curious why is the state interface set to void?
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.
void, {}, null and undefined are pretty much the same
@@ -40,15 +34,15 @@ export default class PatientHeader extends React.Component<IPatientHeaderProps, | |||
); | |||
} | |||
|
|||
private getPopoverPatient(patient: typeof _ClinicalInformationData.patient) { | |||
private getPopoverPatient(patient: ClinicalInformationData['patient']) { | |||
return patient && ( |
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.
sorry, can you remind me again with this is neccessary? the patient && ...
If patient is falsy, then it will return false, correct? But why is that desirable?
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.
TypeScript settings include strictNullChecks=true and the type of ClinicalInformationData['patient'] includes undefined. If we didn't have this check, it would crash when patient is 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.
You mean runtime or ts? Is there a legitimate reason for patient to be undefined? If not, it should crash or throw an error. If so, then it should be handled in the control flow. Sorry if I'm misunderstanding.
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 I said above, TypeScript settings include strictNullChecks=true and the type of ClinicalInformationData['patient'] includes undefined. This means TypeScript displays an error if you do not check for undefined.
src/shared/api/memoize.ts
Outdated
// dual-purpose setter/getter | ||
// note: does not work if subsequent calls vary the length of the keys array for the same cache param | ||
private traverse(cache:Cache<any, any>, keys:any[], value?:T):T|undefined { | ||
if (keys.length == 0) |
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.
is there a reason to use == instead of the strict ===?
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.
they are equivalent as long as the length value is a number.
src/shared/api/memoize.ts
Outdated
/** | ||
* Creates a memoized version of a function. | ||
*/ | ||
export default function memoize<F extends (...args:any[])=>any>(fn:F, getAdditionalMemoizeArgs:()=>any[]):F; |
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.
Could we use reselect instead of this? Reselect is documented, tested and widely used. https://github.com/reactjs/reselect. I mean, if there's a good reason to write our own, then by all means.
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.
Reselect only saves the last result (does not cache all results), does not use weak references to parameter values, and has awkward syntax.
renderStudyName = (name:string, study:CancerStudy) => { | ||
let checked = !!_.find(this.selectedStudies, id => id == study.cancerStudyIdentifier); | ||
return ( | ||
<Checkbox selected={false} onChange={this.getOnCheckHandler(study)} checked={checked}> |
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.
We should but the checkbox in a column of it's own, separate from the name of the study.
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 am following the mockup in this RFC:
https://docs.google.com/document/d/1scnR_uxf2Z8X6eqLzwG60rgO4EMtGofMXF0X6oZViaI/edit#
import {TypeOfCancer, CancerStudy} from "../../api/CBioPortalAPI"; | ||
import {ITreeDescriptor, default as DescriptorTreeNode} from "../tree/DescriptorTreeNode"; | ||
import * as ReactBootstrap from 'react-bootstrap'; | ||
import {BootstrapTable} from "react-bootstrap-table"; |
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 thought we discussed not using react-bootstrap-table? Ironically give it's name, it makes it hard to implement generic bootstrap style. My reasoning is that for simple tables, we want a component that doesn't get away from normal HTML table behavior. This one does because of the way it implements the header cells as a separate table, requiring columns to be of fixed width. Reactable (or MSKReactable) does not do this.
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 had already started using it when it was discussed and it is easy to swap out later. I spent minimal time working with the library.
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.
ok. admittedly the table component situation sucks. we're going to have to use FB's fixed data table (in fact our enhancement of it) for tables where performance is a factor because of huge # of rows/columns. it would be nice to keep this to a minimum.
id: k + '', | ||
})) | ||
.value(); | ||
const samples = _.map( |
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 actually find the initial chained code to be more readable. It's nice to avoid nesting and its nice to have the type right next to the variable we are populating.
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.
Me too but I was changing underscore code to lodash code and did not know the correct way to use chaining.
} | ||
|
||
renderStudyName = (name:string, study:CancerStudy) => { | ||
let checked = !!_.find(this.selectedStudies, id => id == study.cancerStudyIdentifier); |
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 above, the == enables type coercion. I've always understood that === is preferable unless we actually want coercion.
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.
In this case it makes no difference.
for (let link of links) | ||
{ | ||
if (children.length) | ||
children.push(<span> </span>) |
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 use css for padding of this nature
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'm letting @brittanystoroz handle the CSS.
color: black;/*test*/ | ||
} | ||
|
||
ul.cancerTypeTree ul { |
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.
you could nest these children in the above definition to avoir repetition
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.
Thanks. @brittanystoroz will be writing this file.
typings/missing.d.ts
Outdated
@@ -5,3 +5,4 @@ declare module 'react-file-download'; | |||
declare module 'react-zeroclipboard'; | |||
declare module 'reactableMSK'; | |||
declare module 'redux-seamless-immutable'; |
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.
does typescript 2.1 with implicit any mean we don't need the missing file anymore? Do you recommend at it be on or off (on by default, right?)?
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.
noImplicitAny is very useful and should remain on, which means we need to declare these modules.
this.state = {}; | ||
} | ||
|
||
onExpand = () => |
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.
is this a way of getting around binding issue?
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.
actually, it looks like this isn't used, right? onExpand seems to come from props
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 binding is required because the function is passed to a subcomponent.
<FontAwesome | ||
name={expand ? 'caret-down' : 'caret-right'} | ||
style={arrowStyle} | ||
onMouseDown={this.onExpand} |
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.
hmmm. it is used here.
|
||
@memoizeWith(function() { return [this.props.cancerTypes, this.props.studies] }) | ||
getTreeDescriptor():ITreeDescriptor<TypeOfCancer|CancerStudy> & {rootNode: TypeOfCancer, setExpanded: (node:Node, value:boolean) => void} { | ||
let { |
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.
some inconsistent indentation in this file. that is one linting task i think is important. otherwise things get very unreadable fast. it's important that people be able to use the IDE reformat and that it aligns with linting
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.
indentation already addressed in latest commit
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 am fine having a script that normalizes the indentation but it is anti-productive to worry about it while writing code.
src/globalStyles/global.scss
Outdated
|
||
/* makes react-bootstrap-table work in flexbox layout */ | ||
.react-bs-table-container,.react-bs-table,.react-bs-container-body { |
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.
Putting aside whether we use react-bs-table or not, this would be better applied to the component instance itself.
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 will move this to a better location
src/appShell/App/Container.tsx
Outdated
|
||
// don't create extra div elements if there is only one child | ||
if (children.length == 1) | ||
return children[0]; |
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.
We just need to set this back to what it was. I don't think there is a reason that nested parent divs should cause a problem for the layout you are trying to achieve. I'm happy to help address the underlying layout issue.
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.
Why do we need to change this back? The new code is better. Why do you want two divs surrounding the child?
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.
There shouldn't sometimes be a wrapping div at this level and not other times. If there's only ever one child then lets just change the code. More than anything else though, the fact that a change was made here is a flag that there is a deeper confusion. Instead of changing something global, lets try to resolve that local confusion.
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.
Like I said, we can throw an error when there is more than one child if you prefer.
Here's a screenshot of what it shows with two wrapping divs: http://image.prntscr.com/image/7ef4209fefca47f88ce4b8ab5187c694.png
Here's a screenshot of what it shows with no wrapping div: http://image.prntscr.com/image/a966d92465154f93996fd90f6d39d8e9.png
Remove DevMode code
Added options to explicitly set selected values and customize label
More changes for patient view mutations tab
More changes for patient view mutations tab
More changes for patient view mutations tab
More changes for patient view mutations tab
More changes for patient view mutations tab
More changes for patient view mutations tab
More changes for patient view mutations tab
More changes for patient view mutations tab
More changes for patient view mutations tab
More changes for patient view mutations tab
More changes for patient view mutations tab
More changes for patient view mutations tab
More changes for patient view mutations tab
More changes for patient view mutations tab
More changes for patient view mutations tab
More changes for patient view mutations tab
What? Why?
Replacement query component which is used on the homepage and can also be embedded in other pages for modifying the query.
Checks
can be automatically added by git if you run the
git-commit
command withthe
-s
option)Any screenshots or GIFs?
If this is a new visual feature please add a before/after screenshot or gif
here with e.g. GifGrabber.
Notify reviewers
Read our Pull request merging
policy. If you are part of the
cBioPortal organization, notify the approprate team (remove inappropriate):
@cBioPortal/frontend
If you are not part of the cBioPortal organization look at who worked on the
file before you. Please use
git blame <filename>
to determine thatand notify them here: