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

Query component #107

Closed
wants to merge 133 commits into from
Closed

Query component #107

wants to merge 133 commits into from

Conversation

adufilie
Copy link
Contributor

@adufilie adufilie commented Dec 9, 2016

What? Why?

Replacement query component which is used on the homepage and can also be embedded in other pages for modifying the query.

Checks

  • Follows 7 rules of great commit messages. For most PRs a single commit should suffice, in some cases multiple topical commits can be useful. During review it is ok to see tiny commits (e.g. Fix reviewer comments), but right before the code gets merged to master or rc branch, any such commits should be squashed since they are useless to the other developers. Definitely avoid merge commits, use rebase instead.
  • Follows the Airbnb React/JSX Style guide.
  • Make sure your commit messages end with a Signed-off-by string (this line
    can be automatically added by git if you run the git-commit command with
    the -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 that
and notify them here:

@jjgao jjgao temporarily deployed to cbioportal-frontend-pr-107 December 9, 2016 19:14 Inactive
@jjgao jjgao temporarily deployed to cbioportal-frontend-pr-107 December 9, 2016 21:51 Inactive
}
}
}

render () {
return (
<Provider store={this.props.store}>
<div style={{ height: '100%' }}>
<div style={{ height: 700 }}>
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

if (children.length == 1)
return children[0];

return <div style={{width:"100%", height: "100%", flex: 1}}>{children}</div>;
Copy link
Collaborator

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?

Copy link
Contributor Author

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?

Copy link
Collaborator

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.

Copy link
Contributor Author

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({
Copy link
Collaborator

@alisman alisman Dec 12, 2016

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> {
Copy link
Collaborator

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?

Copy link
Contributor Author

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 && (
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

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.

// 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)
Copy link
Collaborator

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 ===?

Copy link
Contributor Author

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.

/**
* Creates a memoized version of a function.
*/
export default function memoize<F extends (...args:any[])=>any>(fn:F, getAdditionalMemoizeArgs:()=>any[]):F;
Copy link
Collaborator

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.

Copy link
Contributor Author

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}>
Copy link
Collaborator

@alisman alisman Dec 12, 2016

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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";
Copy link
Collaborator

@alisman alisman Dec 12, 2016

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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(
Copy link
Collaborator

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.

Copy link
Contributor Author

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);
Copy link
Collaborator

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.

Copy link
Contributor Author

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>&nbsp;</span>)
Copy link
Collaborator

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

Copy link
Contributor Author

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 {
Copy link
Collaborator

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

Copy link
Contributor Author

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.

@jjgao jjgao temporarily deployed to cbioportal-frontend-pr-107 December 12, 2016 16:02 Inactive
@@ -5,3 +5,4 @@ declare module 'react-file-download';
declare module 'react-zeroclipboard';
declare module 'reactableMSK';
declare module 'redux-seamless-immutable';
Copy link
Collaborator

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?)?

Copy link
Contributor Author

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 = () =>
Copy link
Collaborator

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?

Copy link
Collaborator

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

Copy link
Contributor Author

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}
Copy link
Collaborator

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 {
Copy link
Collaborator

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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.


/* makes react-bootstrap-table work in flexbox layout */
.react-bs-table-container,.react-bs-table,.react-bs-container-body {
Copy link
Collaborator

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.

Copy link
Contributor Author

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


// don't create extra div elements if there is only one child
if (children.length == 1)
return children[0];
Copy link
Collaborator

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.

Copy link
Contributor Author

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?

Copy link
Collaborator

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.

Copy link
Contributor Author

@adufilie adufilie Dec 12, 2016

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

@jjgao jjgao temporarily deployed to cbioportal-frontend-pr-107 December 12, 2016 19:04 Inactive
@jjgao jjgao temporarily deployed to cbioportal-frontend-pr-107 December 12, 2016 19:34 Inactive
@jjgao jjgao temporarily deployed to cbioportal-frontend-pr-107 December 12, 2016 19:46 Inactive
@jjgao jjgao temporarily deployed to cbioportal-frontend-pr-107 April 24, 2017 19:12 Inactive
@jjgao jjgao temporarily deployed to cbioportal-frontend-pr-107 April 24, 2017 20:41 Inactive
@alisman alisman closed this May 19, 2017
@alisman alisman reopened this May 24, 2017
@jjgao jjgao temporarily deployed to cbioportal-frontend-pr-107 May 24, 2017 22:05 Inactive
@alisman alisman closed this May 25, 2017
onursumer added a commit to onursumer/cbioportal-frontend that referenced this pull request Dec 18, 2019
Added options to explicitly set selected values and customize label
onursumer pushed a commit to onursumer/cbioportal-frontend that referenced this pull request May 11, 2022
More changes for patient view mutations tab
onursumer pushed a commit to onursumer/cbioportal-frontend that referenced this pull request May 16, 2022
More changes for patient view mutations tab
onursumer pushed a commit to onursumer/cbioportal-frontend that referenced this pull request May 18, 2022
More changes for patient view mutations tab
onursumer pushed a commit to onursumer/cbioportal-frontend that referenced this pull request May 19, 2022
More changes for patient view mutations tab
onursumer pushed a commit to onursumer/cbioportal-frontend that referenced this pull request May 20, 2022
More changes for patient view mutations tab
onursumer pushed a commit to onursumer/cbioportal-frontend that referenced this pull request May 23, 2022
More changes for patient view mutations tab
onursumer pushed a commit to onursumer/cbioportal-frontend that referenced this pull request May 24, 2022
More changes for patient view mutations tab
onursumer pushed a commit to onursumer/cbioportal-frontend that referenced this pull request May 25, 2022
More changes for patient view mutations tab
onursumer pushed a commit to onursumer/cbioportal-frontend that referenced this pull request May 26, 2022
More changes for patient view mutations tab
onursumer pushed a commit to onursumer/cbioportal-frontend that referenced this pull request May 27, 2022
More changes for patient view mutations tab
onursumer pushed a commit to onursumer/cbioportal-frontend that referenced this pull request May 27, 2022
More changes for patient view mutations tab
onursumer pushed a commit to onursumer/cbioportal-frontend that referenced this pull request May 27, 2022
More changes for patient view mutations tab
alisman pushed a commit to alisman/cbioportal-frontend that referenced this pull request Jun 2, 2022
More changes for patient view mutations tab
onursumer pushed a commit to onursumer/cbioportal-frontend that referenced this pull request Jun 6, 2022
More changes for patient view mutations tab
onursumer pushed a commit to onursumer/cbioportal-frontend that referenced this pull request Jun 6, 2022
More changes for patient view mutations tab
alisman pushed a commit to onursumer/cbioportal-frontend that referenced this pull request Jun 8, 2022
More changes for patient view mutations tab
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.

8 participants