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

task/WC-13: Update citation format for publications with versions. #1445

Merged
merged 4 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions client/modules/_hooks/src/datafiles/projects/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export type TPreviewTreeData = {
uuid: string;
value: TEntityValue;
order: number;
version?: number;
publicationDate?: string;
children: TPreviewTreeData[];
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export const PublishedCitation: React.FC<{
)
.join(', ')}{' '}
({new Date(entityDetails.publicationDate).getFullYear()}). "
{entityDetails.value.title}", in <i>{data.baseProject.title}</i>.
DesignSafe-CI.{' '}
{entityDetails.value.title}", in <i>{data.baseProject.title}</i>
{(version ?? 1) > 1 && <span> [Version {version}]</span>}. DesignSafe-CI.{' '}
{doi && (
<a
href={`https://doi.org/${doi}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,11 @@ export const PublishedEntityDisplay: React.FC<{
{preview ? (
<ProjectCitation projectId={projectId} entityUuid={treeData.uuid} />
) : (
<PublishedCitation projectId={projectId} entityUuid={treeData.uuid} />
<PublishedCitation
projectId={projectId}
entityUuid={treeData.uuid}
version={treeData.version ?? 1}
/>
)}
<br />
{citationMetrics && (
Expand Down
13 changes: 7 additions & 6 deletions client/src/datafiles/layouts/published/PublishedDetailLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export const PublishedDetailLayout: React.FC = () => {
const { data, isError } = usePublicationDetail(projectId ?? '');
const { allVersions } = usePublicationVersions(projectId ?? '');
const version = (projectId ?? '').split('v')[1];
const selectedVersion =
version ||
searchParams.get('version') ||
Math.max(...allVersions).toString();

useEffect(() => {
if (version) {
const newSearchParams = new URLSearchParams(searchParams);
Expand All @@ -62,11 +67,6 @@ export const PublishedDetailLayout: React.FC = () => {
useEffect(() => {
if (!data) return;

const selectedVersion =
version ||
searchParams.get('version') ||
Math.max(...allVersions).toString();

data?.baseProject.projectType !== 'other' &&
apiClient.get(
`/api/datafiles/tapis/public/listing/designsafe.storage.published/${projectId}${
Expand All @@ -75,7 +75,7 @@ export const PublishedDetailLayout: React.FC = () => {
: ''
}`
);
}, [data, allVersions, searchParams, version, projectId]);
}, [data, selectedVersion, searchParams, projectId]);

if (isError) {
return (
Expand Down Expand Up @@ -171,6 +171,7 @@ export const PublishedDetailLayout: React.FC = () => {
<PublishedCitation
projectId={projectId}
entityUuid={data.tree.children[0].uuid}
version={parseInt(selectedVersion)}
/>
<br />
<div>
Expand Down
Loading