From 90b0483116a43782901b2aeb0078de1e1ccaa65a Mon Sep 17 00:00:00 2001 From: Hongxin <5400599+zhx828@users.noreply.github.com> Date: Tue, 31 Oct 2023 11:04:13 -0500 Subject: [PATCH] Replace CitationLink with SummaryWithRefs --- src/main/webapp/app/config/constants.tsx | 10 ----- .../webapp/app/pages/genePage/GenePage.tsx | 6 ++- src/main/webapp/app/shared/utils/UrlUtils.tsx | 42 ------------------- 3 files changed, 4 insertions(+), 54 deletions(-) diff --git a/src/main/webapp/app/config/constants.tsx b/src/main/webapp/app/config/constants.tsx index e6428fd17..7bb2f4d34 100644 --- a/src/main/webapp/app/config/constants.tsx +++ b/src/main/webapp/app/config/constants.tsx @@ -886,16 +886,6 @@ export const NOT_CHANGEABLE_AUTHORITIES = [ USER_AUTHORITY.ROLE_PUBLIC_WEBSITE, ]; -export enum REGEXP { - PMID = 'PMID:\\s*([0-9]+,*\\s*)+', - NCTID = 'NCT[0-9]+', -} - -export const REGEXP_LINK: { [key: string]: string } = { - [REGEXP.PMID]: 'https://www.ncbi.nlm.nih.gov/pubmed/', - [REGEXP.NCTID]: 'http://clinicaltrials.gov/show/', -}; - export enum REFERENCE_GENOME { GRCh37 = 'GRCh37', GRCh38 = 'GRCh38', diff --git a/src/main/webapp/app/pages/genePage/GenePage.tsx b/src/main/webapp/app/pages/genePage/GenePage.tsx index 4e6b20098..3d6c51a9c 100644 --- a/src/main/webapp/app/pages/genePage/GenePage.tsx +++ b/src/main/webapp/app/pages/genePage/GenePage.tsx @@ -36,7 +36,7 @@ import { REFERENCE_GENOME, } from 'app/config/constants'; import { ClinicalVariant } from 'app/shared/api/generated/OncoKbPrivateAPI'; -import { AlterationPageLink, CitationLink } from 'app/shared/utils/UrlUtils'; +import { AlterationPageLink } from 'app/shared/utils/UrlUtils'; import AppStore from 'app/store/AppStore'; import _ from 'lodash'; import { MskimpactLink } from 'app/components/MskimpactLink'; @@ -61,6 +61,7 @@ import OncokbLollipopPlot from './OncokbLollipopPlot'; import { getUniqueFdaImplications } from 'app/pages/annotationPage/Utils'; import ShowHideText from 'app/shared/texts/ShowHideText'; import { AnnotationType } from 'app/pages/annotationPage/AnnotationPage'; +import SummaryWithRefs from 'app/oncokb-frontend-commons/src/components/SummaryWithRefs'; interface MatchParams { hugoSymbol: string; @@ -468,8 +469,9 @@ export default class GenePage extends React.Component { show={this.showGeneBackground} title={`${this.store.hugoSymbol} background`} content={ - } onClick={this.toggleGeneBackground} diff --git a/src/main/webapp/app/shared/utils/UrlUtils.tsx b/src/main/webapp/app/shared/utils/UrlUtils.tsx index fec02db52..91f17ace8 100644 --- a/src/main/webapp/app/shared/utils/UrlUtils.tsx +++ b/src/main/webapp/app/shared/utils/UrlUtils.tsx @@ -5,15 +5,9 @@ import { ONCOKB_TM, PAGE_ROUTE, REFERENCE_GENOME, - REGEXP, - REGEXP_LINK, SOP_LINK, YOUTUBE_VIDEO_IDS, } from 'app/config/constants'; -import _ from 'lodash'; -import { PMIDLink } from 'app/shared/links/PMIDLink'; -import reactStringReplace from 'react-string-replace'; -import { ReactNodeArray } from 'prop-types'; import { encodeSlash, getAlterationName, @@ -195,42 +189,6 @@ export const MSILink: React.FunctionComponent<{}> = () => { ); }; -export const CitationLink: React.FunctionComponent<{ - content: string; -}> = props => { - const regexps = [REGEXP.PMID, REGEXP.NCTID]; - let contentWithLink: ReactNodeArray = [props.content]; - _.forEach(regexps, regexp => { - contentWithLink = reactStringReplace( - contentWithLink, - new RegExp(regexp, 'ig'), - (match, i) => { - switch (regexp) { - case REGEXP.PMID: { - return ; - break; - } - case REGEXP.NCTID: - return ( - - ${match} - - ); - break; - default: - return match; - break; - } - } - ); - }); - return
{contentWithLink}
; -}; - export const OncoTreeLink: React.FunctionComponent<{}> = props => { return (