Skip to content

Commit

Permalink
Merge pull request #1042 from zhx828/fix-citation
Browse files Browse the repository at this point in the history
Replace CitationLink with SummaryWithRefs
  • Loading branch information
zhx828 authored Oct 31, 2023
2 parents 0ff9f5c + 90b0483 commit 2220099
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 54 deletions.
10 changes: 0 additions & 10 deletions src/main/webapp/app/config/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 4 additions & 2 deletions src/main/webapp/app/pages/genePage/GenePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -468,8 +469,9 @@ export default class GenePage extends React.Component<GenePageProps, any> {
show={this.showGeneBackground}
title={`${this.store.hugoSymbol} background`}
content={
<CitationLink
<SummaryWithRefs
content={this.store.geneBackground.result}
type="linkout"
/>
}
onClick={this.toggleGeneBackground}
Expand Down
42 changes: 0 additions & 42 deletions src/main/webapp/app/shared/utils/UrlUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 <PMIDLink pmids={match} />;
break;
}
case REGEXP.NCTID:
return (
<a
href={`${REGEXP_LINK[regexp]}${match}`}
target="_blank"
rel="noopener noreferrer"
>
${match}
</a>
);
break;
default:
return match;
break;
}
}
);
});
return <div>{contentWithLink}</div>;
};

export const OncoTreeLink: React.FunctionComponent<{}> = props => {
return (
<Linkout link={'http://oncotree.info'}>
Expand Down

0 comments on commit 2220099

Please sign in to comment.