|
| 1 | +import React from 'react'; |
| 2 | +import { observer } from 'mobx-react'; |
| 3 | + |
| 4 | +import { OncoTreeLink } from 'app/shared/utils/UrlUtils'; |
| 5 | +import { |
| 6 | + ANNOTATION_PAGE_TAB_KEYS, |
| 7 | + DEFAULT_MARGIN_BOTTOM_LG, |
| 8 | + OTHER_BIOMARKERS, |
| 9 | +} from 'app/config/constants'; |
| 10 | +import styles from 'app/pages/alterationPage/AlterationPage.module.scss'; |
| 11 | +import InfoIcon from 'app/shared/icons/InfoIcon'; |
| 12 | +import { Col, Row } from 'react-bootstrap'; |
| 13 | +import classnames from 'classnames'; |
| 14 | +import { action, computed } from 'mobx'; |
| 15 | +import autobind from 'autobind-decorator'; |
| 16 | +import { |
| 17 | + BiologicalVariant, |
| 18 | + VariantAnnotation, |
| 19 | +} from 'app/shared/api/generated/OncoKbPrivateAPI'; |
| 20 | +import { |
| 21 | + FdaImplication, |
| 22 | + TherapeuticImplication, |
| 23 | +} from 'app/store/AnnotationStore'; |
| 24 | +import { isCategoricalAlteration } from 'app/shared/utils/Utils'; |
| 25 | +import CancerTypeSelect from 'app/shared/dropdown/CancerTypeSelect'; |
| 26 | +import AlterationTableTabs from 'app/pages/annotationPage/AlterationTableTabs'; |
| 27 | +import { getSummaries, SummaryKey } from 'app/pages/annotationPage/Utils'; |
| 28 | +import AppStore from 'app/store/AppStore'; |
| 29 | +import { Alteration } from 'app/shared/api/generated/OncoKbAPI'; |
| 30 | + |
| 31 | +export type IAlterationView = { |
| 32 | + appStore?: AppStore; |
| 33 | + hugoSymbol: string; |
| 34 | + alteration: string; |
| 35 | + matchedAlteration: Alteration | undefined; |
| 36 | + tumorType: string; |
| 37 | + onChangeTumorType: (newTumorType: string) => void; |
| 38 | + annotation: VariantAnnotation; |
| 39 | + biologicalAlterations?: BiologicalVariant[]; |
| 40 | + relevantAlterations?: Alteration[]; |
| 41 | + fdaImplication: FdaImplication[]; |
| 42 | + therapeuticImplications: TherapeuticImplication[]; |
| 43 | + diagnosticImplications: TherapeuticImplication[]; |
| 44 | + prognosticImplications: TherapeuticImplication[]; |
| 45 | + defaultSelectedTab?: ANNOTATION_PAGE_TAB_KEYS; |
| 46 | + onChangeTab?: ( |
| 47 | + selectedTabKey: ANNOTATION_PAGE_TAB_KEYS, |
| 48 | + newTabKey: ANNOTATION_PAGE_TAB_KEYS |
| 49 | + ) => void; |
| 50 | +}; |
| 51 | +@observer |
| 52 | +export default class SomaticGermlineAlterationView extends React.Component< |
| 53 | + IAlterationView, |
| 54 | + {} |
| 55 | +> { |
| 56 | + @autobind |
| 57 | + @action |
| 58 | + updateTumorTypeQuery(selectedOption: any) { |
| 59 | + this.props.onChangeTumorType(selectedOption ? selectedOption.value : ''); |
| 60 | + } |
| 61 | + |
| 62 | + @computed |
| 63 | + get tumorTypeSummaries() { |
| 64 | + const orderedSummaries = this.props.tumorType |
| 65 | + ? [ |
| 66 | + SummaryKey.TUMOR_TYPE_SUMMARY, |
| 67 | + SummaryKey.DIAGNOSTIC_SUMMARY, |
| 68 | + SummaryKey.PROGNOSTIC_SUMMARY, |
| 69 | + ] |
| 70 | + : []; |
| 71 | + return getSummaries(this.props.annotation, orderedSummaries); |
| 72 | + } |
| 73 | + |
| 74 | + @computed get isCategoricalAlteration() { |
| 75 | + return isCategoricalAlteration(this.props.alteration); |
| 76 | + } |
| 77 | + |
| 78 | + @computed |
| 79 | + get showGeneNameLink() { |
| 80 | + const lHugo = this.props.hugoSymbol.toLowerCase(); |
| 81 | + const altNameIncludesGene = this.props.alteration |
| 82 | + .toLowerCase() |
| 83 | + .includes(lHugo); |
| 84 | + const isOtherBiomarkers = lHugo === OTHER_BIOMARKERS.toLowerCase(); |
| 85 | + return !altNameIncludesGene && !isOtherBiomarkers; |
| 86 | + } |
| 87 | + |
| 88 | + @computed |
| 89 | + get relevantBiologicalVariants(): BiologicalVariant[] { |
| 90 | + if ( |
| 91 | + this.isCategoricalAlteration && |
| 92 | + this.props.biologicalAlterations && |
| 93 | + this.props.relevantAlterations |
| 94 | + ) { |
| 95 | + const relevantAltNames = this.props.relevantAlterations.map( |
| 96 | + alt => alt.alteration |
| 97 | + ); |
| 98 | + return this.props.biologicalAlterations.filter(variant => |
| 99 | + relevantAltNames.includes(variant.variant.alteration) |
| 100 | + ); |
| 101 | + } else { |
| 102 | + return []; |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + render() { |
| 107 | + const dropdownColor = '#0968C3'; |
| 108 | + return ( |
| 109 | + <> |
| 110 | + <Row className="mt-4"> |
| 111 | + <Col> |
| 112 | + <div |
| 113 | + className={classnames( |
| 114 | + 'd-flex', |
| 115 | + 'align-items-center', |
| 116 | + 'justify-content-left', |
| 117 | + 'flex-wrap', |
| 118 | + DEFAULT_MARGIN_BOTTOM_LG |
| 119 | + )} |
| 120 | + > |
| 121 | + <span className={classnames('mr-3', 'h6')}> |
| 122 | + Filter this list by: |
| 123 | + </span> |
| 124 | + <span |
| 125 | + className={classnames(styles.headerTumorTypeSelection, 'mr-2')} |
| 126 | + > |
| 127 | + <span> |
| 128 | + <CancerTypeSelect |
| 129 | + styles={{ |
| 130 | + control: base => ({ |
| 131 | + ...base, |
| 132 | + height: '30px', |
| 133 | + minHeight: '30px', |
| 134 | + borderBottomWidth: '1px', |
| 135 | + borderBottomColor: dropdownColor, |
| 136 | + borderStyle: 'none', |
| 137 | + borderBottomStyle: 'solid', |
| 138 | + borderRadius: '0px', |
| 139 | + '&:hover': { |
| 140 | + borderBottomColor: dropdownColor, |
| 141 | + }, |
| 142 | + }), |
| 143 | + indicatorsContainer: base => ({ |
| 144 | + ...base, |
| 145 | + '& div': { |
| 146 | + color: dropdownColor, |
| 147 | + }, |
| 148 | + '& div:hover': { |
| 149 | + color: dropdownColor, |
| 150 | + }, |
| 151 | + }), |
| 152 | + indicatorSeparator: base => ({ |
| 153 | + ...base, |
| 154 | + width: '0px', |
| 155 | + }), |
| 156 | + dropdownIndicator: base => ({ |
| 157 | + ...base, |
| 158 | + padding: 4, |
| 159 | + }), |
| 160 | + clearIndicator: base => ({ |
| 161 | + ...base, |
| 162 | + padding: 4, |
| 163 | + }), |
| 164 | + valueContainer: base => ({ |
| 165 | + ...base, |
| 166 | + padding: '0px 6px', |
| 167 | + }), |
| 168 | + input: base => ({ |
| 169 | + ...base, |
| 170 | + margin: 0, |
| 171 | + padding: 0, |
| 172 | + }), |
| 173 | + menu: base => ({ ...base, zIndex: 10 }), |
| 174 | + }} |
| 175 | + cancerType={this.props.tumorType} |
| 176 | + onChange={(selectedOption: any) => |
| 177 | + this.updateTumorTypeQuery(selectedOption) |
| 178 | + } |
| 179 | + /> |
| 180 | + </span> |
| 181 | + </span> |
| 182 | + <InfoIcon |
| 183 | + overlay={ |
| 184 | + <span> |
| 185 | + For cancer type specific information, please select a cancer |
| 186 | + type from the dropdown. The cancer type is curated using{' '} |
| 187 | + <OncoTreeLink /> |
| 188 | + </span> |
| 189 | + } |
| 190 | + placement="top" |
| 191 | + /> |
| 192 | + </div> |
| 193 | + </Col> |
| 194 | + </Row> |
| 195 | + {this.props.tumorType && !this.isCategoricalAlteration ? ( |
| 196 | + <Row> |
| 197 | + <Col> |
| 198 | + {this.tumorTypeSummaries.map((summary, index) => { |
| 199 | + return ( |
| 200 | + <div |
| 201 | + className={DEFAULT_MARGIN_BOTTOM_LG} |
| 202 | + key={`summary-${index}`} |
| 203 | + > |
| 204 | + <h6 className={'mb-0'}>{summary.title}</h6> |
| 205 | + {summary.content} |
| 206 | + </div> |
| 207 | + ); |
| 208 | + })} |
| 209 | + </Col> |
| 210 | + </Row> |
| 211 | + ) : null} |
| 212 | + <Row className="mt-2"> |
| 213 | + <Col> |
| 214 | + <AlterationTableTabs |
| 215 | + selectedTab={this.props.defaultSelectedTab} |
| 216 | + appStore={this.props.appStore} |
| 217 | + hugoSymbol={this.props.hugoSymbol} |
| 218 | + alteration={ |
| 219 | + this.props.matchedAlteration |
| 220 | + ? { |
| 221 | + alteration: this.props.matchedAlteration.alteration, |
| 222 | + name: this.props.matchedAlteration.name, |
| 223 | + } |
| 224 | + : { |
| 225 | + alteration: this.props.alteration, |
| 226 | + name: this.props.alteration, |
| 227 | + } |
| 228 | + } |
| 229 | + cancerType={this.props.tumorType} |
| 230 | + biological={[]} |
| 231 | + tx={this.props.therapeuticImplications} |
| 232 | + dx={this.props.diagnosticImplications} |
| 233 | + px={this.props.prognosticImplications} |
| 234 | + fda={this.props.fdaImplication} |
| 235 | + onChangeTab={this.props.onChangeTab} |
| 236 | + /> |
| 237 | + </Col> |
| 238 | + </Row> |
| 239 | + </> |
| 240 | + ); |
| 241 | + } |
| 242 | +} |
0 commit comments