Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v2.5.0 #564

Merged
merged 41 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
7997da5
Switch from Universal Analytics to Google Analytics 4
sunu Oct 4, 2023
a76322c
change some of the calls to react-ga4 syntax
sunu Oct 4, 2023
5db6bbd
Fix module in package.json
vgeorge Oct 4, 2023
1d603d0
Lint fix
vgeorge Oct 4, 2023
1b9e3cc
Add GA to all environments
vgeorge Oct 6, 2023
57ca4dd
Merge pull request #550 from NASA-IMPACT/feat/google-analytics-4
vgeorge Oct 6, 2023
05f50d6
Do not use formatDocumentTableCaptions function on document body, app…
vgeorge Oct 10, 2023
bd6ca5b
Remove reviewer info UI
kamicut Oct 11, 2023
3c9fd7d
Add 'Document Reviewer' Role type
kamicut Oct 11, 2023
5857c86
Apply table transformer in document preview
vgeorge Oct 12, 2023
f66c077
Change figure captions using the transformer
vgeorge Oct 12, 2023
71cf6af
Rename function
vgeorge Oct 12, 2023
51ec185
Add corresponding authors
kamicut Oct 12, 2023
e8b12f3
Replace reviewer_info with new component
kamicut Oct 12, 2023
6b4d51e
add sort contacts method
kamicut Oct 12, 2023
2f68fba
Remove redundant checkbox
kamicut Oct 13, 2023
331a14d
Merge pull request #560 from NASA-IMPACT/fix/journal-styling-authors
wrynearson Oct 13, 2023
d5c62f8
Merge pull request #559 from NASA-IMPACT/feature/multiple-contact-rev…
wrynearson Oct 13, 2023
bf37f27
Add algorithm variables to journal PDF output
vgeorge Oct 13, 2023
4c6f98b
Refactor type declaration
vgeorge Oct 13, 2023
dff6420
Add types file
vgeorge Oct 13, 2023
1af63c3
Merge branch 'develop' into fix/numbering
vgeorge Oct 13, 2023
9532aee
sort contacts for journal pdf and remove reviewers
kamicut Oct 13, 2023
4a613db
Merge pull request #562 from NASA-IMPACT/fix/sort-journal-contacts
wrynearson Oct 16, 2023
406c19e
Merge branch 'develop' into add/alg-variables-to-journal-pdf
vgeorge Oct 16, 2023
21880c1
Merge pull request #561 from NASA-IMPACT/add/alg-variables-to-journal…
vgeorge Oct 16, 2023
2cbacbe
Merge branch 'develop' into fix/numbering
vgeorge Oct 16, 2023
2b54a90
Track template download
vgeorge Oct 16, 2023
5d65d48
Track ATBD edits
vgeorge Oct 16, 2023
51c7e6b
Merge pull request #563 from NASA-IMPACT/enhance/ga
wrynearson Oct 17, 2023
a01ad5d
Merge pull request #558 from NASA-IMPACT/fix/numbering
vgeorge Oct 17, 2023
0396151
Merge branch 'develop' into fix/add-ga-to-all-envs
vgeorge Oct 17, 2023
5663d6d
Update tracking codes
vgeorge Oct 17, 2023
2d96c14
Merge pull request #557 from NASA-IMPACT/fix/add-ga-to-all-envs
vgeorge Oct 17, 2023
665cd00
Bump version
vgeorge Oct 17, 2023
ba455f5
Fix image positioning
vgeorge Oct 19, 2023
aa09225
Remove tables/image numbering from caption element as it is handled b…
vgeorge Oct 19, 2023
116a543
Improve comments, refactor numbering context
vgeorge Oct 19, 2023
71de924
Fix equation number repetition
vgeorge Oct 20, 2023
7783e33
Merge pull request #565 from NASA-IMPACT/fix/captions
wrynearson Oct 20, 2023
fe57369
Merge pull request #566 from NASA-IMPACT/fix/equation-number-repetition
wrynearson Oct 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect } from 'react';
import T from 'prop-types';
import styled from 'styled-components';

import ReactGA from 'react-ga';
import ReactGA from 'react-ga4';
import { Modal as BaseModal } from '@devseed-ui/modal';
import { glsp } from '@devseed-ui/theme-provider';

Expand Down Expand Up @@ -121,7 +121,7 @@ export default function DocumentChangelogModal(props) {

useEffect(() => {
if (revealed) {
ReactGA.modalview('document-changelog');
ReactGA.send({ hitType: 'modalview', page: '/modal/document-changelog' });
}
}, [revealed]);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { confirmDeleteDocumentVersion } from '../common/confirmation-prompt';
import toasts from '../common/toasts';
import ReactGA from 'react-ga4';

/**
* Convenience method to delete an atbd version and show a toast notification.
Expand All @@ -24,6 +25,7 @@ export async function documentDeleteVersionConfirmAndToast({
if (result.error) {
toasts.error(`An error occurred: ${result.error.message}`);
} else {
ReactGA.event('atbd_version_deleted');
toasts.success('Document version successfully deleted');
history.push('/dashboard');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useMemo } from 'react';
import T from 'prop-types';
import ReactGA from 'react-ga';
import ReactGA from 'react-ga4';
import { Auth } from 'aws-amplify';
import { saveAs } from 'file-saver';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useEffect } from 'react';
import T from 'prop-types';
import styled from 'styled-components';
import ReactGA from 'react-ga';
import ReactGA from 'react-ga4';
import { FormTextarea } from '@devseed-ui/form';
import { Modal } from '@devseed-ui/modal';
import { Button } from '@devseed-ui/button';
Expand Down Expand Up @@ -41,7 +41,7 @@ export default function DocumentInfoModal(props) {

useEffect(() => {
if (revealed) {
ReactGA.modalview('document-info');
ReactGA.send({ hitType: 'modalview', page: '/modal/document-info' });
}
}, [revealed]);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useEffect, useMemo } from 'react';
import T from 'prop-types';
import qs from 'qs';
import ReactGA from 'react-ga';
import ReactGA from 'react-ga4';
import styled, { css } from 'styled-components';
import { useLocation } from 'react-router';
import { Modal, ModalFooter } from '@devseed-ui/modal';
Expand Down Expand Up @@ -140,7 +140,10 @@ export default function DocumentTrackerModal(props) {

useEffect(() => {
if (revealed) {
ReactGA.modalview('document-progress-tracker');
ReactGA.send({
hitType: 'modalview',
page: '/modal/document-progress-tracker'
});
}
}, [revealed]);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useMemo } from 'react';
import T from 'prop-types';
import ReactGA from 'react-ga';
import ReactGA from 'react-ga4';
import { VerticalDivider } from '@devseed-ui/toolbar';
import { BsFilePdf } from 'react-icons/bs';

Expand Down
120 changes: 88 additions & 32 deletions app/assets/scripts/components/documents/journal-pdf-preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ import {
formatReference,
sortReferences
} from '../../../utils/references';
import { formatDocumentTableCaptions } from '../../../utils/format-table-captions';
import { applyNumberCaptionsToDocument } from '../../../utils/apply-number-captions-to-document';
import { VariableItem } from '../single-view/document-body';
import { variableNodeType } from '../../../types';
import { sortContacts } from '../../../utils/sort-contacts';

const ReferencesList = styled.ol`
&& {
Expand Down Expand Up @@ -217,6 +220,28 @@ ImplementationDataList.propTypes = {
)
};

function VariablesList({ list }) {
if (!list || list.length === 0) {
return EMPTY_CONTENT_MESSAGE;
}

return (
<DataListContainer>
{list?.map((variable, i) => (
<VariableItem
key={`variable-${i + 1}`}
variable={variable}
element={{ id: `variable-${i}`, label: `Variable #${i + 1}` }}
/>
))}
</DataListContainer>
);
}

VariablesList.propTypes = {
list: T.arrayOf(variableNodeType)
};

function ContactOutput(props) {
const { data } = props;
const { affiliations, contact, roles } = data;
Expand Down Expand Up @@ -344,7 +369,7 @@ function JournalPdfPreview() {
journal_discussion,
data_availability,
journal_acknowledgements
} = formatDocumentTableCaptions(document);
} = applyNumberCaptionsToDocument(document);

const ContentView = useMemo(() => {
const safeReadContext = {
Expand Down Expand Up @@ -422,43 +447,67 @@ function JournalPdfPreview() {

// create contacts list component with superscripts
let contacts = [];
contacts_link?.forEach(
({ contact, affiliations: contactAffiliations }, i) => {
let authors = contacts_link?.filter(
(c) => !c.roles?.includes('Document Reviewer')
); // Remove any reviewer from the authors list

authors
?.sort(sortContacts)
.forEach(({ contact, affiliations: contactAffiliations }, i) => {
const hasAffiliation =
contactAffiliations && contactAffiliations.length > 0;

let contactEmail = contact.mechanisms.find(
(mechanism) => mechanism.mechanism_type === 'Email'
)?.mechanism_value;

const item = (
<span key={contact.id}>
<strong>
{getContactName(contact, { full: true })}
{contactEmail && ` (${contactEmail})`}
{hasAffiliation &&
contactAffiliations.map((affiliation, j) => {
return (
<>
<sup>
{Array.from(affiliations).indexOf(affiliation) + 1}
</sup>
<sup>
{j < contactAffiliations.length - 1 && <span>, </span>}
</sup>
</>
);
})}
{i < authors.length - 1 && <span>, </span>}
{i === authors.length - 2 && <span>and </span>}
</strong>
{hasAffiliation &&
contactAffiliations.map((affiliation, j) => {
return (
<>
<sup>
{Array.from(affiliations).indexOf(affiliation) + 1}
</sup>
<sup>
{j < contactAffiliations.length - 1 && <span>, </span>}
</sup>
</>
);
})}
{i < contacts_link.length - 1 && <span>, </span>}
{i === contacts_link.length - 2 && <span>and </span>}
</span>
);
contacts.push(item);
}
);
});

// create corresponding authors list component
const correspondingAuthors =
authors
?.filter((c) =>
c.roles?.find((r) => r.toLowerCase() === 'corresponding author')
)
.map(({ contact }) => {
let contactEmail = contact.mechanisms.find(
(mechanism) => mechanism.mechanism_type === 'Email'
)?.mechanism_value;

let contactName = getContactName(contact, { full: true });

return `${contactName} ${contactEmail ? `(${contactEmail})` : ''}`;
}) || [];

const correspondingAuthorsString = correspondingAuthors.map((author, i) => (
<>
{author}
{i < correspondingAuthors.length - 1 && <span>, </span>}
{i === correspondingAuthors.length - 2 && <span>and </span>}
</>
));
return {
items: contacts,
correspondingAuthors: correspondingAuthorsString,
affiliations_list: Array.from(affiliations),
maxIndex: (contacts_link?.length ?? 0) - 1
};
Expand Down Expand Up @@ -514,10 +563,9 @@ function JournalPdfPreview() {
);
const mathematicalTheoryVisible =
hasContent(mathematical_theory) || mathematicalTheoryAssumptionsVisible;
const algorithmInputVariablesVisible = hasContent(algorithm_input_variables);
const algorithmOutputVariablesVisible = hasContent(
algorithm_output_variables
);
const algorithmInputVariablesVisible = algorithm_input_variables?.length > 0;
const algorithmOutputVariablesVisible =
algorithm_output_variables?.length > 0;
const algorithmDescriptionVisible =
scientificTheoryVisible ||
mathematicalTheoryVisible ||
Expand Down Expand Up @@ -581,6 +629,14 @@ function JournalPdfPreview() {
</div>
))}
</div>
<div>
{contacts?.correspondingAuthors?.length > 0 && (
<div>
<strong>Corresponding Author(s): </strong>
{contacts?.correspondingAuthors}
</div>
)}
</div>
</AuthorsSection>
<Section id='key_points' title='Key Points:' skipNumbering>
<ul>
Expand Down Expand Up @@ -668,15 +724,15 @@ function JournalPdfPreview() {
id='algorithm_input_variables'
title='Algorithm Input Variables'
>
<ContentView value={algorithm_input_variables} />
<VariablesList list={algorithm_input_variables} />
</Section>
)}
{algorithmOutputVariablesVisible && (
<Section
id='algorithm_output_variables'
title='Algorithm Output Variables'
>
<ContentView value={algorithm_output_variables} />
<VariablesList list={algorithm_output_variables} />
</Section>
)}
</Section>
Expand Down
34 changes: 22 additions & 12 deletions app/assets/scripts/components/documents/pdf-preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import DocumentTitle from '../single-view/document-title';
import { DocumentProse } from '../single-view/document-content';
import { ScrollAnchorProvider } from '../single-view/scroll-manager';
import { applyNumberCaptionsToDocument } from '../../../utils/apply-number-captions-to-document';

const TocHeader = styled.h1`
border-bottom: 3px solid #000;
Expand Down Expand Up @@ -204,13 +205,6 @@
// Starting from h2
generateHeading(2, tocElement, content, undefined);

const captions = content.querySelectorAll('.slate-image-block figcaption');
Array.from(captions).forEach((caption, i) => {
const captionPrefix = document.createElement('span');
captionPrefix.innerText = `Figure ${i + 1}: `;
caption.prepend(captionPrefix);
});

const equationNumbers = content.querySelectorAll(
'.slate-equation-element .equation-number'
);
Expand All @@ -225,6 +219,7 @@
const { isAuthReady } = useUser();
const contentRef = useRef(null);
const [previewReady, setPreviewReady] = useState(false);
const [document, setDocument] = useState(null);

useEffect(() => {
isAuthReady && fetchSingleAtbd();
Expand All @@ -245,12 +240,19 @@
}

if (atbd.status === 'succeeded') {
generateTocAndHeadingNumbering(contentRef.current);

setDocument(applyNumberCaptionsToDocument(atbd.data.document));
waitForImages();
}
}, [atbd.status]);

Check warning on line 246 in app/assets/scripts/components/documents/pdf-preview/index.js

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'atbd.data.document'. Either include it or remove the dependency array

Check warning on line 246 in app/assets/scripts/components/documents/pdf-preview/index.js

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'atbd.data.document'. Either include it or remove the dependency array

// This useEffect is responsible for generating the ToC and numbering
// after the document is transformed
useEffect(() => {
if (document && contentRef?.current) {
generateTocAndHeadingNumbering(contentRef.current);
}
}, [document]);

return (
<ScrollAnchorProvider disabled>
{atbd.status === 'loading' && <GlobalLoading />}
Expand All @@ -271,9 +273,17 @@
id='table-of-contents'
/>
</div>
<DocumentProse className='preview-page-content'>
<DocumentBody atbd={atbd.data} disableScrollManagement={true} />
</DocumentProse>
{document && (
<DocumentProse className='preview-page-content'>
<DocumentBody
atbd={{
...atbd.data,
document
}}
disableScrollManagement={true}
/>
</DocumentProse>
)}
</div>
{previewReady && <div id='pdf-preview-ready' />}
</PreviewContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const roleTypes = [
'Supervision',
'Investigation',
'Funding acquisition',
'Corresponding Author'
'Corresponding Author',
'Document Reviewer'
];

const emptyAffiliation = '';
Expand Down
Loading
Loading