Skip to content

Commit

Permalink
task/WC-13: Update citation format for publications with versions. (#…
Browse files Browse the repository at this point in the history
…1445)

* Update citation format for versions

* fix type error

* linting
  • Loading branch information
jarosenb authored Oct 3, 2024
1 parent d583c7e commit 7151b22
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
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

0 comments on commit 7151b22

Please sign in to comment.