Skip to content

Commit

Permalink
Include 2023 year end summary && Move YES page to About page (#1076)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhx828 authored Jan 16, 2024
1 parent 8a06eca commit 46f782c
Show file tree
Hide file tree
Showing 14 changed files with 533 additions and 130 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions src/main/webapp/app/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,13 @@ class Header extends React.Component<IHeaderProps> {
PAGE_ROUTE.TEAM,
PAGE_ROUTE.FDA_RECOGNITION,
PAGE_ROUTE.SOP,
PAGE_ROUTE.YEAR_END_SUMMARY,
],
},
{ title: 'News', link: PAGE_ROUTE.NEWS },
{
title: 'News',
link: PAGE_ROUTE.NEWS,
matchedPaths: [PAGE_ROUTE.NEWS, PAGE_ROUTE.YEAR_END_SUMMARY],
},
{ title: 'FAQ', link: PAGE_ROUTE.FAQ_ACCESS },
];

Expand Down
77 changes: 6 additions & 71 deletions src/main/webapp/app/pages/aboutGroup/AboutPageNavTab.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import * as React from 'react';
import { Row, Col, Tab, Nav } from 'react-bootstrap';
import { Col, Nav, Row, Tab } from 'react-bootstrap';
import AppStore from 'app/store/AppStore';
import { inject, observer } from 'mobx-react';
import { ONCOKB_TM, PAGE_ROUTE, PAGE_TITLE } from 'app/config/constants';
import { observable, IReactionDisposer, reaction, computed } from 'mobx';
import { computed, IReactionDisposer, observable, reaction } from 'mobx';
import { RouterStore } from 'mobx-react-router';
import { AboutPage } from 'app/pages/AboutPage';
import { TeamPage } from 'app/pages/teamPage/TeamPage';
import Iframe from 'react-iframe';
import FdaRecognitionPage from 'app/pages/aboutGroup/FdaRecognitionPage';
import { YearEndSummaryPage } from 'app/pages/yearEndSummaryPage/YearEndSummaryPage';
import { LocationDescriptorObject } from 'history';
import classnames from 'classnames';
import DocumentTitle from 'react-document-title';
Expand All @@ -22,10 +21,8 @@ export enum TabKey {
TEAM = PAGE_ROUTE.TEAM,
FDA_RECOGNITION = PAGE_ROUTE.FDA_RECOGNITION,
SOP = PAGE_ROUTE.SOP,
YEAR_END_SUMMARY = PAGE_ROUTE.YEAR_END_SUMMARY,
}

export const YEAR_END_SUMMARY_RANGE = ['2022'] as const;
const YEAR_END_SUMMARY_KEY_DIVIDER = '+';

@inject('appStore', 'routing')
Expand All @@ -49,13 +46,7 @@ export class AboutPageNavTab extends React.Component<AboutPageNavTabProps> {
() => [props.routing.location.pathname],
([pathName]) => {
const lowerCasePathName = pathName.toLowerCase();
if (
lowerCasePathName.startsWith(PAGE_ROUTE.YEAR_END_SUMMARY) &&
props.routing.location.hash
) {
const year = props.routing.location.hash.slice(1);
this.selectedTab = this.getYearEndSummaryEventKey(year);
} else if (Object.keys(TabKey).includes(lowerCasePathName)) {
if (Object.keys(TabKey).includes(lowerCasePathName)) {
this.selectedTab = lowerCasePathName;
}
},
Expand All @@ -69,35 +60,9 @@ export class AboutPageNavTab extends React.Component<AboutPageNavTabProps> {
}

getHistoryBySelectedTab(newSelectedTab: string): LocationDescriptorObject {
if (newSelectedTab.startsWith(PAGE_ROUTE.YEAR_END_SUMMARY)) {
const location: LocationDescriptorObject = {
pathname: PAGE_ROUTE.YEAR_END_SUMMARY,
};
const year = this.parseYearEndSummaryEventKey(newSelectedTab);
if (year !== undefined) {
location.hash = `#${year}`;
}
return location;
} else {
return {
pathname: newSelectedTab,
};
}
}

getYearEndSummaryEventKey(year: string | undefined) {
return `${TabKey.YEAR_END_SUMMARY}${
year ? YEAR_END_SUMMARY_KEY_DIVIDER + year : ''
}`;
}

parseYearEndSummaryEventKey(eventKey: string): string | undefined {
const components = eventKey.split(YEAR_END_SUMMARY_KEY_DIVIDER);
if (components.length <= 1) {
return undefined;
} else {
return components[1];
}
return {
pathname: newSelectedTab,
};
}

componentWillUnmount() {
Expand Down Expand Up @@ -139,20 +104,6 @@ export class AboutPageNavTab extends React.Component<AboutPageNavTabProps> {
<Nav.Item>
<Nav.Link eventKey={TabKey.SOP}>SOP</Nav.Link>
</Nav.Item>
<Nav.Item>
<Nav.Link eventKey={TabKey.YEAR_END_SUMMARY}>
{PAGE_TITLE.YEAR_END_SUMMARY}
</Nav.Link>
</Nav.Item>
{this.inYearEndSummarySection &&
YEAR_END_SUMMARY_RANGE.map(year => {
const key = this.getYearEndSummaryEventKey(year);
return (
<Nav.Item key={key}>
<Nav.Link eventKey={key}>{year}</Nav.Link>
</Nav.Item>
);
})}
</Nav>
</Col>
<Col sm={10}>
Expand Down Expand Up @@ -188,22 +139,6 @@ export class AboutPageNavTab extends React.Component<AboutPageNavTabProps> {
</div>
</DocumentTitle>
</Tab.Pane>
<Tab.Pane
eventKey={TabKey.YEAR_END_SUMMARY}
key={TabKey.YEAR_END_SUMMARY}
unmountOnExit
>
<YearEndSummaryPage />
</Tab.Pane>
{this.inYearEndSummarySection &&
YEAR_END_SUMMARY_RANGE.map(year => {
const key = this.getYearEndSummaryEventKey(year);
return (
<Tab.Pane eventKey={key} key={key} unmountOnExit>
<YearEndSummaryPage selectedYear={year} />
</Tab.Pane>
);
})}
</Tab.Content>
</Col>
</Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const ChangedAnnotationListItem = (props: {
if (linkableMutationName(geneInput, mutationInput)) {
row.content[mutationColumnIndex].content = (
<AlterationPageLink
key={`${geneInput}-${mutationInput}`}
hugoSymbol={geneInput}
alteration={mutationInput}
/>
Expand Down
5 changes: 4 additions & 1 deletion src/main/webapp/app/pages/newsPage/NewsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export default class NewsPage extends React.Component<{
const id = this.props.routing.location.hash.slice(1);
const element = document.getElementById(id);
scrollWidthOffset(element);
}, 500);
}, 200);
} else {
window.scrollTo({ top: 0, behavior: 'auto' });
}
}

Expand Down Expand Up @@ -89,6 +91,7 @@ export default class NewsPage extends React.Component<{
<CitationText />
</div>
<div className="mt-2">
<NewsList date={'01172024'} />
<NewsList date={'12212023'} />
<NewsList date={'12062023'} />
<NewsList date={'11132023'} />
Expand Down
19 changes: 19 additions & 0 deletions src/main/webapp/app/pages/newsPage/NewsPageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,25 @@ const EVIDENCE_COLUMN_SEPARATOR = '; ';
// https://stackoverflow.com/questions/41947168/is-it-possible-to-use-keyof-operator-on-literals-instead-of-interfaces

export const NEWS_BY_DATE: { [date: string]: NewsData } = {
'01172024': {
priorityNews: [
<span>
Happy New Year! As of December 31, 2023, 11 level 1, 7 level 2, 4 level
3 and 3 level 4 treatments for unique biomarker-selected indications
were added to OncoKB. A table summarizing these changes can be found{' '}
<YearEndReviewPageLink year={'2023'}>here</YearEndReviewPageLink>. The
Precision Oncology: 2023 in review article can be found{' '}
<Linkout
link={
'https://aacrjournals.org/cancerdiscovery/article/13/12/2525/731600/Precision-Oncology-2023-in-Review'
}
>
here
</Linkout>
.
</span>,
],
},
'12212023': {
priorityNews: [
<span>
Expand Down
187 changes: 187 additions & 0 deletions src/main/webapp/app/pages/newsPage/NewsPageNavTab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
import * as React from 'react';
import { Col, Nav, Row, Tab } from 'react-bootstrap';
import AppStore from 'app/store/AppStore';
import { inject, observer } from 'mobx-react';
import { PAGE_ROUTE, PAGE_TITLE } from 'app/config/constants';
import { computed, IReactionDisposer, observable, reaction } from 'mobx';
import { RouterStore } from 'mobx-react-router';
import { YearEndSummaryPage } from 'app/pages/yearEndSummaryPage/YearEndSummaryPage';
import { LocationDescriptorObject } from 'history';
import classnames from 'classnames';
import NewsPage from 'app/pages/newsPage/NewsPage';

type NewsPageNavTabProps = { appStore: AppStore; routing: RouterStore };

export enum TabKey {
NEWS = PAGE_ROUTE.NEWS,
YEAR_END_SUMMARY = PAGE_ROUTE.YEAR_END_SUMMARY,
}

export const YEAR_END_SUMMARY_RANGE = ['2023', '2022'] as const;
const HASH_KEY_DIVIDER = '+';

@inject('appStore', 'routing')
@observer
export class NewsPageNavTab extends React.Component<NewsPageNavTabProps> {
readonly reactions: IReactionDisposer[] = [];

@observable selectedTab: string = TabKey.NEWS.toString();

constructor(props: NewsPageNavTabProps) {
super(props);
reaction(
() => this.selectedTab,
newSelectedTab => {
this.props.routing.history.push(
this.getHistoryBySelectedTab(newSelectedTab)
);
}
);
reaction(
() => [props.routing.location.pathname],
([pathName]) => {
const lowerCasePathName = pathName.toLowerCase();
if (
props.routing.location.hash &&
lowerCasePathName.startsWith(PAGE_ROUTE.YEAR_END_SUMMARY)
) {
const hash = props.routing.location.hash.slice(1);
this.selectedTab = this.getTabEventKey(TabKey.YEAR_END_SUMMARY, hash);
} else if (Object.keys(TabKey).includes(lowerCasePathName)) {
this.selectedTab = lowerCasePathName;
}
},
{ fireImmediately: true }
);
}

@computed
get inYearEndSummarySection() {
return this.selectedTab.startsWith(PAGE_ROUTE.YEAR_END_SUMMARY);
}

@computed
get inNewsSection() {
return this.selectedTab.startsWith(PAGE_ROUTE.NEWS);
}

getHistoryBySelectedTab(newSelectedTab: string): LocationDescriptorObject {
if (newSelectedTab.startsWith(PAGE_ROUTE.YEAR_END_SUMMARY)) {
const location: LocationDescriptorObject = {
pathname: PAGE_ROUTE.YEAR_END_SUMMARY,
};
const year = this.parseYearEndSummaryEventKey(newSelectedTab);
if (year !== undefined) {
location.hash = `#${year}`;
}
return location;
} else if (newSelectedTab.startsWith(PAGE_ROUTE.NEWS)) {
const location: LocationDescriptorObject = {
pathname: PAGE_ROUTE.NEWS,
};
const year = this.parseYearEndSummaryEventKey(newSelectedTab);
if (year !== undefined) {
location.hash = `#${year}`;
}
return location;
} else {
return {
pathname: newSelectedTab,
};
}
}

getTabEventKey(tab: TabKey, hash: string | undefined) {
return `${tab}${hash ? HASH_KEY_DIVIDER + hash : ''}`;
}

parseYearEndSummaryEventKey(eventKey: string): string | undefined {
const components = eventKey.split(HASH_KEY_DIVIDER);
if (components.length <= 1) {
return undefined;
} else {
return components[1];
}
}

componentWillUnmount() {
this.reactions.forEach(componentReaction => componentReaction());
}

render() {
return (
<>
<Tab.Container
id="news-page-nav-tabs"
activeKey={this.selectedTab}
unmountOnExit
onSelect={(selectedTab: string) => {
this.selectedTab = selectedTab as any;
}}
>
<Row>
<Col sm={2}>
<Nav
variant="pills"
className={classnames(
'flex-column',
'sticky-top',
'sticky-panel-relevant-to-header'
)}
>
<Nav.Item>
<Nav.Link eventKey={TabKey.NEWS}>Latest News</Nav.Link>
</Nav.Item>
<Nav.Item>
<Nav.Link eventKey={TabKey.YEAR_END_SUMMARY}>
{PAGE_TITLE.YEAR_END_SUMMARY}
</Nav.Link>
</Nav.Item>
{this.inYearEndSummarySection &&
YEAR_END_SUMMARY_RANGE.map(year => {
const key = this.getTabEventKey(
TabKey.YEAR_END_SUMMARY,
year
);
return (
<Nav.Item key={key}>
<Nav.Link eventKey={key} className={'ml-3'}>
{year}
</Nav.Link>
</Nav.Item>
);
})}
</Nav>
</Col>
<Col sm={10}>
<Tab.Content>
<Tab.Pane eventKey={TabKey.NEWS}>
<NewsPage routing={this.props.routing} />
</Tab.Pane>
<Tab.Pane
eventKey={TabKey.YEAR_END_SUMMARY}
key={TabKey.YEAR_END_SUMMARY}
unmountOnExit
>
<YearEndSummaryPage />
</Tab.Pane>
{this.inYearEndSummarySection &&
YEAR_END_SUMMARY_RANGE.map(year => {
const key = this.getTabEventKey(
TabKey.YEAR_END_SUMMARY,
year
);
return (
<Tab.Pane eventKey={key} key={key} unmountOnExit>
<YearEndSummaryPage selectedYear={year} />
</Tab.Pane>
);
})}
</Tab.Content>
</Col>
</Row>
</Tab.Container>
</>
);
}
}
Loading

0 comments on commit 46f782c

Please sign in to comment.