diff --git a/src/sections/dataset/dataset-citation/DatasetCitation.tsx b/src/sections/dataset/dataset-citation/DatasetCitation.tsx index 5fc95d1b9..f1004960d 100644 --- a/src/sections/dataset/dataset-citation/DatasetCitation.tsx +++ b/src/sections/dataset/dataset-citation/DatasetCitation.tsx @@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next' import { DatasetPublishingStatus, DatasetVersion } from '../../../dataset/domain/models/Dataset' import { DatasetThumbnail } from './DatasetThumbnail' import { CitationDescription } from '../../shared/citation/CitationDescription' +import { DatasetCitationTooltip } from './DatasetCitationTooltip' interface DatasetCitationProps { thumbnail?: string @@ -32,7 +33,10 @@ export function DatasetCitation({ thumbnail, title, citation, version }: Dataset - + + + +
diff --git a/src/sections/dataset/dataset-citation/DatasetCitationTooltip.tsx b/src/sections/dataset/dataset-citation/DatasetCitationTooltip.tsx new file mode 100644 index 000000000..0ae1676b1 --- /dev/null +++ b/src/sections/dataset/dataset-citation/DatasetCitationTooltip.tsx @@ -0,0 +1,24 @@ +import { DatasetPublishingStatus } from '../../../dataset/domain/models/Dataset' +import { useTranslation } from 'react-i18next' +import { QuestionMarkTooltip } from '@iqss/dataverse-design-system' + +interface DatasetCitationTooltipProps { + status: DatasetPublishingStatus +} + +export function DatasetCitationTooltip({ status }: DatasetCitationTooltipProps) { + const { t } = useTranslation('dataset') + + if (status !== DatasetPublishingStatus.RELEASED) { + return ( + <> + {' '} + + + ) + } + return <> +} diff --git a/src/sections/home/datasets-list/dataset-card/DatasetCardInfo.tsx b/src/sections/home/datasets-list/dataset-card/DatasetCardInfo.tsx index 1ed0f32fa..76a03a645 100644 --- a/src/sections/home/datasets-list/dataset-card/DatasetCardInfo.tsx +++ b/src/sections/home/datasets-list/dataset-card/DatasetCardInfo.tsx @@ -15,7 +15,7 @@ export function DatasetCardInfo({ dataset }: DatasetCardInfoProps) { className={ dataset.isDeaccessioned ? styles['citation-box-deaccessioned'] : styles['citation-box'] }> - + {dataset.abbreviatedDescription}
diff --git a/src/sections/shared/citation/CitationDescription.tsx b/src/sections/shared/citation/CitationDescription.tsx index e3d99dc36..eb2730bd2 100644 --- a/src/sections/shared/citation/CitationDescription.tsx +++ b/src/sections/shared/citation/CitationDescription.tsx @@ -1,42 +1,11 @@ -import { DatasetPublishingStatus, DatasetVersion } from '../../../dataset/domain/models/Dataset' import parse from 'html-react-parser' -import styles from '../../dataset/dataset-citation/DatasetCitation.module.scss' -import { useTranslation } from 'react-i18next' -import { QuestionMarkTooltip } from '@iqss/dataverse-design-system' interface CitationDescriptionProps { citation: string - version: DatasetVersion } -export function CitationDescription({ citation, version }: CitationDescriptionProps) { +export function CitationDescription({ citation }: CitationDescriptionProps) { const citationAsReactElement = parse(citation) - return ( - - {citationAsReactElement} - - - ) -} - -interface CitationTooltipProps { - status: DatasetPublishingStatus -} - -function CitationTooltip({ status }: CitationTooltipProps) { - const { t } = useTranslation('dataset') - - if (status !== DatasetPublishingStatus.RELEASED) { - return ( - <> - {' '} - - - ) - } - return <> + return {citationAsReactElement} } diff --git a/tests/component/sections/shared/citation/CitationDescription.spec.tsx b/tests/component/sections/shared/citation/CitationDescription.spec.tsx index 54924a7e9..ce5b1a57e 100644 --- a/tests/component/sections/shared/citation/CitationDescription.spec.tsx +++ b/tests/component/sections/shared/citation/CitationDescription.spec.tsx @@ -1,46 +1,12 @@ import { CitationDescription } from '../../../../../src/sections/shared/citation/CitationDescription' -import { DatasetMother } from '../../../dataset/domain/models/DatasetMother' -import { - DatasetPublishingStatus, - DatasetVersion -} from '../../../../../src/dataset/domain/models/Dataset' describe('CitationDescription', () => { it('renders the citation', () => { - const citation = 'This is a citation' - cy.customMount( - - ) + const citation = + 'Finch, Fiona, 2023, "Darwin\'s Finches", https://doi.org/10.5072/FK2/0YFWKL, Root, V1' + cy.customMount() - cy.findByText(citation).should('exist') - }) - - it('renders the citation with a tooltip when the version is not released', () => { - const citation = 'This is a citation' - const dataset = DatasetMother.create({ - version: new DatasetVersion( - 1, - DatasetPublishingStatus.DRAFT, - true, - false, - DatasetPublishingStatus.DRAFT - ) - }) - cy.customMount() - - cy.findByText(citation).should('exist') - cy.findByRole('img', { name: 'tooltip icon' }).should('exist').trigger('mouseover') - cy.findByText( - /DRAFT VERSION will be replaced in the citation with the selected version once the dataset has been published./ - ).should('exist') - }) - - it('does not render the tooltip when the version is released', () => { - const citation = 'This is a citation' - const dataset = DatasetMother.create() - cy.customMount() - - cy.findByText(citation).should('exist') - cy.findByRole('img', { name: 'tooltip icon' }).should('not.exist') + cy.findByText(/Finch, Fiona, 2023, "Darwin's Finches",/).should('exist') + cy.findByRole('link', { name: 'https://doi.org/10.5072/FK2/0YFWKL' }).should('exist') }) })