-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated type of sampleToMutationGenePanelId
- Loading branch information
Ngoc Nguyen
committed
Oct 1, 2019
1 parent
2873027
commit fd3d777
Showing
3 changed files
with
59 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 57 additions & 30 deletions
87
src/shared/components/mutationTable/column/PanelColumnFormatter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,67 @@ | ||
import * as React from 'react'; | ||
import {Mutation, DiscreteCopyNumberData} from "shared/api/generated/CBioPortalAPI"; | ||
import { | ||
Mutation, | ||
DiscreteCopyNumberData | ||
} from 'shared/api/generated/CBioPortalAPI'; | ||
|
||
interface PanelColumnFormatterProps { | ||
data: Mutation[] | DiscreteCopyNumberData[], | ||
sampleToMutationGenePanelId: any, | ||
data: Mutation[] | DiscreteCopyNumberData[]; | ||
sampleToMutationGenePanelId: {[sampleId:string]: string} | undefined; | ||
} | ||
|
||
class PanelColumn extends React.Component<PanelColumnFormatterProps,{}> { | ||
constructor(props:PanelColumnFormatterProps) { | ||
super(props); | ||
} | ||
|
||
render() { | ||
const {data, sampleToMutationGenePanelId} = this.props; | ||
|
||
if (!Object.keys(sampleToMutationGenePanelId).length) { | ||
return <i className='fa fa-spinner fa-pulse'/>; | ||
} | ||
|
||
const genePanelIds:string[] = getGenePanelIds(data, sampleToMutationGenePanelId); | ||
class PanelColumn extends React.Component<PanelColumnFormatterProps, {}> { | ||
constructor(props: PanelColumnFormatterProps) { | ||
super(props); | ||
} | ||
|
||
render() { | ||
const { data, sampleToMutationGenePanelId } = this.props; | ||
|
||
return ( | ||
<div style={{position:'relative'}}> | ||
<ul style={{marginBottom:0}} className="list-inline list-unstyled">{ genePanelIds.join(', ') }</ul> | ||
</div> | ||
) | ||
} | ||
} | ||
if (!sampleToMutationGenePanelId) return; | ||
|
||
const getGenePanelIds = (data:any[], sampleToMutationGenePanelId:any) => { | ||
const sampleIds = data.map(datum => datum.sampleId); | ||
return sampleIds.map(id => sampleToMutationGenePanelId[id]); | ||
if (sampleToMutationGenePanelId && !Object.keys(sampleToMutationGenePanelId).length) { | ||
return <i className='fa fa-spinner fa-pulse' />; | ||
} | ||
|
||
const genePanelIds: string[] = getGenePanelIds( | ||
data, | ||
sampleToMutationGenePanelId | ||
); | ||
|
||
return ( | ||
<div style={{ position: 'relative' }}> | ||
<ul style={{ marginBottom: 0 }} className='list-inline list-unstyled'> | ||
{genePanelIds.join(', ')} | ||
</ul> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
const getGenePanelIds = ( | ||
data: any[], | ||
sampleToMutationGenePanelId: {[sampleId:string]: string} | undefined | ||
) => { | ||
if (sampleToMutationGenePanelId) { | ||
const sampleIds = data.map((datum) => datum.sampleId); | ||
return sampleIds.map((id) => sampleToMutationGenePanelId[id]); | ||
} | ||
return []; | ||
}; | ||
|
||
export default { | ||
renderFunction: (data:Mutation[] | DiscreteCopyNumberData[], sampleToMutationGenePanelId:any) => <PanelColumn data={data} sampleToMutationGenePanelId={sampleToMutationGenePanelId}/>, | ||
download: (data:Mutation[] | DiscreteCopyNumberData[], sampleToMutationGenePanelId:any) => getGenePanelIds(data, sampleToMutationGenePanelId), | ||
getGenePanelIds | ||
} | ||
renderFunction: ( | ||
data: Mutation[] | DiscreteCopyNumberData[], | ||
sampleToMutationGenePanelId: {[sampleId:string]: string} | undefined | ||
) => ( | ||
<PanelColumn | ||
data={data} | ||
sampleToMutationGenePanelId={sampleToMutationGenePanelId} | ||
/> | ||
), | ||
download: ( | ||
data: Mutation[] | DiscreteCopyNumberData[], | ||
sampleToMutationGenePanelId: {[sampleId:string]: string} | undefined | ||
) => getGenePanelIds(data, sampleToMutationGenePanelId), | ||
getGenePanelIds | ||
}; |