forked from uncch-rdmc/dataverse-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request IQSS#202 from IQSS/feature/130-dataset-citation-th…
…umbnail 130 - Dataset citation thumbnail
- Loading branch information
Showing
16 changed files
with
175 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/sections/dataset/dataset-citation/CitationThumbnail.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { DatasetPublishingStatus } from '../../../dataset/domain/models/Dataset' | ||
import styles from './DatasetCitation.module.scss' | ||
import { Icon, IconName } from '@iqss/dataverse-design-system' | ||
|
||
interface CitationThumbnailProps { | ||
thumbnail?: string | ||
title: string | ||
publishingStatus: DatasetPublishingStatus | ||
} | ||
|
||
export function CitationThumbnail({ thumbnail, title, publishingStatus }: CitationThumbnailProps) { | ||
if (thumbnail && publishingStatus !== DatasetPublishingStatus.DEACCESSIONED) { | ||
return <img className={styles['preview-image']} src={thumbnail} alt={title} /> | ||
} | ||
|
||
return ( | ||
<div className={styles.icon}> | ||
<Icon name={IconName.DATASET} /> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
tests/component/sections/dataset/dataset-citation/CitationThumbnail.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { DatasetPublishingStatus } from '../../../../../src/dataset/domain/models/Dataset' | ||
import { CitationThumbnail } from '../../../../../src/sections/dataset/dataset-citation/CitationThumbnail' | ||
|
||
describe('CitationThumbnail', () => { | ||
it('renders the dataset icon when there is no thumbnail', () => { | ||
cy.customMount( | ||
<CitationThumbnail | ||
title="Dataset title" | ||
publishingStatus={DatasetPublishingStatus.RELEASED} | ||
/> | ||
) | ||
|
||
cy.findByLabelText('icon-dataset').should('exist') | ||
}) | ||
|
||
it('renders the dataset icon when the dataset is deaccessioned', () => { | ||
cy.customMount( | ||
<CitationThumbnail | ||
title="Dataset title" | ||
thumbnail="https://example.com/image.png" | ||
publishingStatus={DatasetPublishingStatus.DEACCESSIONED} | ||
/> | ||
) | ||
|
||
cy.findByLabelText('icon-dataset').should('exist') | ||
}) | ||
|
||
it('renders the dataset thumbnail when there is one and the dataset is not deaccessioned', () => { | ||
cy.customMount( | ||
<CitationThumbnail | ||
thumbnail="https://example.com/image.png" | ||
title="Dataset title" | ||
publishingStatus={DatasetPublishingStatus.RELEASED} | ||
/> | ||
) | ||
|
||
cy.findByRole('img', { name: 'Dataset title' }).should('exist') | ||
}) | ||
}) |
Oops, something went wrong.