-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enabled filtering for MutationRateSummary
Signed-off-by: Onur Sumer <s.onur.sumer@gmail.com>
- Loading branch information
Showing
4 changed files
with
161 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import {computed} from "mobx"; | ||
import {observer} from "mobx-react"; | ||
import * as React from 'react'; | ||
import { | ||
BadgeLabel, | ||
formatPercentValue, | ||
MutationStatusBadgeSelector, | ||
MutationStatusBadgeSelectorProps | ||
} from "react-mutation-mapper"; | ||
|
||
import DefaultTooltip from "public-lib/components/defaultTooltip/DefaultTooltip"; | ||
|
||
|
||
export function getFilterOptionLabel(content: {title: string, description?: string}): JSX.Element | string | ||
{ | ||
if (content.description) { | ||
return ( | ||
<span> | ||
{content.title} | ||
<DefaultTooltip | ||
placement="right" | ||
overlay={ | ||
<span>{content.description}</span> | ||
} | ||
> | ||
<i className="fa fa-info-circle" style={{marginLeft: "0.2rem"}} /> | ||
</DefaultTooltip> | ||
</span> | ||
); | ||
} | ||
else { | ||
return content.title; | ||
} | ||
} | ||
|
||
type MutationStatusSelectorProps = MutationStatusBadgeSelectorProps & { | ||
somaticContent: {title: string, description?: string}; | ||
germlineContent?: {title: string, description?: string}; | ||
}; | ||
|
||
@observer | ||
export default class MutationStatusSelector extends React.Component<MutationStatusSelectorProps, {}> | ||
{ | ||
@computed | ||
private get mutationStatusFilterOptions() | ||
{ | ||
const options = [ | ||
{ | ||
value: "Somatic", | ||
label: getFilterOptionLabel(this.props.somaticContent), | ||
badgeStyleOverride: {color: "#000", backgroundColor: "#FFF"} | ||
} | ||
]; | ||
|
||
if (this.props.germlineContent) | ||
{ | ||
options.push({ | ||
value: "Germline", | ||
label: getFilterOptionLabel(this.props.germlineContent), | ||
badgeStyleOverride: {color: "#000", backgroundColor: "#FFF"} | ||
}); | ||
} | ||
|
||
return options; | ||
} | ||
|
||
private get somaticInfo() | ||
{ | ||
return this.props.rates ? ( | ||
<BadgeLabel | ||
label={getFilterOptionLabel(this.props.somaticContent)} | ||
badgeContent={`${formatPercentValue(this.props.rates["Somatic"])}%`} | ||
badgeStyleOverride={this.mutationStatusFilterOptions[0].badgeStyleOverride} | ||
/> | ||
): null; | ||
} | ||
|
||
private get germlinePlaceholder() { | ||
return <div data-test='germlineMutationRate' className="invisible">%</div> | ||
} | ||
|
||
public render() | ||
{ | ||
// Render the actual selector only if germline content exists. | ||
// Otherwise just display the somatic info without a filter option. | ||
return this.props.germlineContent === undefined ? ( | ||
<React.Fragment> | ||
{this.somaticInfo} | ||
{this.germlinePlaceholder} | ||
</React.Fragment> | ||
): ( | ||
<MutationStatusBadgeSelector | ||
badgeSelectorOptions={this.mutationStatusFilterOptions} | ||
{...this.props} | ||
/> | ||
); | ||
} | ||
} |
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