From 7e845fb0b320107992796987608a3c86dac74e17 Mon Sep 17 00:00:00 2001 From: Cheng Shi Date: Tue, 22 Apr 2025 20:08:57 -0400 Subject: [PATCH 1/6] feat: add Deaccession reason note --- package-lock.json | 8 +-- package.json | 2 +- public/locales/en/dataset.json | 1 + src/dataset/domain/models/Dataset.ts | 9 ++- .../models/DatasetVersionSummaryInfo.ts | 12 +++- .../infrastructure/mappers/JSDatasetMapper.ts | 4 +- .../mappers/JSDatasetVersionMapper.ts | 6 +- .../dataset-citation/DatasetCitation.tsx | 57 ++++++++++++------- .../dataset-versions/DatasetVersions.tsx | 5 +- .../useDatasetVersionSummaryDescription.tsx | 10 +++- 10 files changed, 77 insertions(+), 37 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8dc105784..4526511ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@dnd-kit/sortable": "8.0.0", "@dnd-kit/utilities": "3.2.2", "@faker-js/faker": "7.6.0", - "@iqss/dataverse-client-javascript": "2.0.0-alpha.37", + "@iqss/dataverse-client-javascript": "2.0.0-pr292.b0a1ddd", "@iqss/dataverse-design-system": "*", "@istanbuljs/nyc-config-typescript": "1.0.2", "@tanstack/react-table": "8.9.2", @@ -3685,9 +3685,9 @@ }, "node_modules/@iqss/dataverse-client-javascript": { "name": "@IQSS/dataverse-client-javascript", - "version": "2.0.0-alpha.37", - "resolved": "https://npm.pkg.github.com/download/@IQSS/dataverse-client-javascript/2.0.0-alpha.37/7761cb0b560317a498b0f75673813d2397752460", - "integrity": "sha512-1G0uV467x84JO/2y13Zo8J+rgjoEYdyWuL4Qp+SvIfdYKlc4DZDxY0O4cCZK5NstNEP0u4SF4W2UslxO6SIcmA==", + "version": "2.0.0-pr292.b0a1ddd", + "resolved": "https://npm.pkg.github.com/download/@IQSS/dataverse-client-javascript/2.0.0-pr292.b0a1ddd/8c4d3045113744267c143f68d23c7e6a1476413c", + "integrity": "sha512-THFWMZRqVuajeJcjNmdEgXrgGdScHJ09E2nMiuB4RLHzYOX5IB/OOMkyo8c04jq5dAB+8ePw9TfNV9evEdK2Rg==", "license": "MIT", "dependencies": { "@types/node": "^18.15.11", diff --git a/package.json b/package.json index f2ed127aa..6f15e456a 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@dnd-kit/sortable": "8.0.0", "@dnd-kit/utilities": "3.2.2", "@faker-js/faker": "7.6.0", - "@iqss/dataverse-client-javascript": "2.0.0-alpha.37", + "@iqss/dataverse-client-javascript": "2.0.0-pr292.b0a1ddd", "@iqss/dataverse-design-system": "*", "@istanbuljs/nyc-config-typescript": "1.0.2", "@tanstack/react-table": "8.9.2", diff --git a/public/locales/en/dataset.json b/public/locales/en/dataset.json index 787cb44c4..8e2b77439 100644 --- a/public/locales/en/dataset.json +++ b/public/locales/en/dataset.json @@ -21,6 +21,7 @@ } } }, + "deaccessionReason": "Deaccession Reason", "datasetActionButtons": { "title": "Dataset Action Buttons", "submitForReview": { diff --git a/src/dataset/domain/models/Dataset.ts b/src/dataset/domain/models/Dataset.ts index 5067b442c..7fdda55ed 100644 --- a/src/dataset/domain/models/Dataset.ts +++ b/src/dataset/domain/models/Dataset.ts @@ -255,7 +255,8 @@ export class DatasetVersion { public readonly isInReview: boolean, public readonly latestVersionPublishingStatus: DatasetPublishingStatus, public readonly someDatasetVersionHasBeenReleased: boolean, - public readonly termsOfAccess?: TermsOfAccess + public readonly termsOfAccess?: TermsOfAccess, + public readonly deaccessionNote?: string ) {} static Builder = class { @@ -270,7 +271,8 @@ export class DatasetVersion { public readonly isInReview: boolean, public readonly latestVersionPublishingStatus: DatasetPublishingStatus, public readonly someDatasetVersionHasBeenReleased: boolean, - public readonly termsOfAccess?: TermsOfAccess + public readonly termsOfAccess?: TermsOfAccess, + public readonly deaccessionNote?: string ) { this.createLabels() } @@ -337,7 +339,8 @@ export class DatasetVersion { this.isInReview, this.latestVersionPublishingStatus, this.someDatasetVersionHasBeenReleased, - this.termsOfAccess + this.termsOfAccess, + this.deaccessionNote ) } } diff --git a/src/dataset/domain/models/DatasetVersionSummaryInfo.ts b/src/dataset/domain/models/DatasetVersionSummaryInfo.ts index ab463c8c5..021e86c1f 100644 --- a/src/dataset/domain/models/DatasetVersionSummaryInfo.ts +++ b/src/dataset/domain/models/DatasetVersionSummaryInfo.ts @@ -7,7 +7,17 @@ export interface DatasetVersionSummaryInfo { } export type DatasetVersionSummary = { - [key: string]: SummaryUpdates | SummaryUpdatesWithFields | FilesSummaryUpdates | boolean + [key: string]: + | SummaryUpdates + | SummaryUpdatesWithFields + | FilesSummaryUpdates + | Deaccessioned + | boolean +} + +export interface Deaccessioned { + reason: string + url: string } export interface SummaryUpdates { diff --git a/src/dataset/infrastructure/mappers/JSDatasetMapper.ts b/src/dataset/infrastructure/mappers/JSDatasetMapper.ts index 454e07023..6b4fcc572 100644 --- a/src/dataset/infrastructure/mappers/JSDatasetMapper.ts +++ b/src/dataset/infrastructure/mappers/JSDatasetMapper.ts @@ -57,7 +57,9 @@ export class JSDatasetMapper { jsDataset.versionInfo, JSDatasetMapper.toDatasetTitle(jsDataset.metadataBlocks), jsDatasetCitation, - jsDataset.publicationDate + jsDataset.publicationDate, + jsDataset.termsOfUse?.termsOfAccess, + jsDataset.versionInfo.deaccessionNote as string ) return new Dataset.Builder( jsDataset.persistentId, diff --git a/src/dataset/infrastructure/mappers/JSDatasetVersionMapper.ts b/src/dataset/infrastructure/mappers/JSDatasetVersionMapper.ts index 0b780b519..63b3fc8a3 100644 --- a/src/dataset/infrastructure/mappers/JSDatasetVersionMapper.ts +++ b/src/dataset/infrastructure/mappers/JSDatasetVersionMapper.ts @@ -16,7 +16,8 @@ export class JSDatasetVersionMapper { jsDatasetTitle: string, jsDatasetCitation: string, jsDatasetPublicationDate?: string, - jsDatasettermsOfAccess?: TermsOfAccess + jsDatasettermsOfAccess?: TermsOfAccess, + jsDatasetDeaccessionedNote?: string ): DatasetVersion { return new DatasetVersion.Builder( jDatasetVersionId, @@ -28,7 +29,8 @@ export class JSDatasetVersionMapper { false, // TODO Connect with dataset version isInReview this.toStatus(jsDatasetVersionInfo.state), this.toSomeDatasetVersionHasBeenReleased(jsDatasetVersionInfo, jsDatasetPublicationDate), - jsDatasettermsOfAccess + jsDatasettermsOfAccess, + jsDatasetDeaccessionedNote ) } diff --git a/src/sections/dataset/dataset-citation/DatasetCitation.tsx b/src/sections/dataset/dataset-citation/DatasetCitation.tsx index e9f05f3f2..d80bdbb6d 100644 --- a/src/sections/dataset/dataset-citation/DatasetCitation.tsx +++ b/src/sections/dataset/dataset-citation/DatasetCitation.tsx @@ -1,10 +1,11 @@ -import { Col, Row } from '@iqss/dataverse-design-system' -import styles from './DatasetCitation.module.scss' +import { useTranslation } from 'react-i18next' +import { Col, Row, Stack } from '@iqss/dataverse-design-system' import { DatasetPublishingStatus, DatasetVersion } from '../../../dataset/domain/models/Dataset' import { DatasetThumbnail } from '../dataset-thumbnail/DatasetThumbnail' import { CitationDescription } from '../../shared/citation/CitationDescription' import { DatasetCitationTooltip } from './DatasetCitationTooltip' import { CitationLearnAbout } from '../../shared/citation/CitationLearnAbout' +import styles from './DatasetCitation.module.scss' interface DatasetCitationProps { thumbnail?: string @@ -13,29 +14,41 @@ interface DatasetCitationProps { } export function DatasetCitation({ thumbnail, version, withoutThumbnail }: DatasetCitationProps) { + const { t } = useTranslation('dataset') + return ( - - {!withoutThumbnail && ( - - + + {!withoutThumbnail && ( + + + + )} + + } /> + + + {version.publishingStatus === DatasetPublishingStatus.DEACCESSIONED && ( + + + {t('deaccessionReason')} + + {version.deaccessionNote} + )} - - } - /> - - - + ) } diff --git a/src/sections/dataset/dataset-versions/DatasetVersions.tsx b/src/sections/dataset/dataset-versions/DatasetVersions.tsx index 3f1ad42e9..b3944c083 100644 --- a/src/sections/dataset/dataset-versions/DatasetVersions.tsx +++ b/src/sections/dataset/dataset-versions/DatasetVersions.tsx @@ -29,6 +29,7 @@ export function DatasetVersions({ datasetRepository, datasetId }: DatasetVersion datasetRepository, persistentId: datasetId }) + console.log('datasetVersionSummaries', datasetVersionSummaries) const handleCheckboxChange = (datasetSummary: DatasetVersionSummaryInfo) => { setSelectedVersions((prevSelected) => { @@ -114,9 +115,9 @@ export function DatasetVersions({ datasetRepository, datasetId }: DatasetVersion -

+

- {previousDataset && ( + {previousDataset && typeof dataset.summary !== 'string' && ( Date: Wed, 23 Apr 2025 12:09:09 -0400 Subject: [PATCH 2/6] feat: add tests --- .../dataset/domain/models/DatasetMother.ts | 1 + .../dataset-citation/DatasetCitation.spec.tsx | 7 +++++++ .../useDatasetVersionSummaryDescription.spec.tsx | 14 +++++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/component/dataset/domain/models/DatasetMother.ts b/tests/component/dataset/domain/models/DatasetMother.ts index 5f3c107d3..109d15bbf 100644 --- a/tests/component/dataset/domain/models/DatasetMother.ts +++ b/tests/component/dataset/domain/models/DatasetMother.ts @@ -51,6 +51,7 @@ export class DatasetVersionMother { citation: 'Admin, Dataverse, 2023, "Dataset Title", https://doi.org/10.5072/FK2/BUDNRV, Root, V1 DEACCESSIONED VERSION', someDatasetVersionHasBeenReleased: true, + deaccessionNote: 'This dataset has been deaccessioned.', ...props }) } diff --git a/tests/component/sections/dataset/dataset-citation/DatasetCitation.spec.tsx b/tests/component/sections/dataset/dataset-citation/DatasetCitation.spec.tsx index 4f5558af3..1fa3ef2c0 100644 --- a/tests/component/sections/dataset/dataset-citation/DatasetCitation.spec.tsx +++ b/tests/component/sections/dataset/dataset-citation/DatasetCitation.spec.tsx @@ -40,6 +40,13 @@ describe('DatasetCitation', () => { ).should('exist') }) + it('shows the deaccessioned reason when version is deaccessioned', () => { + const version = DatasetVersionMother.createDeaccessioned() + cy.customMount() + + cy.findByText(/Deaccession Reason/).should('exist') + }) + it('does not render the thumbnail when withoutThumbnail prop is true', () => { const version = DatasetVersionMother.createRealistic() cy.customMount() diff --git a/tests/component/sections/dataset/dataset-versions/useDatasetVersionSummaryDescription.spec.tsx b/tests/component/sections/dataset/dataset-versions/useDatasetVersionSummaryDescription.spec.tsx index 60e04cad5..7f204d7ff 100644 --- a/tests/component/sections/dataset/dataset-versions/useDatasetVersionSummaryDescription.spec.tsx +++ b/tests/component/sections/dataset/dataset-versions/useDatasetVersionSummaryDescription.spec.tsx @@ -48,12 +48,16 @@ describe('useDatasetVersionSummaryDescription', () => { expect(result.current).to.deep.equal({ firstPublished: 'This is the First Published Version.' }) }) - it('returns correct values for version deaccessioned', () => { - const { result } = renderHook(() => - useDatasetVersionSummaryDescription(DatasetVersionSummaryStringValues.versionDeaccessioned) - ) + it('returns correct values for deaccessioned dataset', () => { + const deaccessionedSummary = { + deaccessioned: { + reason: 'The research article has been retracted.', + url: '' + } + } + const { result } = renderHook(() => useDatasetVersionSummaryDescription(deaccessionedSummary)) expect(result.current).to.deep.equal({ - versionDeaccessioned: 'Deaccessioned Reason: The research article has been retracted.' + 'Deaccessioned Reason': 'The research article has been retracted.' }) }) From ec591e90560a1d4593af7725f22ffcbd243593db Mon Sep 17 00:00:00 2001 From: Cheng Shi Date: Wed, 23 Apr 2025 15:09:12 -0400 Subject: [PATCH 3/6] fix: tests --- .../mappers/JSDatasetMapper.spec.ts | 28 ++++++++++++---- .../DatasetJSDataverseRepository.spec.ts | 32 +++++++++++++++---- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/tests/component/dataset/infrastructure/mappers/JSDatasetMapper.spec.ts b/tests/component/dataset/infrastructure/mappers/JSDatasetMapper.spec.ts index 1d1eb545a..771528380 100644 --- a/tests/component/dataset/infrastructure/mappers/JSDatasetMapper.spec.ts +++ b/tests/component/dataset/infrastructure/mappers/JSDatasetMapper.spec.ts @@ -25,6 +25,16 @@ import { chai.use(chaiAsPromised) const expect = chai.expect +const termsOfAccess = { + fileAccessRequest: true, + termsOfAccess: 'New terms', + dataAccessPlace: 'New place', + originalArchive: 'New archive', + availabilityStatus: 'New status', + contactForAccess: 'New contact', + sizeOfCollection: 'New size', + studyCompletion: 'New completion' +} const jsDataset = { id: 505, persistentId: 'doi:10.5072/FK2/B4B2MJ', @@ -35,7 +45,8 @@ const jsDataset = { minorNumber: 0, createTime: new Date('2023-09-07T13:40:04.000Z'), lastUpdateTime: new Date('2023-09-07T13:40:04.000Z'), - releaseTime: undefined + releaseTime: undefined, + deaccessionNote: undefined }, internalVersionNumber: 1, termsOfUse: { @@ -246,7 +257,8 @@ const expectedDataset = { majorNumber: 0 }, someDatasetVersionHasBeenReleased: false, - termsOfAccess: undefined, + termsOfAccess: termsOfAccess, + deaccessionNote: undefined, citation: 'Finch, Fiona, 2023, "Darwin\'s Finches", https://doi.org/10.5072/FK2/B4B2MJ, Root, DRAFT VERSION' }, @@ -381,7 +393,8 @@ const expectedDatasetWithPublicationDate = { publishingStatus: 'draft', isLatest: true, isInReview: false, - termsOfAccess: undefined, + termsOfAccess: termsOfAccess, + deaccessionNote: undefined, latestVersionPublishingStatus: 'draft', number: { minorNumber: 0, @@ -529,7 +542,8 @@ const expectedDatasetWithNextVersionNumbers = { majorNumber: 0 }, someDatasetVersionHasBeenReleased: true, - termsOfAccess: undefined, + termsOfAccess: termsOfAccess, + deaccessionNote: undefined, citation: 'Finch, Fiona, 2023, "Darwin\'s Finches", https://doi.org/10.5072/FK2/B4B2MJ, Root, DRAFT VERSION' }, @@ -675,7 +689,8 @@ const expectedDatasetAlternateVersion = { majorNumber: 0 }, someDatasetVersionHasBeenReleased: false, - termsOfAccess: undefined, + termsOfAccess: termsOfAccess, + deaccessionNote: undefined, citation: 'Finch, Fiona, 2023, "Darwin\'s Finches", https://doi.org/10.5072/FK2/B4B2MJ, Root, DRAFT VERSION' }, @@ -825,7 +840,6 @@ describe('JS Dataset Mapper', () => { jsDatasetFilesTotalArchivalDownloadSize, jsDatasetVersionSummaries ) - expect(mapped).to.deep.equal(expectedDataset) }) @@ -950,6 +964,7 @@ describe('JS Dataset Mapper', () => { expect(expectedDatasetWithPublicationDate).to.deep.equal(actual) }) + it('maps jsDataset model to the domain Dataset model when latest published version numbers are provided', () => { const jsDatasetWithPublicationDate = { ...jsDataset, @@ -974,6 +989,7 @@ describe('JS Dataset Mapper', () => { ) expect(expectedDatasetWithNextVersionNumbers).to.deep.equal(actual) }) + it('maps jsDataset model to the domain Dataset model when datasetVersionDiff is provided', () => { const latestPublishedVersionMajorNumber = 1 const latestPublishedVersionMinorNumber = 2 diff --git a/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts b/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts index 8714b47b9..02c4f9451 100644 --- a/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts +++ b/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts @@ -46,6 +46,16 @@ function getCitationString(persistentId: string, version: 'DRAFT VERSION' | 'V1' persistentId )}" target="_blank">${getPersistentIdUrl(persistentId)}, Root, ${version}` } +const termsOfUse = { + fileAccessRequest: true, + dataAccessPlace: undefined, + originalArchive: undefined, + availabilityStatus: undefined, + contactForAccess: undefined, + sizeOfCollection: undefined, + studyCompletion: undefined, + termsOfAccessForRestrictedFiles: undefined +} const datasetData = (persistentId: string, versionId: number) => { return { @@ -117,11 +127,18 @@ const datasetData = (persistentId: string, versionId: number) => { citation: getCitationString(persistentId, 'DRAFT VERSION'), title: "Darwin's Finches", labels: [ - { semanticMeaning: 'dataset', value: 'Draft' }, - { semanticMeaning: 'warning', value: 'Unpublished' } + { + semanticMeaning: 'dataset', + value: 'Draft' + }, + { + semanticMeaning: 'warning', + value: 'Unpublished' + } ], someDatasetVersionHasBeenReleased: false, - termsOfAccess: undefined + termsOfAccess: termsOfUse, + deaccessionNote: undefined }, versionsSummaries: [ { @@ -173,7 +190,6 @@ describe('Dataset JSDataverse Repository', () => { throw new Error('Dataset not found') } const datasetExpected = datasetData(dataset.persistentId, dataset.version.id) - expect(dataset.license).to.deep.equal(datasetExpected.license) expect(dataset.metadataBlocks).to.deep.equal(datasetExpected.metadataBlocks) expect(dataset.summaryFields).to.deep.equal(datasetExpected.summaryFields) @@ -217,7 +233,9 @@ describe('Dataset JSDataverse Repository', () => { true, false, DatasetPublishingStatus.RELEASED, - true + true, + termsOfUse, + undefined ) const expectedPublicationDate = getCurrentDateInYYYYMMDDFormat() expect(dataset.version).to.deep.equal(newVersion) @@ -262,7 +280,9 @@ describe('Dataset JSDataverse Repository', () => { true, false, DatasetPublishingStatus.RELEASED, - true + true, + termsOfUse, + undefined ) const expectedPublicationDate = getCurrentDateInYYYYMMDDFormat() expect(dataset.version).to.deep.equal(newVersion) From 90cffbef3a5e98709f76ff1e061aba281cfdaeff Mon Sep 17 00:00:00 2001 From: Cheng Shi Date: Wed, 23 Apr 2025 16:43:27 -0400 Subject: [PATCH 4/6] fix: delete console.log --- src/sections/dataset/dataset-versions/DatasetVersions.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sections/dataset/dataset-versions/DatasetVersions.tsx b/src/sections/dataset/dataset-versions/DatasetVersions.tsx index b3944c083..1f66d34a4 100644 --- a/src/sections/dataset/dataset-versions/DatasetVersions.tsx +++ b/src/sections/dataset/dataset-versions/DatasetVersions.tsx @@ -29,7 +29,6 @@ export function DatasetVersions({ datasetRepository, datasetId }: DatasetVersion datasetRepository, persistentId: datasetId }) - console.log('datasetVersionSummaries', datasetVersionSummaries) const handleCheckboxChange = (datasetSummary: DatasetVersionSummaryInfo) => { setSelectedVersions((prevSelected) => { From 6d559984b9dc91c5b38c9635908d9c2f8862b771 Mon Sep 17 00:00:00 2001 From: Cheng Shi Date: Mon, 28 Apr 2025 12:08:53 -0400 Subject: [PATCH 5/6] fix: update styling problem and useTranslation to summarydescription --- public/locales/en/dataset.json | 7 ++++++- .../DatasetCitation.module.scss | 2 ++ .../useDatasetVersionSummaryDescription.tsx | 18 ++++++++++-------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/public/locales/en/dataset.json b/public/locales/en/dataset.json index 8e2b77439..9d7ac9a30 100644 --- a/public/locales/en/dataset.json +++ b/public/locales/en/dataset.json @@ -231,6 +231,9 @@ "version": "Version", "lastUpdated": "Last Updated", "files": "Files", + "filesAsKey": "files", + "termsAccessChangedAsKey": "termsAccessChanged", + "deaccessionedAsKey": "deaccessioned", "citationMetadata": "Citation Metadata", "additionalCitationMetadata": "Additional Citation Metadata", "termsAccess": "Terms of Use and Access", @@ -242,7 +245,9 @@ "access": "Access", "needTwoVersions": "Please select two versions to view the differences.", "viewDetails": "View Details", - "replace": "File Replace" + "replace": "File Replace", + "termsOfUseandAccess": "Terms of Use/Access", + "deaccessionedReason": "Deaccessioned Reason" }, "getDatasetVersionDiffError": "Error Fetching Dataset Version Differences", "datasetVersionSummary": { diff --git a/src/sections/dataset/dataset-citation/DatasetCitation.module.scss b/src/sections/dataset/dataset-citation/DatasetCitation.module.scss index 3a4b0fcfd..384870bb1 100644 --- a/src/sections/dataset/dataset-citation/DatasetCitation.module.scss +++ b/src/sections/dataset/dataset-citation/DatasetCitation.module.scss @@ -4,12 +4,14 @@ margin: 0 0 20px; padding: 10px 0; border: 1px solid $dv-info-border-color; + border-radius: 4px; } .deaccessioned { margin: 0.5rem 0; padding: 10px; border: 1px solid $dv-danger-color; + border-radius: 4px; } .row { diff --git a/src/sections/dataset/dataset-versions/useDatasetVersionSummaryDescription.tsx b/src/sections/dataset/dataset-versions/useDatasetVersionSummaryDescription.tsx index a0fabd913..ae0703fb9 100644 --- a/src/sections/dataset/dataset-versions/useDatasetVersionSummaryDescription.tsx +++ b/src/sections/dataset/dataset-versions/useDatasetVersionSummaryDescription.tsx @@ -32,7 +32,7 @@ export const useDatasetVersionSummaryDescription = ( Object.entries(summary).forEach(([key, value]) => { switch (key) { - case 'Citation Metadata': { + case t('versions.citationMetadata'): { const metadataChanges: string[] = [] Object.entries(value as Record).forEach(([field, change]) => { @@ -50,7 +50,7 @@ export const useDatasetVersionSummaryDescription = ( break } - case 'Additional Citation Metadata': { + case t('versions.additionalCitationMetadata'): { const additionalChanges: string[] = [] const additionalMetadata = value as SummaryUpdates @@ -77,7 +77,7 @@ export const useDatasetVersionSummaryDescription = ( break } - case 'files': { + case t('versions.filesAsKey'): { const fileSummary = value as FilesSummaryUpdates const fileChanges: string[] = [] @@ -102,19 +102,21 @@ export const useDatasetVersionSummaryDescription = ( }) ) - if (fileChanges.length) description['Files'] = fileChanges.join('; ') + if (fileChanges.length) description[t('versions.files')] = fileChanges.join('; ') break } - case 'termsAccessChanged': + case t('versions.termsAccessChangedAsKey'): if (value) - description['Terms of Use/Access'] = t('datasetVersionSummary.termsAccessChanged') + description[t('versions.termsOfUseandAccess')] = t( + 'datasetVersionSummary.termsAccessChanged' + ) break - case 'deaccessioned': + case t('versions.deaccessionedAsKey'): if (value) { const deaccessioned = value as Deaccessioned - description['Deaccessioned Reason'] = deaccessioned.reason + description[t('versions.deaccessionedReason')] = deaccessioned.reason } break } From 5ba8cd5e3f9b3b1adc8ea9b5a301a6ad6438f4c8 Mon Sep 17 00:00:00 2001 From: Cheng Shi Date: Mon, 28 Apr 2025 12:24:22 -0400 Subject: [PATCH 6/6] fix: reverse useTranslation to summarydescription switch cases --- public/locales/en/dataset.json | 3 --- .../useDatasetVersionSummaryDescription.tsx | 10 +++++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/public/locales/en/dataset.json b/public/locales/en/dataset.json index 9d7ac9a30..b966fde1f 100644 --- a/public/locales/en/dataset.json +++ b/public/locales/en/dataset.json @@ -231,9 +231,6 @@ "version": "Version", "lastUpdated": "Last Updated", "files": "Files", - "filesAsKey": "files", - "termsAccessChangedAsKey": "termsAccessChanged", - "deaccessionedAsKey": "deaccessioned", "citationMetadata": "Citation Metadata", "additionalCitationMetadata": "Additional Citation Metadata", "termsAccess": "Terms of Use and Access", diff --git a/src/sections/dataset/dataset-versions/useDatasetVersionSummaryDescription.tsx b/src/sections/dataset/dataset-versions/useDatasetVersionSummaryDescription.tsx index ae0703fb9..24002c91e 100644 --- a/src/sections/dataset/dataset-versions/useDatasetVersionSummaryDescription.tsx +++ b/src/sections/dataset/dataset-versions/useDatasetVersionSummaryDescription.tsx @@ -32,7 +32,7 @@ export const useDatasetVersionSummaryDescription = ( Object.entries(summary).forEach(([key, value]) => { switch (key) { - case t('versions.citationMetadata'): { + case 'Citation Metadata': { const metadataChanges: string[] = [] Object.entries(value as Record).forEach(([field, change]) => { @@ -50,7 +50,7 @@ export const useDatasetVersionSummaryDescription = ( break } - case t('versions.additionalCitationMetadata'): { + case 'Additional Citation Metadata': { const additionalChanges: string[] = [] const additionalMetadata = value as SummaryUpdates @@ -77,7 +77,7 @@ export const useDatasetVersionSummaryDescription = ( break } - case t('versions.filesAsKey'): { + case 'files': { const fileSummary = value as FilesSummaryUpdates const fileChanges: string[] = [] @@ -106,14 +106,14 @@ export const useDatasetVersionSummaryDescription = ( break } - case t('versions.termsAccessChangedAsKey'): + case 'termsAccessChanged': if (value) description[t('versions.termsOfUseandAccess')] = t( 'datasetVersionSummary.termsAccessChanged' ) break - case t('versions.deaccessionedAsKey'): + case 'deaccessioned': if (value) { const deaccessioned = value as Deaccessioned description[t('versions.deaccessionedReason')] = deaccessioned.reason