From 977a7a07077194ed0efd9da8d1e1de76748ebcb3 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 16 Apr 2024 21:06:51 -0400 Subject: [PATCH 1/5] Add isReleased to Collection model and mapper --- src/collection/domain/models/Collection.ts | 1 + src/collection/infrastructure/mappers/JSCollectionMapper.ts | 1 + 2 files changed, 2 insertions(+) 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( From ae1fb600539f1317cdf10b57a81cf9d5751075f2 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 16 Apr 2024 21:07:22 -0400 Subject: [PATCH 2/5] if isReleased is false, show Unpublished label --- src/sections/collection/Collection.module.scss | 1 + src/sections/collection/CollectionInfo.tsx | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/sections/collection/Collection.module.scss b/src/sections/collection/Collection.module.scss index 8723f4da4..e663e23c8 100644 --- a/src/sections/collection/Collection.module.scss +++ b/src/sections/collection/Collection.module.scss @@ -13,5 +13,6 @@ } .subtext { + margin-right: 5px; 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..8c6702ff0 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 @@ -14,6 +16,9 @@ export function CollectionInfo({ collection }: CollectionInfoProps) { {collection.affiliation && ( ({collection.affiliation}) )} + {!collection.isReleased && ( + Unpublished + )} {collection.description && (
From 74e329a83386e468fa8b55e22f94398a090fe175 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 16 Apr 2024 21:07:40 -0400 Subject: [PATCH 3/5] update stories and tests --- src/stories/collection/CollectionInfo.stories.tsx | 3 +++ .../collection/domain/models/CollectionMother.ts | 11 ++++++++++- .../sections/collection/CollectionInfo.spec.tsx | 8 ++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) 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') + }) }) From b1ce1aed3524b3fd2475a687aecc1a86eb708942 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Wed, 17 Apr 2024 07:31:07 -0400 Subject: [PATCH 4/5] fix:e2e test --- .../collection/CollectionJSDataverseRepository.spec.ts | 1 + 1 file changed, 1 insertion(+) 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', From a510c8ff92ebe9a44a4be17722aa89b66416e6c0 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Wed, 17 Apr 2024 16:43:05 -0400 Subject: [PATCH 5/5] fix: layout --- src/sections/collection/Collection.module.scss | 6 +++++- src/sections/collection/CollectionInfo.tsx | 14 ++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/sections/collection/Collection.module.scss b/src/sections/collection/Collection.module.scss index e663e23c8..0b2d0fc18 100644 --- a/src/sections/collection/Collection.module.scss +++ b/src/sections/collection/Collection.module.scss @@ -12,7 +12,11 @@ margin-bottom: $spacer; } +.infoContainer { + display: flex; + gap: 10px; +} + .subtext { - margin-right: 5px; 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 8c6702ff0..8c2d2ee45 100644 --- a/src/sections/collection/CollectionInfo.tsx +++ b/src/sections/collection/CollectionInfo.tsx @@ -13,12 +13,14 @@ export function CollectionInfo({ collection }: CollectionInfoProps) { <>

{collection.name}

- {collection.affiliation && ( - ({collection.affiliation}) - )} - {!collection.isReleased && ( - Unpublished - )} +
+ {collection.affiliation && ( + ({collection.affiliation}) + )} + {!collection.isReleased && ( + Unpublished + )} +
{collection.description && (