diff --git a/package-lock.json b/package-lock.json index 43ea433c7..795548cfa 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.39", + "@iqss/dataverse-client-javascript": "2.0.0-alpha.42", "@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.39", - "resolved": "https://npm.pkg.github.com/download/@IQSS/dataverse-client-javascript/2.0.0-alpha.39/ad1dbb3ecd7e37e34b4b6aac358eb80e7735bee7", - "integrity": "sha512-TMOdQInt+ArinjBcQcmlwCKyO0ORCVrqhNlPHYKDBQ+xzm4FAVykS+nxInE3mfVYqQ9Twp6Q7nS+we3I8H7PVg==", + "version": "2.0.0-alpha.42", + "resolved": "https://npm.pkg.github.com/download/@IQSS/dataverse-client-javascript/2.0.0-alpha.42/9bb5781e9a747fbe2e07dc74e8550b42c0efb9e9", + "integrity": "sha512-qx2hLDTKx/7vnj7jkNpzguXaNzcmmtDvoQVJaCewrw1+ogH2G+pv9S40dDTJK7Wf8Zuxz6uxsUvA9O9WcurdNQ==", "license": "MIT", "dependencies": { "@types/node": "^18.15.11", diff --git a/package.json b/package.json index 958841385..fe5dc7e9e 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.39", + "@iqss/dataverse-client-javascript": "2.0.0-alpha.42", "@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 2c7e07861..208b50316 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": { @@ -247,7 +248,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/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 fb18d915c..021e86c1f 100644 --- a/src/dataset/domain/models/DatasetVersionSummaryInfo.ts +++ b/src/dataset/domain/models/DatasetVersionSummaryInfo.ts @@ -15,9 +15,9 @@ export type DatasetVersionSummary = { | boolean } -interface Deaccessioned { - deaccessionReason: string - deaccessionURL: string +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.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-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..1f66d34a4 100644 --- a/src/sections/dataset/dataset-versions/DatasetVersions.tsx +++ b/src/sections/dataset/dataset-versions/DatasetVersions.tsx @@ -114,9 +114,9 @@ export function DatasetVersions({ datasetRepository, datasetId }: DatasetVersion -

+

- {previousDataset && ( + {previousDataset && typeof dataset.summary !== 'string' && ( 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/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/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.' }) }) 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)