diff --git a/src/collection/domain/models/Collection.ts b/src/collection/domain/models/Collection.ts index fbe81fd6e..003250eff 100644 --- a/src/collection/domain/models/Collection.ts +++ b/src/collection/domain/models/Collection.ts @@ -4,6 +4,7 @@ export interface Collection { id: string name: string hierarchy: UpwardHierarchyNode + isReleased: boolean description?: string affiliation?: string } diff --git a/src/collection/infrastructure/mappers/JSCollectionMapper.ts b/src/collection/infrastructure/mappers/JSCollectionMapper.ts index aeeebc4ad..e4d036fa3 100644 --- a/src/collection/infrastructure/mappers/JSCollectionMapper.ts +++ b/src/collection/infrastructure/mappers/JSCollectionMapper.ts @@ -14,6 +14,7 @@ export class JSCollectionMapper { return { id: jsCollection.alias, name: jsCollection.name, + isReleased: true, // TODO: replace with real value, waiting for https://github.com/IQSS/dataverse-client-javascript/issues/139 description: jsCollection.description, affiliation: jsCollection.affiliation, hierarchy: JSCollectionMapper.toHierarchy( diff --git a/src/sections/collection/Collection.module.scss b/src/sections/collection/Collection.module.scss index 8723f4da4..0b2d0fc18 100644 --- a/src/sections/collection/Collection.module.scss +++ b/src/sections/collection/Collection.module.scss @@ -12,6 +12,11 @@ margin-bottom: $spacer; } +.infoContainer { + display: flex; + gap: 10px; +} + .subtext { color: $dv-subtext-color; } \ No newline at end of file diff --git a/src/sections/collection/CollectionInfo.tsx b/src/sections/collection/CollectionInfo.tsx index 220815991..8c2d2ee45 100644 --- a/src/sections/collection/CollectionInfo.tsx +++ b/src/sections/collection/CollectionInfo.tsx @@ -1,6 +1,8 @@ import { Collection } from '../../collection/domain/models/Collection' import styles from './Collection.module.scss' import { MarkdownComponent } from '../dataset/markdown/MarkdownComponent' +import { Badge } from '@iqss/dataverse-design-system' +import { DatasetLabelSemanticMeaning } from '../../dataset/domain/models/Dataset' interface CollectionInfoProps { collection: Collection @@ -11,9 +13,14 @@ export function CollectionInfo({ collection }: CollectionInfoProps) { <>

{collection.name}

- {collection.affiliation && ( - ({collection.affiliation}) - )} +
+ {collection.affiliation && ( + ({collection.affiliation}) + )} + {!collection.isReleased && ( + Unpublished + )} +
{collection.description && (
diff --git a/src/stories/collection/CollectionInfo.stories.tsx b/src/stories/collection/CollectionInfo.stories.tsx index f7d932c9e..67e7b2d74 100644 --- a/src/stories/collection/CollectionInfo.stories.tsx +++ b/src/stories/collection/CollectionInfo.stories.tsx @@ -24,6 +24,9 @@ export const WithAffiliation: Story = { render: () => } +export const Unpublished: Story = { + render: () => +} export const WithDescription: Story = { render: () => } diff --git a/tests/component/collection/domain/models/CollectionMother.ts b/tests/component/collection/domain/models/CollectionMother.ts index 157b872d7..b5441d735 100644 --- a/tests/component/collection/domain/models/CollectionMother.ts +++ b/tests/component/collection/domain/models/CollectionMother.ts @@ -8,6 +8,7 @@ export class CollectionMother { return { id: faker.datatype.uuid(), name: faker.lorem.words(3), + isReleased: faker.datatype.boolean(), description: faker.datatype.boolean() ? `${faker.lorem.paragraph()} **${faker.lorem.sentence()}** ${faker.lorem.paragraph()}` : undefined, @@ -20,6 +21,7 @@ export class CollectionMother { static createRealistic(): Collection { return CollectionMother.create({ id: 'science', + isReleased: true, name: 'Collection Name', description: 'We do all the science.', affiliation: 'Scientific Research University' @@ -30,6 +32,7 @@ export class CollectionMother { return CollectionMother.create({ id: faker.datatype.uuid(), name: FakerHelper.collectionName(), + isReleased: faker.datatype.boolean(), affiliation: undefined, description: undefined, ...props @@ -39,12 +42,18 @@ export class CollectionMother { static createComplete(): Collection { return CollectionMother.create({ id: faker.datatype.uuid(), + isReleased: faker.datatype.boolean(), name: FakerHelper.collectionName(), description: FakerHelper.paragraph(), affiliation: FakerHelper.affiliation() }) } - + static createUnpublished(): Collection { + return CollectionMother.createWithOnlyRequiredFields({ + isReleased: false, + affiliation: FakerHelper.affiliation() + }) + } static createWithDescription(): Collection { return CollectionMother.createWithOnlyRequiredFields({ description: FakerHelper.paragraph() diff --git a/tests/component/sections/collection/CollectionInfo.spec.tsx b/tests/component/sections/collection/CollectionInfo.spec.tsx index b3bd13073..08fb12bd3 100644 --- a/tests/component/sections/collection/CollectionInfo.spec.tsx +++ b/tests/component/sections/collection/CollectionInfo.spec.tsx @@ -6,6 +6,7 @@ describe('CollectionInfo', () => { const collection = CollectionMother.create({ name: 'Collection Name', affiliation: 'Affiliation', + isReleased: true, description: 'Here is a description with [a link](https://dataverse.org)' }) cy.customMount() @@ -14,6 +15,7 @@ describe('CollectionInfo', () => { cy.findByText('(Affiliation)').should('exist') cy.findByText(/Here is a description with/).should('exist') cy.findByRole('link', { name: 'a link' }).should('exist') + cy.findByText('Unpublished').should('not.exist') }) it('does not render affiliation when it is not present', () => { @@ -33,4 +35,10 @@ describe('CollectionInfo', () => { cy.findByText('Description').should('not.exist') }) + it('renders unpublished label when isReleased is false', () => { + const collection = CollectionMother.createUnpublished() + cy.customMount() + + cy.findByText('Unpublished').should('exist') + }) }) diff --git a/tests/e2e-integration/integration/collection/CollectionJSDataverseRepository.spec.ts b/tests/e2e-integration/integration/collection/CollectionJSDataverseRepository.spec.ts index 494fa33c0..a2534020a 100644 --- a/tests/e2e-integration/integration/collection/CollectionJSDataverseRepository.spec.ts +++ b/tests/e2e-integration/integration/collection/CollectionJSDataverseRepository.spec.ts @@ -12,6 +12,7 @@ const collectionExpected = { id: 'new-collection', name: 'Scientific Research', description: 'We do all the science.', + isReleased: true, affiliation: 'Scientific Research University', hierarchy: new UpwardHierarchyNode( 'Scientific Research',