Skip to content
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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion public/locales/en/dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
}
}
},
"deaccessionReason": "Deaccession Reason",
"datasetActionButtons": {
"title": "Dataset Action Buttons",
"submitForReview": {
Expand Down Expand Up @@ -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": {
Expand Down
9 changes: 6 additions & 3 deletions src/dataset/domain/models/Dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
}
Expand Down Expand Up @@ -337,7 +339,8 @@ export class DatasetVersion {
this.isInReview,
this.latestVersionPublishingStatus,
this.someDatasetVersionHasBeenReleased,
this.termsOfAccess
this.termsOfAccess,
this.deaccessionNote
)
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/dataset/domain/models/DatasetVersionSummaryInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export type DatasetVersionSummary = {
| boolean
}

interface Deaccessioned {
deaccessionReason: string
deaccessionURL: string
export interface Deaccessioned {
reason: string
url: string
}

export interface SummaryUpdates {
Expand Down
4 changes: 3 additions & 1 deletion src/dataset/infrastructure/mappers/JSDatasetMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions src/dataset/infrastructure/mappers/JSDatasetVersionMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
57 changes: 35 additions & 22 deletions src/sections/dataset/dataset-citation/DatasetCitation.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,29 +14,41 @@ interface DatasetCitationProps {
}

export function DatasetCitation({ thumbnail, version, withoutThumbnail }: DatasetCitationProps) {
const { t } = useTranslation('dataset')

return (
<Row
className={
version.publishingStatus === DatasetPublishingStatus.DEACCESSIONED
? styles.deaccessioned
: styles.container
}>
{!withoutThumbnail && (
<Col sm={2} className={styles.thumbnail}>
<DatasetThumbnail
thumbnail={thumbnail}
title={version.title}
isDeaccessioned={version.publishingStatus === DatasetPublishingStatus.DEACCESSIONED}
<>
<Row
className={
version.publishingStatus === DatasetPublishingStatus.DEACCESSIONED
? styles.deaccessioned
: styles.container
}>
{!withoutThumbnail && (
<Col sm={2} className={styles.thumbnail}>
<DatasetThumbnail
thumbnail={thumbnail}
title={version.title}
isDeaccessioned={version.publishingStatus === DatasetPublishingStatus.DEACCESSIONED}
/>
</Col>
)}
<Col sm={withoutThumbnail ? 12 : 10}>
<CitationDescription
citation={version.citation}
tooltip={<DatasetCitationTooltip status={version.publishingStatus} />}
/>
<CitationLearnAbout />
</Col>
</Row>
{version.publishingStatus === DatasetPublishingStatus.DEACCESSIONED && (
<Row className={styles.deaccessioned}>
<Stack>
<b>{t('deaccessionReason')} </b>
</Stack>
<Stack>{version.deaccessionNote} </Stack>
</Row>
)}
<Col sm={withoutThumbnail ? 12 : 10}>
<CitationDescription
citation={version.citation}
tooltip={<DatasetCitationTooltip status={version.publishingStatus} />}
/>
<CitationLearnAbout />
</Col>
</Row>
</>
)
}
4 changes: 2 additions & 2 deletions src/sections/dataset/dataset-versions/DatasetVersions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ export function DatasetVersions({ datasetRepository, datasetId }: DatasetVersion
</Button>
</td>
<td>
<p style={{ display: 'flex', flexWrap: 'wrap', margin: 0 }}>
<p style={{ display: 'flex', flexWrap: 'wrap', margin: 0, textAlign: 'left' }}>
<SummaryDescription summary={dataset.summary} />
{previousDataset && (
{previousDataset && typeof dataset.summary !== 'string' && (
<DatasetViewDetailButton
datasetRepository={datasetRepository}
oldVersionNumber={previousDataset.versionNumber}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
DatasetVersionSummaryStringValues,
DatasetVersionSummary,
FilesSummaryUpdates,
SummaryUpdates
SummaryUpdates,
Deaccessioned
} from '@/dataset/domain/models/DatasetVersionSummaryInfo'

export const useDatasetVersionSummaryDescription = (
Expand Down Expand Up @@ -101,13 +102,22 @@ export const useDatasetVersionSummaryDescription = (
})
)

if (fileChanges.length) description['Files'] = fileChanges.join('; ')
if (fileChanges.length) description[t('versions.files')] = fileChanges.join('; ')
break
}

case 'termsAccessChanged':
if (value)
description['Terms of Use/Access'] = t('datasetVersionSummary.termsAccessChanged')
description[t('versions.termsOfUseandAccess')] = t(
'datasetVersionSummary.termsAccessChanged'
)
break

case 'deaccessioned':
if (value) {
const deaccessioned = value as Deaccessioned
description[t('versions.deaccessionedReason')] = deaccessioned.reason
}
break
}
})
Expand Down
1 change: 1 addition & 0 deletions tests/component/dataset/domain/models/DatasetMother.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class DatasetVersionMother {
citation:
'Admin, Dataverse, 2023, "Dataset Title", <a href="https://doi.org/10.5072/FK2/BUDNRV" target="_blank">https://doi.org/10.5072/FK2/BUDNRV</a>, Root, V1 DEACCESSIONED VERSION',
someDatasetVersionHasBeenReleased: true,
deaccessionNote: 'This dataset has been deaccessioned.',
...props
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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: {
Expand Down Expand Up @@ -246,7 +257,8 @@ const expectedDataset = {
majorNumber: 0
},
someDatasetVersionHasBeenReleased: false,
termsOfAccess: undefined,
termsOfAccess: termsOfAccess,
deaccessionNote: undefined,
citation:
'Finch, Fiona, 2023, "Darwin\'s Finches", <a href="https://doi.org/10.5072/FK2/B4B2MJ" target="_blank">https://doi.org/10.5072/FK2/B4B2MJ</a>, Root, DRAFT VERSION'
},
Expand Down Expand Up @@ -381,7 +393,8 @@ const expectedDatasetWithPublicationDate = {
publishingStatus: 'draft',
isLatest: true,
isInReview: false,
termsOfAccess: undefined,
termsOfAccess: termsOfAccess,
deaccessionNote: undefined,
latestVersionPublishingStatus: 'draft',
number: {
minorNumber: 0,
Expand Down Expand Up @@ -529,7 +542,8 @@ const expectedDatasetWithNextVersionNumbers = {
majorNumber: 0
},
someDatasetVersionHasBeenReleased: true,
termsOfAccess: undefined,
termsOfAccess: termsOfAccess,
deaccessionNote: undefined,
citation:
'Finch, Fiona, 2023, "Darwin\'s Finches", <a href="https://doi.org/10.5072/FK2/B4B2MJ" target="_blank">https://doi.org/10.5072/FK2/B4B2MJ</a>, Root, DRAFT VERSION'
},
Expand Down Expand Up @@ -675,7 +689,8 @@ const expectedDatasetAlternateVersion = {
majorNumber: 0
},
someDatasetVersionHasBeenReleased: false,
termsOfAccess: undefined,
termsOfAccess: termsOfAccess,
deaccessionNote: undefined,
citation:
'Finch, Fiona, 2023, "Darwin\'s Finches", <a href="https://doi.org/10.5072/FK2/B4B2MJ" target="_blank">https://doi.org/10.5072/FK2/B4B2MJ</a>, Root, DRAFT VERSION'
},
Expand Down Expand Up @@ -825,7 +840,6 @@ describe('JS Dataset Mapper', () => {
jsDatasetFilesTotalArchivalDownloadSize,
jsDatasetVersionSummaries
)

expect(mapped).to.deep.equal(expectedDataset)
})

Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ describe('DatasetCitation', () => {
).should('exist')
})

it('shows the deaccessioned reason when version is deaccessioned', () => {
const version = DatasetVersionMother.createDeaccessioned()
cy.customMount(<DatasetCitation version={version} />)

cy.findByText(/Deaccession Reason/).should('exist')
})

it('does not render the thumbnail when withoutThumbnail prop is true', () => {
const version = DatasetVersionMother.createRealistic()
cy.customMount(<DatasetCitation version={version} withoutThumbnail={true} />)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
})
})

Expand Down
Loading
Loading