Skip to content

Commit

Permalink
Merge branch 'master' into multi-tenancy
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/i18n.ts
#	src/utils/generators/generate-article-status.test.ts
  • Loading branch information
nlisgo committed Nov 22, 2024
2 parents 3fe89b3 + b47835d commit fb0358a
Show file tree
Hide file tree
Showing 23 changed files with 232 additions and 260 deletions.
36 changes: 36 additions & 0 deletions browser-tests/api-reviewed-preprints.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ test('reviewed preprints api listing', async ({ request }) => {
expect(responseJson.items[0].version).toBe(2);
expect(responseJson.items[0].doi).toBe('10.1101/2022.11.08.515698');
expect(responseJson.items[0].title).toBe('The locus coeruleus broadcasts prediction errors across the cortex to promote sensorimotor plasticity');
expect(responseJson.items[0].elifeAssessment).toStrictEqual({
title: 'eLife assessment',
content: [
{
type: 'paragraph',
// eslint-disable-next-line max-len
text: 'This important study provides convincing evidence that locus coeruleus is activated during visuomotor mismatches. Gain of function optogenetic experiments complement this evidence and indicate that locus coeruleus could be involved in the learning process that enables visuomotor predictions. This study, therefore, sets the groundwork for the circuit dissection of predictive signals in the visual cortex. Loss-of-function experiments would strengthen the evidence of the involvement of locus coeruleus in prediction learning. These results will be of interest to systems neuroscientists.',
},
],
id: 'sa2',
doi: '10.7554/eLife.85111.2.sa2',
significance: [
'important',
],
strength: [
'convincing',
],
});
});

test('reviewed preprints api item found', async ({ request }) => {
Expand All @@ -37,6 +55,24 @@ test('reviewed preprints api item found', async ({ request }) => {
expect(responseJson.version).toBe(2);
expect(responseJson.doi).toBe('10.1101/2022.11.08.515698');
expect(responseJson.title).toBe('The locus coeruleus broadcasts prediction errors across the cortex to promote sensorimotor plasticity');
expect(responseJson.elifeAssessment).toStrictEqual({
title: 'eLife assessment',
content: [
{
type: 'paragraph',
// eslint-disable-next-line max-len
text: 'This important study provides convincing evidence that locus coeruleus is activated during visuomotor mismatches. Gain of function optogenetic experiments complement this evidence and indicate that locus coeruleus could be involved in the learning process that enables visuomotor predictions. This study, therefore, sets the groundwork for the circuit dissection of predictive signals in the visual cortex. Loss-of-function experiments would strengthen the evidence of the involvement of locus coeruleus in prediction learning. These results will be of interest to systems neuroscientists.',
},
],
id: 'sa2',
doi: '10.7554/eLife.85111.2.sa2',
significance: [
'important',
],
strength: [
'convincing',
],
});
expect(responseJson.indexContent).toContain('Through experience with the world, brains learn to predict the sensory feedback');
expect(responseJson.indexContent).toContain('Rebecca Jordan, Georg B. Keller');
});
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ services:
API_SERVER: ${API_SERVER:-http://wiremock:3000}
IIIF_SERVER: ${IIIF_SERVER:-http://image-server:8182/iiif}
NEXT_PUBLIC_IMAGE_SERVER: /iiif
NEXT_PUBLIC_DISABLE_TERMS: ${NEXT_PUBLIC_DISABLE_TERMS:-false}
depends_on:
yarn:
condition: service_completed_successfully
Expand Down
14 changes: 10 additions & 4 deletions src/components/atoms/assessment/assessment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '../../../utils/terms';
import { Descriptors } from '../descriptors/descriptors';
import { isPdfRoute } from '../../../utils/isPdfRoute';
import { config } from '../../../config';

type Props = { content: string, doi?: string };
export const Assessment = ({ content, doi }: Props) => {
Expand All @@ -20,7 +21,12 @@ export const Assessment = ({ content, doi }: Props) => {

const { strength, significance } = findTerms(content);

return (
return config.disableTerms ? (
<section id="assessment" className="assessment">
<div className="assessment__body" dangerouslySetInnerHTML={{ __html: content }} />
{doi && <Descriptors doi={doi}/>}
</section>
) : (
<section id="assessment" className="assessment">
<div className="assessment__body" dangerouslySetInnerHTML={{ __html: highlightTerms(content) }} />
{doi && <Descriptors doi={doi}/>}
Expand All @@ -30,9 +36,9 @@ export const Assessment = ({ content, doi }: Props) => {
<p className="assessment__fixed_text">{t('about_assessments_description')} <a href={t('about_assessments_url')}>{t('about_assessments')}</a></p>
</div>
{(expanded !== null && !isPdf) &&
<span role="button" aria-controls="assessment" aria-expanded={expanded}
className={`explanation_link ${expanded ? 'explanation_link__expanded' : ''}`}
onClick={() => setExpanded(!expanded)}> {expanded ? 'Show less' : 'Read more about this assessment'}</span>}
<span role="button" aria-controls="assessment" aria-expanded={expanded}
className={`explanation_link ${expanded ? 'explanation_link__expanded' : ''}`}
onClick={() => setExpanded(!expanded)}> {expanded ? 'Show less' : 'Read more about this assessment'}</span>}
</section>
);
};
2 changes: 1 addition & 1 deletion src/components/atoms/review-process/review-process.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const ReviewProcess = ({ current, authorResponse }: ReviewProcessProps) =
<h2 className="review-process__header" id="review-process">Peer review process</h2>
<div className="review-process__container">
<p className="review-process__body">{parse(t(`review_process_${type}${type === 'reviewed' && authorResponse === true ? '_with_author_response' : ''}`))}</p>
<a className="review-process__link" href={t('process_url')}>Read more about eLife’s peer review process.</a>
<a className="review-process__link" href={t('process_url')}>{t('process_url_read_more')}</a>
</div>
</section>
);
Expand Down
52 changes: 46 additions & 6 deletions src/components/pages/article/article-page.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import LinkTo from '@storybook/addon-links/react';
import { Meta, StoryObj } from '@storybook/react';
import {
content, metaData, metrics, peerReview, relatedContent, status, timeline,
content, metaData, metrics, peerReview, relatedContent, timeline,
} from '../../../utils/mocks';
import { ArticlePage } from './article-page';
import { ArticleFullTextTab, ArticleFiguresTab, ArticleReviewsTab } from './tabs';
Expand Down Expand Up @@ -57,7 +57,6 @@ const headings = contentToHeadings(content);
export const ArticlePageFullTextTab: Story = {
args: {
metaData,
status,
activeTab: 'fulltext',
tabs,
relatedContent,
Expand All @@ -74,10 +73,32 @@ export const ArticlePageFullTextTab: Story = {
),
};

export const ArticlePageFullTextTabNoSummary: Story = {
args: {
metaData,
activeTab: 'fulltext',
tabs,
relatedContent,
metrics,
previousVersionWarningUrl: '#',
timeline,
},
render: (args) => {
const { reviews, authorResponse } = peerReview;

return (
<DefaultLayout>
<ArticlePage {...args}>
<ArticleFullTextTab metrics={metrics} headings={headings} metaData={metaData} peerReview={{ reviews, authorResponse }} content={jsxContent} />
</ArticlePage>
</DefaultLayout>
);
},
};

export const ArticlePageFiguresTab: Story = {
args: {
metaData,
status,
activeTab: 'figures',
tabs,
relatedContent,
Expand All @@ -99,7 +120,6 @@ export const ArticlePageReviewedReviewsTab: Story = {
...metaData,
version: '1',
},
status,
activeTab: 'reviews',
tabs,
relatedContent,
Expand All @@ -118,7 +138,6 @@ export const ArticlePageReviewedReviewsTab: Story = {
export const ArticlePageRevisedReviewsTab: Story = {
args: {
metaData,
status,
activeTab: 'reviews',
tabs,
relatedContent,
Expand All @@ -134,10 +153,31 @@ export const ArticlePageRevisedReviewsTab: Story = {
),
};

export const ArticlePageRevisedReviewsTabNoSummary: Story = {
args: {
metaData,
activeTab: 'reviews',
tabs,
relatedContent,
metrics,
timeline,
},
render: (args) => {
const { reviews, authorResponse } = peerReview;

return (
<DefaultLayout>
<ArticlePage {...args}>
<ArticleReviewsTab peerReview={{ reviews, authorResponse }} currentVersion={2} />
</ArticlePage>
</DefaultLayout>
);
},
};

export const ArticlePageErrorTab: Story = {
args: {
metaData,
status,
activeTab: 'reviews',
tabs,
relatedContent,
Expand Down
24 changes: 12 additions & 12 deletions src/components/pages/article/article-page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
import { ArticlePage } from './article-page';
import { ArticleStatus } from '../../molecules/article-status/article-status';
import {
metaData, peerReview, status, timeline, citation, relatedContent,
metaData, peerReview, timeline, citation, relatedContent,
} from '../../../utils/mocks';
import { ArticleFiguresTab, ArticleFullTextTab, ArticleReviewsTab } from './tabs';
import { contentToText } from '../../../utils/content';
Expand All @@ -16,19 +16,19 @@ jest.mock('next/navigation', () => ({

describe('ArticlePage', () => {
it('renders correctly', () => {
expect(() => render(<ArticlePage relatedContent={[]} msidWithVersion="12345v1" metaData={metaData} status={status} timeline={timeline} activeTab="fulltext" tabs={[]} previousVersionWarningUrl="http://latest.version">
expect(() => render(<ArticlePage relatedContent={[]} msidWithVersion="12345v1" metaData={metaData} timeline={timeline} activeTab="fulltext" tabs={[]} previousVersionWarningUrl="http://latest.version">
<ArticleFullTextTab headings={[]} content={''} peerReview={peerReview} metaData={metaData} metrics={null} />
</ArticlePage>)).not.toThrow();
});

it('renders with figures tab', () => {
expect(() => render(<ArticlePage relatedContent={[]} msidWithVersion="12345v1" metaData={metaData} status={status} timeline={timeline} activeTab="figures" tabs={[]} previousVersionWarningUrl="http://latest.version">
expect(() => render(<ArticlePage relatedContent={[]} msidWithVersion="12345v1" metaData={metaData} timeline={timeline} activeTab="figures" tabs={[]} previousVersionWarningUrl="http://latest.version">
<ArticleFiguresTab content={''} />
</ArticlePage>)).not.toThrow();
});

it('renders with reviews tab', () => {
expect(() => render(<ArticlePage relatedContent={[]} msidWithVersion="12345v1" metaData={metaData} status={status} timeline={timeline} activeTab="reviews" tabs={[]} previousVersionWarningUrl="http://latest.version">
expect(() => render(<ArticlePage relatedContent={[]} msidWithVersion="12345v1" metaData={metaData} timeline={timeline} activeTab="reviews" tabs={[]} previousVersionWarningUrl="http://latest.version">
<ArticleReviewsTab peerReview={peerReview} currentVersion={1} />
</ArticlePage>)).not.toThrow();
});
Expand All @@ -48,7 +48,7 @@ describe('ArticlePage', () => {
linkElement: <a href={'/reviewed-preprints/12345v1/reviews#tab-content'}>Peer review</a>,
},
];
render(<ArticlePage relatedContent={[]} msidWithVersion="12345v1" metaData={metaData} status={status} timeline={timeline} activeTab="fulltext" tabs={tabs} previousVersionWarningUrl="http://latest.version">
render(<ArticlePage relatedContent={[]} msidWithVersion="12345v1" metaData={metaData} timeline={timeline} activeTab="fulltext" tabs={tabs} previousVersionWarningUrl="http://latest.version">
<ArticleFullTextTab headings={[]} content={''} peerReview={peerReview} metaData={metaData} metrics={null} />
</ArticlePage>);

Expand All @@ -61,7 +61,7 @@ describe('ArticlePage', () => {
expect(screen.getByText('Peer review').parentElement?.classList.value).not.toContain('tab-label--active');

cleanup();
render(<ArticlePage relatedContent={[]} msidWithVersion="12345v1" metaData={metaData} status={status} timeline={timeline} activeTab="figures" tabs={tabs} previousVersionWarningUrl="http://latest.version">
render(<ArticlePage relatedContent={[]} msidWithVersion="12345v1" metaData={metaData} timeline={timeline} activeTab="figures" tabs={tabs} previousVersionWarningUrl="http://latest.version">
<ArticleFullTextTab headings={[]} content={''} peerReview={peerReview} metaData={metaData} metrics={null} />
</ArticlePage>);

Expand All @@ -70,7 +70,7 @@ describe('ArticlePage', () => {
expect(screen.getByText('Peer review').parentElement?.classList.value).not.toContain('tab-label--active');

cleanup();
render(<ArticlePage relatedContent={[]} msidWithVersion="12345v1" metaData={metaData} status={status} timeline={timeline} activeTab="reviews" tabs={tabs} previousVersionWarningUrl="http://latest.version">
render(<ArticlePage relatedContent={[]} msidWithVersion="12345v1" metaData={metaData} timeline={timeline} activeTab="reviews" tabs={tabs} previousVersionWarningUrl="http://latest.version">
<ArticleFullTextTab headings={[]} content={''} peerReview={peerReview} metaData={metaData} metrics={null} />
</ArticlePage>);

Expand All @@ -96,7 +96,7 @@ describe('ArticlePage', () => {
});

it('renders related content', () => {
render(<ArticlePage relatedContent={relatedContent} msidWithVersion="12345v1" metaData={metaData} status={status} timeline={timeline} activeTab="figures" tabs={[]} previousVersionWarningUrl="http://latest.version">
render(<ArticlePage relatedContent={relatedContent} msidWithVersion="12345v1" metaData={metaData} timeline={timeline} activeTab="figures" tabs={[]} previousVersionWarningUrl="http://latest.version">
<ArticleFullTextTab headings={[]} content={''} peerReview={peerReview} metaData={metaData} metrics={null} />
</ArticlePage>);

Expand All @@ -106,7 +106,7 @@ describe('ArticlePage', () => {
});

it('renders metrics if present', () => {
render(<ArticlePage relatedContent={[]} msidWithVersion="12345v1" metaData={metaData} status={status} timeline={timeline} activeTab="figures" tabs={[]} previousVersionWarningUrl="http://latest.version">
render(<ArticlePage relatedContent={[]} msidWithVersion="12345v1" metaData={metaData} timeline={timeline} activeTab="figures" tabs={[]} previousVersionWarningUrl="http://latest.version">
<ArticleFullTextTab headings={[]} content={''} peerReview={peerReview} metaData={metaData} metrics={null} />
</ArticlePage>);

Expand All @@ -122,7 +122,7 @@ describe('ArticlePage', () => {
relatedContent={[]}
msidWithVersion="12345v1"
metaData={{ ...metaData, authors: [] }}
status={status}

timeline={timeline}
activeTab="figures"
tabs={[]}
Expand All @@ -143,7 +143,7 @@ describe('ArticlePage', () => {
relatedContent={[]}
msidWithVersion="12345v1"
metaData={{ ...metaData, authors: [] }}
status={status}

timeline={timeline}
activeTab="pdf"
tabs={[]}
Expand All @@ -164,7 +164,7 @@ describe('ArticlePage', () => {
relatedContent={relatedContent}
msidWithVersion="12345v1"
metaData={{ ...metaData, authors: [] }}
status={status}

timeline={timeline}
activeTab="pdf"
tabs={[]}
Expand Down
7 changes: 0 additions & 7 deletions src/components/pages/article/article-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ import { CitationData } from '../../atoms/citation/citation';
import { RelatedContentData, RelatedContent } from '../../atoms/related-content/related-content';
import { PreviousVersionWarning } from '../../atoms/previous-version-warning/previous-version-warning';

export type ArticleStatusProps = {
articleType: string,
status: string,
isPreview: boolean,
};

export type Tab = {
id: string,
linkElement: ReactElement,
Expand All @@ -24,7 +18,6 @@ export type Tab = {
export type ArticlePageProps = {
metaData: MetaData,
msidWithVersion: string,
status: ArticleStatusProps,
relatedContent: RelatedContentData[],
metrics?: Metrics,
children: ReactElement<typeof ArticleFullTextTab | typeof ArticleFiguresTab | typeof ArticleReviewsTab>,
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/article/tabs/fulltext-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const ArticleFullTextTab = (props: Props) => {

return (
<>
{ props.peerReview && <Assessment content={props.peerReview.evaluationSummary.text} doi={props.peerReview.evaluationSummary.doi}/> }
{ (props.peerReview && props.peerReview.evaluationSummary) && <Assessment content={props.peerReview.evaluationSummary.text} doi={props.peerReview.evaluationSummary.doi}/> }
<div className="tabbed-navigation__content">
<JumpToMenu headings={headings} />
<div className="article-body-container">
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/article/tabs/reviews-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const ArticleReviewsTab = ({ peerReview, currentVersion }: { peerReview:
<JumpToMenu headings={headings} />
<div className="article-body-container">
<ReviewProcess current={currentVersion} {...(peerReview.authorResponse ? { authorResponse: true } : {})} />
<EditorsAndReviewers participants={peerReview.evaluationSummary.participants} />
{ peerReview.evaluationSummary && <EditorsAndReviewers participants={peerReview.evaluationSummary.participants} /> }
{peerReview.reviews.map((review, index) => (
<ReviewContent key={index} id={`peer-review-${index}`} content={review.text} doi={review.doi} />
))}
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Config = {
cookiebotId?: string,
articleCacheAge: string,
disallowRobots: boolean,
disableTerms: boolean,
};

export const config: Config = {
Expand All @@ -23,4 +24,5 @@ export const config: Config = {
cookiebotId: process.env.NEXT_PUBLIC_COOKIEBOT_ID,
articleCacheAge: process.env.ARTICLE_CACHE_AGE || '1800',
disallowRobots: !!process.env.DISALLOW_ROBOTS,
disableTerms: !!process.env.NEXT_PUBLIC_DISABLE_TERMS && ['all', 'true'].includes(process.env.NEXT_PUBLIC_DISABLE_TERMS),
};
15 changes: 6 additions & 9 deletions src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@ const resources = {

// Defaults:
reviewed_preprints_url: '/reviewed-preprints/{{msid}}', // link to reviewed preprints
heading_assessment: '$t(publisher_short) assessment',
about_assessments_description: (
'During the peer-review process the editor and reviewers write an assessment that summarises the significance'
+ ' of the findings reported in the article and the strength of the evidence.'
),
about_assessments: 'Learn more about $t(publisher_short) assessments',
status_description_reviewed: 'Published from the original preprint after peer review and assessment by $t(publisher_short).',
status_description_revised: 'Revised by authors after peer review.',
status_about: 'About $t(publisher_short)\'s process',
reviewed_preprint: 'Reviewed Preprint',
related_intro: 'Related {{type}}',
related_type_default: 'content',
Expand All @@ -34,6 +30,10 @@ const resources = {
history_version_title: '$t(reviewed_preprint) version {{version}}',
external_history_version_title: '$t(history_version_title)',
external_history_version_title_updated: '$t(external_history_version_title)',
process_url_read_more: 'Read more about $t(publisher_short)’s peer review process.',
review_process_reviewed: '',
review_process_reviewed_with_author_response: '',
review_process_revised: '',
},
elife: {
twitter_handle: '@elife',
Expand Down Expand Up @@ -74,11 +74,8 @@ const resources = {
home_url: 'https://biophysicscolab.pubpub.org/',
about_url: 'https://biophysicscolab.pubpub.org/about',
search_url: 'https://biophysicscolab.pubpub.org/search',
heading_assessment: 'Endorsement statement',
timeline_version_title: 'Endorsed article published',
reviewed_preprint: 'Endorsed article',
status_description_reviewed: '$t(publisher_short) have endorsed this preprint that was revised by authors after peer review.',
status_description_revised: '$t(publisher_short) have endorsed this preprint that was revised by authors after peer review.',
timeline_version_title: 'Curated preprint published',
reviewed_preprint: 'Curated preprint',
process_url: 'https://www.sciencecolab.org/biophysics-colab',
about_assessments_url: 'https://www.sciencecolab.org/biophysics-colab',
},
Expand Down
Loading

0 comments on commit fb0358a

Please sign in to comment.