From 9e4d6b06259237ae99690562c3e44a9a8049b555 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Fri, 1 Dec 2023 09:49:34 -0500 Subject: [PATCH 01/33] use dataverse-client-javascript that implements deaccessioned dataset usecase --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 07dff0099..6ea08d64a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.1.0", "dependencies": { "@faker-js/faker": "7.6.0", - "@iqss/dataverse-client-javascript": "2.0.0-pr99.c36f1db", + "@iqss/dataverse-client-javascript": "2.0.0-pr105.779a3f4", "@iqss/dataverse-design-system": "*", "@istanbuljs/nyc-config-typescript": "1.0.2", "@tanstack/react-table": "8.9.2", @@ -3589,9 +3589,9 @@ }, "node_modules/@iqss/dataverse-client-javascript": { "name": "@IQSS/dataverse-client-javascript", - "version": "2.0.0-pr99.c36f1db", - "resolved": "https://npm.pkg.github.com/download/@IQSS/dataverse-client-javascript/2.0.0-pr99.c36f1db/3f49037b14e53295c39ce787cce53f20b2558ba6", - "integrity": "sha512-KzMVzB420eKKaOuwDEpvAB/k1RrW3Le/ZJcVtjxFk/Wvxov2Jl1npbwy4SXQWasEXaJWslohn2KRkBfBDoTHTQ==", + "version": "2.0.0-pr105.779a3f4", + "resolved": "https://npm.pkg.github.com/download/@IQSS/dataverse-client-javascript/2.0.0-pr105.779a3f4/1a42052721a2981ed2bab2d051f3cda3ecdec15c", + "integrity": "sha512-56zZUWOhU8mXg4STr/vGJmIGJ+xpUPcqwUenUkREMtT0BhxSoTmwS8xYfdfMvBwW4vEXsli0te+m7XXyyRIKPw==", "license": "MIT", "dependencies": { "@types/node": "^18.15.11", diff --git a/package.json b/package.json index 7de72ef50..23cd989b7 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "7.6.0", - "@iqss/dataverse-client-javascript": "2.0.0-pr99.c36f1db", + "@iqss/dataverse-client-javascript": "2.0.0-pr105.779a3f4", "@iqss/dataverse-design-system": "*", "@istanbuljs/nyc-config-typescript": "1.0.2", "@tanstack/react-table": "8.9.2", From fd2c70b74cd0a16eda1962be4c2b1d67e97c1d6d Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Sat, 2 Dec 2023 11:27:38 -0500 Subject: [PATCH 02/33] feat: add Add Dataset Story and e2e test for Deaccessioned Dataset --- src/stories/dataset/Dataset.stories.tsx | 5 +++ .../dataset/WithDeaccessionedDataset.tsx | 44 +++++++++++++++++++ .../e2e/sections/dataset/Dataset.spec.tsx | 2 +- 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/stories/dataset/WithDeaccessionedDataset.tsx diff --git a/src/stories/dataset/Dataset.stories.tsx b/src/stories/dataset/Dataset.stories.tsx index 0bfd77785..28ff04fc0 100644 --- a/src/stories/dataset/Dataset.stories.tsx +++ b/src/stories/dataset/Dataset.stories.tsx @@ -16,6 +16,7 @@ import { WithDatasetNotFound } from './WithDatasetNotFound' import { WithDatasetLoading } from './WithDatasetLoading' import { WithLoggedInUser } from '../WithLoggedInUser' import { WithAlerts } from '../WithAlerts' +import { WithDeaccessionedDataset } from './WithDeaccessionedDataset' const meta: Meta = { title: 'Pages/Dataset', @@ -39,6 +40,10 @@ export const DraftWithAllDatasetPermissions: Story = { decorators: [WithLayout, WithDatasetDraftAsOwner, WithLoggedInUser, WithFilePermissionsGranted], render: () => } +export const Deaccessioned: Story = { + decorators: [WithLayout, WithDeaccessionedDataset, WithLoggedInUser, WithFilePermissionsGranted], + render: () => +} export const LoggedInAsOwner: Story = { decorators: [WithDataset, WithLayout, WithLoggedInUser, WithFilePermissionsGranted], render: () => diff --git a/src/stories/dataset/WithDeaccessionedDataset.tsx b/src/stories/dataset/WithDeaccessionedDataset.tsx new file mode 100644 index 000000000..d486c3fcf --- /dev/null +++ b/src/stories/dataset/WithDeaccessionedDataset.tsx @@ -0,0 +1,44 @@ +import { StoryFn } from '@storybook/react' +import { DatasetProvider } from '../../sections/dataset/DatasetProvider' +import { DatasetRepository } from '../../dataset/domain/repositories/DatasetRepository' +import { + Dataset, + DatasetPublishingStatus, + DatasetVersion +} from '../../dataset/domain/models/Dataset' +import { DatasetMother } from '../../../tests/component/dataset/domain/models/DatasetMother' + +export const WithDeaccessionedDataset = (Story: StoryFn) => { + const datasetRepository = {} as DatasetRepository + datasetRepository.getByPersistentId = ( + // eslint-disable-next-line unused-imports/no-unused-vars + persistentId: string, + // eslint-disable-next-line unused-imports/no-unused-vars + version?: string | undefined + ): Promise => { + return new Promise((resolve) => { + setTimeout(() => { + resolve( + DatasetMother.createRealistic({ + version: new DatasetVersion( + 1, + DatasetPublishingStatus.DEACCESSIONED, + true, + false, + DatasetPublishingStatus.DEACCESSIONED, + 1, + 0 + ) + }) + ) + }, 1000) + }) + } + return ( + + + + ) +} diff --git a/tests/e2e-integration/e2e/sections/dataset/Dataset.spec.tsx b/tests/e2e-integration/e2e/sections/dataset/Dataset.spec.tsx index 02aa926b9..acd697e73 100644 --- a/tests/e2e-integration/e2e/sections/dataset/Dataset.spec.tsx +++ b/tests/e2e-integration/e2e/sections/dataset/Dataset.spec.tsx @@ -127,7 +127,7 @@ describe('Dataset', () => { }) }) - it.skip('successfully loads a dataset deaccessioned', () => { + it('successfully loads a dataset deaccessioned', () => { // TODO - Implement once the getDatasetCitation includes deaccessioned datasets cy.wrap(DatasetHelper.create()) // eslint-disable-next-line @typescript-eslint/no-unsafe-argument From 2b6fd89d8da3a104a924c0c78d7edaf3917948ca Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Sat, 2 Dec 2023 11:29:06 -0500 Subject: [PATCH 03/33] fix: don't display AccessDatasetMenu if Dataset is deaccessioned --- .../access-dataset-menu/AccessDatasetMenu.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sections/dataset/dataset-action-buttons/access-dataset-menu/AccessDatasetMenu.tsx b/src/sections/dataset/dataset-action-buttons/access-dataset-menu/AccessDatasetMenu.tsx index 542ad49c0..1295249e9 100644 --- a/src/sections/dataset/dataset-action-buttons/access-dataset-menu/AccessDatasetMenu.tsx +++ b/src/sections/dataset/dataset-action-buttons/access-dataset-menu/AccessDatasetMenu.tsx @@ -14,8 +14,7 @@ interface AccessDatasetMenuProps { export function AccessDatasetMenu({ version, permissions }: AccessDatasetMenuProps) { if ( !permissions.canDownloadFiles || - (version.publishingStatus === DatasetPublishingStatus.DEACCESSIONED && - !permissions.canUpdateDataset) + version.publishingStatus === DatasetPublishingStatus.DEACCESSIONED ) { return <> } @@ -31,6 +30,7 @@ export function AccessDatasetMenu({ version, permissions }: AccessDatasetMenuPro ) } + // TODO: add download feature https://github.com/IQSS/dataverse-frontend/issues/63 // TODO: add explore feature // TODO: add compute feature From e6158fc093a4885d56c18c8f2dd92f7cb4bddec1 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Sat, 2 Dec 2023 13:13:52 -0500 Subject: [PATCH 04/33] fix: revert to previous rendering logic --- .../access-dataset-menu/AccessDatasetMenu.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sections/dataset/dataset-action-buttons/access-dataset-menu/AccessDatasetMenu.tsx b/src/sections/dataset/dataset-action-buttons/access-dataset-menu/AccessDatasetMenu.tsx index 1295249e9..e1a587968 100644 --- a/src/sections/dataset/dataset-action-buttons/access-dataset-menu/AccessDatasetMenu.tsx +++ b/src/sections/dataset/dataset-action-buttons/access-dataset-menu/AccessDatasetMenu.tsx @@ -14,7 +14,8 @@ interface AccessDatasetMenuProps { export function AccessDatasetMenu({ version, permissions }: AccessDatasetMenuProps) { if ( !permissions.canDownloadFiles || - version.publishingStatus === DatasetPublishingStatus.DEACCESSIONED + (version.publishingStatus === DatasetPublishingStatus.DEACCESSIONED && + !permissions.canUpdateDataset) ) { return <> } From 11dde3a8753ae8bb4c8e775395ac74bbc736ad2c Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Sat, 2 Dec 2023 17:31:12 -0500 Subject: [PATCH 05/33] Update AccessDatasetMenu.tsx remove added whitespace --- .../access-dataset-menu/AccessDatasetMenu.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sections/dataset/dataset-action-buttons/access-dataset-menu/AccessDatasetMenu.tsx b/src/sections/dataset/dataset-action-buttons/access-dataset-menu/AccessDatasetMenu.tsx index e1a587968..542ad49c0 100644 --- a/src/sections/dataset/dataset-action-buttons/access-dataset-menu/AccessDatasetMenu.tsx +++ b/src/sections/dataset/dataset-action-buttons/access-dataset-menu/AccessDatasetMenu.tsx @@ -31,7 +31,6 @@ export function AccessDatasetMenu({ version, permissions }: AccessDatasetMenuPro ) } - // TODO: add download feature https://github.com/IQSS/dataverse-frontend/issues/63 // TODO: add explore feature // TODO: add compute feature From b4d3a37d444e835ff1b6258244b90f4fd01c4096 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 12 Dec 2023 11:04:28 -0500 Subject: [PATCH 06/33] fix: add decorator WithLoggedInUser --- .../dataset-action-buttons/DatasetActionButtons.stories.tsx | 3 ++- .../publish-dataset-menu/PublishDatasetMenu.stories.tsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/stories/dataset/dataset-action-buttons/DatasetActionButtons.stories.tsx b/src/stories/dataset/dataset-action-buttons/DatasetActionButtons.stories.tsx index 173f83561..f2429c005 100644 --- a/src/stories/dataset/dataset-action-buttons/DatasetActionButtons.stories.tsx +++ b/src/stories/dataset/dataset-action-buttons/DatasetActionButtons.stories.tsx @@ -7,11 +7,12 @@ import { DatasetPermissionsMother, DatasetVersionMother } from '../../../../tests/component/dataset/domain/models/DatasetMother' +import { WithLoggedInUser } from '../../WithLoggedInUser' const meta: Meta = { title: 'Sections/Dataset Page/DatasetActionButtons', component: DatasetActionButtons, - decorators: [WithI18next, WithSettings], + decorators: [WithI18next, WithSettings, WithLoggedInUser], parameters: { // Sets the delay for all stories. chromatic: { delay: 15000, pauseAnimationAtEnd: true } diff --git a/src/stories/dataset/dataset-action-buttons/publish-dataset-menu/PublishDatasetMenu.stories.tsx b/src/stories/dataset/dataset-action-buttons/publish-dataset-menu/PublishDatasetMenu.stories.tsx index cbc01d0d3..143a1ea9a 100644 --- a/src/stories/dataset/dataset-action-buttons/publish-dataset-menu/PublishDatasetMenu.stories.tsx +++ b/src/stories/dataset/dataset-action-buttons/publish-dataset-menu/PublishDatasetMenu.stories.tsx @@ -7,11 +7,12 @@ import { DatasetVersionMother } from '../../../../../tests/component/dataset/domain/models/DatasetMother' import { PublishDatasetMenu } from '../../../../sections/dataset/dataset-action-buttons/publish-dataset-menu/PublishDatasetMenu' +import { WithLoggedInUser } from '../../../WithLoggedInUser' const meta: Meta = { title: 'Sections/Dataset Page/DatasetActionButtons/PublishDatasetMenu', component: PublishDatasetMenu, - decorators: [WithI18next, WithSettings], + decorators: [WithI18next, WithSettings, WithLoggedInUser], parameters: { // Sets the delay for all stories. chromatic: { delay: 15000, pauseAnimationAtEnd: true } From a6c8df43cd85417e6948e81fc192eb9ce19a8b65 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 19 Dec 2023 10:36:07 -0500 Subject: [PATCH 07/33] fix: update to latest dataverse-client-javascript file --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8fb27ced0..c5e902cbd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.1.0", "dependencies": { "@faker-js/faker": "7.6.0", - "@iqss/dataverse-client-javascript": "2.0.0-pr105.779a3f4", + "@iqss/dataverse-client-javascript": "2.0.0-pr105.302daff", "@iqss/dataverse-design-system": "*", "@istanbuljs/nyc-config-typescript": "1.0.2", "@tanstack/react-table": "8.9.2", @@ -3589,9 +3589,9 @@ }, "node_modules/@iqss/dataverse-client-javascript": { "name": "@IQSS/dataverse-client-javascript", - "version": "2.0.0-pr105.779a3f4", - "resolved": "https://npm.pkg.github.com/download/@IQSS/dataverse-client-javascript/2.0.0-pr105.779a3f4/1a42052721a2981ed2bab2d051f3cda3ecdec15c", - "integrity": "sha512-56zZUWOhU8mXg4STr/vGJmIGJ+xpUPcqwUenUkREMtT0BhxSoTmwS8xYfdfMvBwW4vEXsli0te+m7XXyyRIKPw==", + "version": "2.0.0-pr105.302daff", + "resolved": "https://npm.pkg.github.com/download/@IQSS/dataverse-client-javascript/2.0.0-pr105.302daff/c34263b284c0ae3c5cce7af678826c2b9724c6da", + "integrity": "sha512-Nw3u2mWmqrhnAsFbHIVzWNbgbT1YH3Bk1MpC6Qdpp6OmoLzz5GwWUSTl2DoebMEa1ERRZPjQ2/QGfjbenlkDmQ==", "license": "MIT", "dependencies": { "@types/node": "^18.15.11", diff --git a/package.json b/package.json index 01dfb0c42..b265a88aa 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "7.6.0", - "@iqss/dataverse-client-javascript": "2.0.0-pr105.779a3f4", + "@iqss/dataverse-client-javascript": "2.0.0-pr105.302daff", "@iqss/dataverse-design-system": "*", "@istanbuljs/nyc-config-typescript": "1.0.2", "@tanstack/react-table": "8.9.2", From 7dfd9a06eb96bc58e735b4e6715f92487ee9a7aa Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 19 Dec 2023 10:36:19 -0500 Subject: [PATCH 08/33] fix: remove TODO --- tests/e2e-integration/e2e/sections/dataset/Dataset.spec.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e-integration/e2e/sections/dataset/Dataset.spec.tsx b/tests/e2e-integration/e2e/sections/dataset/Dataset.spec.tsx index 74c9c12bd..8c584cf87 100644 --- a/tests/e2e-integration/e2e/sections/dataset/Dataset.spec.tsx +++ b/tests/e2e-integration/e2e/sections/dataset/Dataset.spec.tsx @@ -156,7 +156,6 @@ describe('Dataset', () => { }) it('successfully loads a dataset deaccessioned', () => { - // TODO - Implement once the getDatasetCitation includes deaccessioned datasets cy.wrap(DatasetHelper.create()) // eslint-disable-next-line @typescript-eslint/no-unsafe-argument .then((dataset) => Promise.all([dataset, DatasetHelper.publish(dataset.persistentId)])) From 9913c2772454700b3f9c9c582fd5df80e0959399 Mon Sep 17 00:00:00 2001 From: MellyGray Date: Tue, 19 Dec 2023 17:22:08 +0100 Subject: [PATCH 09/33] feat(FilePage): add dataset citation --- public/locales/en/file.json | 3 ++- .../DatasetCitation.module.scss | 1 - .../dataset-citation/DatasetCitation.tsx | 19 +++++++++++-------- src/sections/file/File.module.scss | 5 +++++ src/sections/file/File.tsx | 9 ++++++++- .../DatasetCitation.stories.tsx | 9 ++++++++- .../dataset-citation/DatasetCitation.spec.tsx | 8 ++++++++ tests/component/sections/file/File.spec.tsx | 2 ++ 8 files changed, 44 insertions(+), 12 deletions(-) diff --git a/public/locales/en/file.json b/public/locales/en/file.json index 9e3bd1b68..516ac5815 100644 --- a/public/locales/en/file.json +++ b/public/locales/en/file.json @@ -2,5 +2,6 @@ "tabs": { "metadata": "Metadata" }, - "subtext": "This file is part of \"{{datasetTitle}}\"." + "subtext": "This file is part of \"{{datasetTitle}}\".", + "datasetCitation": "Dataset Citation" } diff --git a/src/sections/dataset/dataset-citation/DatasetCitation.module.scss b/src/sections/dataset/dataset-citation/DatasetCitation.module.scss index 4e3ecc9ea..ef29ae7bc 100644 --- a/src/sections/dataset/dataset-citation/DatasetCitation.module.scss +++ b/src/sections/dataset/dataset-citation/DatasetCitation.module.scss @@ -1,7 +1,6 @@ @import "node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module"; .container { -min-height: 150px; margin: 0.5rem 0; padding: 10px; border: 1px solid $dv-info-border-color; diff --git a/src/sections/dataset/dataset-citation/DatasetCitation.tsx b/src/sections/dataset/dataset-citation/DatasetCitation.tsx index 976a17dc8..09494653b 100644 --- a/src/sections/dataset/dataset-citation/DatasetCitation.tsx +++ b/src/sections/dataset/dataset-citation/DatasetCitation.tsx @@ -8,9 +8,10 @@ import { CitationThumbnail } from './CitationThumbnail' interface DatasetCitationProps { thumbnail?: string version: DatasetVersion + withoutThumbnail?: boolean } -export function DatasetCitation({ thumbnail, version }: DatasetCitationProps) { +export function DatasetCitation({ thumbnail, version, withoutThumbnail }: DatasetCitationProps) { const { t } = useTranslation('dataset') return ( <> @@ -21,13 +22,15 @@ export function DatasetCitation({ thumbnail, version }: DatasetCitationProps) { : styles.container }> - - - + {!withoutThumbnail && ( + + + + )}
+ + + {t('datasetCitation')} + + + diff --git a/src/stories/dataset/dataset-citation/DatasetCitation.stories.tsx b/src/stories/dataset/dataset-citation/DatasetCitation.stories.tsx index 4d8d201d2..e578f6d1e 100644 --- a/src/stories/dataset/dataset-citation/DatasetCitation.stories.tsx +++ b/src/stories/dataset/dataset-citation/DatasetCitation.stories.tsx @@ -29,7 +29,7 @@ export const Default: Story = { } } -export const WithThumbnail: Story = { +export const WithThumbnailImage: Story = { render: () => { const dataset = DatasetMother.createRealistic({ thumbnail: faker.image.imageUrl() }) return ( @@ -91,3 +91,10 @@ export const Anonymized: Story = { ) } } + +export const WithoutThumbnail: Story = { + render: () => { + const dataset = DatasetMother.createRealistic() + return + } +} diff --git a/tests/component/sections/dataset/dataset-citation/DatasetCitation.spec.tsx b/tests/component/sections/dataset/dataset-citation/DatasetCitation.spec.tsx index d695e40cd..4f5558af3 100644 --- a/tests/component/sections/dataset/dataset-citation/DatasetCitation.spec.tsx +++ b/tests/component/sections/dataset/dataset-citation/DatasetCitation.spec.tsx @@ -17,6 +17,7 @@ describe('DatasetCitation', () => { cy.findByText(/RELEASED/).should('not.exist') cy.findByText(/V1/).should('exist') cy.findByLabelText('icon-dataset').should('exist') + cy.findByLabelText('icon-dataset').should('exist') }) it('shows the draft tooltip when version is draft', () => { @@ -38,4 +39,11 @@ describe('DatasetCitation', () => { /DEACCESSIONED VERSION has been added to the citation for this version since it is no longer available./ ).should('exist') }) + + it('does not render the thumbnail when withoutThumbnail prop is true', () => { + const version = DatasetVersionMother.createRealistic() + cy.customMount() + + cy.findByLabelText('icon-dataset').should('not.exist') + }) }) diff --git a/tests/component/sections/file/File.spec.tsx b/tests/component/sections/file/File.spec.tsx index 1377c092a..0340eddc1 100644 --- a/tests/component/sections/file/File.spec.tsx +++ b/tests/component/sections/file/File.spec.tsx @@ -15,6 +15,8 @@ describe('File', () => { cy.findAllByText(testFile.name).should('exist') cy.findByText(`This file is part of "${testFile.datasetVersion.title}".`).should('exist') + cy.findByText('Dataset Citation').should('exist') + cy.findByText(/Bennet, Elizabeth; Darcy, Fitzwilliam, 2023, "Dataset Title",/).should('exist') }) it('renders skeleton while loading', () => { From 70e7314b58fdb0635fcab7da2810cf2fe38425f6 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 19 Dec 2023 11:23:36 -0500 Subject: [PATCH 10/33] fix: add includeDeaccessioned parameter to getDatasetCitation() --- .../repositories/DatasetJSDataverseRepository.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts b/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts index c3773641b..d7288ef72 100644 --- a/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts +++ b/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts @@ -18,6 +18,7 @@ import { import { JSDatasetMapper } from '../mappers/JSDatasetMapper' const includeDeaccessioned = true + export class DatasetJSDataverseRepository implements DatasetRepository { getByPersistentId( persistentId: string, @@ -30,7 +31,11 @@ export class DatasetJSDataverseRepository implements DatasetRepository { Promise.all([ jsDataset, getDatasetSummaryFieldNames.execute(), - getDatasetCitation.execute(jsDataset.id, this.versionToVersionId(version)), + getDatasetCitation.execute( + jsDataset.id, + this.versionToVersionId(version), + includeDeaccessioned + ), getDatasetUserPermissions.execute(jsDataset.id), getDatasetLocks.execute(jsDataset.id), getDatasetFilesTotalDownloadSize.execute( From d144cff71a91f10241ce29baf5d61b4e9ec48cfd Mon Sep 17 00:00:00 2001 From: MellyGray Date: Thu, 21 Dec 2023 12:06:23 +0100 Subject: [PATCH 11/33] refactor: DatasetCitation extract components --- public/locales/en/citationBlock.json | 2 + public/locales/en/dataset.json | 4 +- src/sections/dataset/Dataset.module.scss | 2 +- .../DatasetCitation.module.scss | 8 +-- .../dataset-citation/DatasetCitation.tsx | 66 +++++++------------ .../DatasetCitationTooltip.tsx | 17 ++--- .../shared/citation/Citation.module.scss | 9 +++ .../shared/citation/CitationDescription.tsx | 13 +++- .../shared/citation/CitationLearnAbout.tsx | 17 +++++ .../citation/CitationDescription.spec.tsx | 8 +++ .../citation/CitationLearnAbout.spec.tsx | 10 +++ 11 files changed, 91 insertions(+), 65 deletions(-) create mode 100644 public/locales/en/citationBlock.json create mode 100644 src/sections/shared/citation/Citation.module.scss create mode 100644 src/sections/shared/citation/CitationLearnAbout.tsx create mode 100644 tests/component/sections/shared/citation/CitationLearnAbout.spec.tsx diff --git a/public/locales/en/citationBlock.json b/public/locales/en/citationBlock.json new file mode 100644 index 000000000..f782b979b --- /dev/null +++ b/public/locales/en/citationBlock.json @@ -0,0 +1,2 @@ +{"learnAbout": "Learn About", + "standards": "Data Citation Standards"} \ No newline at end of file diff --git a/public/locales/en/dataset.json b/public/locales/en/dataset.json index b9a083d83..54dad4532 100644 --- a/public/locales/en/dataset.json +++ b/public/locales/en/dataset.json @@ -14,9 +14,7 @@ "deaccessioned": { "description": "DEACCESSIONED VERSION has been added to the citation for this version since it is no longer available." } - }, - "learnAbout": "Learn About", - "standards": "Data Citation Standards" + } }, "datasetActionButtons": { "title": "Dataset Action Buttons", diff --git a/src/sections/dataset/Dataset.module.scss b/src/sections/dataset/Dataset.module.scss index 991d976ca..2de5469ba 100644 --- a/src/sections/dataset/Dataset.module.scss +++ b/src/sections/dataset/Dataset.module.scss @@ -7,7 +7,7 @@ } .summary-container { - margin:1em 0; + margin-bottom: 1em; } .tab-container { diff --git a/src/sections/dataset/dataset-citation/DatasetCitation.module.scss b/src/sections/dataset/dataset-citation/DatasetCitation.module.scss index ca1d6f081..a2e5f09a5 100644 --- a/src/sections/dataset/dataset-citation/DatasetCitation.module.scss +++ b/src/sections/dataset/dataset-citation/DatasetCitation.module.scss @@ -1,15 +1,11 @@ @import "node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module"; .container { - margin: 0.5rem 0; - padding: 10px; + margin: 0 0 20px 0; + padding: 10px 0; border: 1px solid $dv-info-border-color; } -.citation { - margin-bottom: 1em; -} - .deaccessioned { margin: 0.5rem 0; padding: 10px; diff --git a/src/sections/dataset/dataset-citation/DatasetCitation.tsx b/src/sections/dataset/dataset-citation/DatasetCitation.tsx index 4bd872b53..e9f05f3f2 100644 --- a/src/sections/dataset/dataset-citation/DatasetCitation.tsx +++ b/src/sections/dataset/dataset-citation/DatasetCitation.tsx @@ -1,10 +1,10 @@ import { Col, Row } from '@iqss/dataverse-design-system' import styles from './DatasetCitation.module.scss' -import { useTranslation } from 'react-i18next' 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' interface DatasetCitationProps { thumbnail?: string @@ -13,47 +13,29 @@ interface DatasetCitationProps { } export function DatasetCitation({ thumbnail, version, withoutThumbnail }: DatasetCitationProps) { - const { t } = useTranslation('dataset') return ( - <> - - - {!withoutThumbnail && ( - - - - )} - - - - - - - - -
- {t('citation.learnAbout')}{' '} - - {t('citation.standards')}. - -
-
- -
-
- + + {!withoutThumbnail && ( + + + + )} + + } + /> + + + ) } diff --git a/src/sections/dataset/dataset-citation/DatasetCitationTooltip.tsx b/src/sections/dataset/dataset-citation/DatasetCitationTooltip.tsx index 0ae1676b1..a9e2d2b04 100644 --- a/src/sections/dataset/dataset-citation/DatasetCitationTooltip.tsx +++ b/src/sections/dataset/dataset-citation/DatasetCitationTooltip.tsx @@ -9,16 +9,11 @@ interface DatasetCitationTooltipProps { export function DatasetCitationTooltip({ status }: DatasetCitationTooltipProps) { const { t } = useTranslation('dataset') - if (status !== DatasetPublishingStatus.RELEASED) { - return ( - <> - {' '} - - - ) + if (status === DatasetPublishingStatus.RELEASED) { + return <> } - return <> + + return ( + + ) } diff --git a/src/sections/shared/citation/Citation.module.scss b/src/sections/shared/citation/Citation.module.scss new file mode 100644 index 000000000..da18ce409 --- /dev/null +++ b/src/sections/shared/citation/Citation.module.scss @@ -0,0 +1,9 @@ +@import "node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module"; + +.description { + margin-bottom: 1em; +} + +.text { + color: $dv-subtext-color +} \ No newline at end of file diff --git a/src/sections/shared/citation/CitationDescription.tsx b/src/sections/shared/citation/CitationDescription.tsx index eb2730bd2..227ec95ba 100644 --- a/src/sections/shared/citation/CitationDescription.tsx +++ b/src/sections/shared/citation/CitationDescription.tsx @@ -1,11 +1,20 @@ import parse from 'html-react-parser' +import styles from './Citation.module.scss' +import { ReactNode } from 'react' interface CitationDescriptionProps { citation: string + tooltip?: ReactNode } -export function CitationDescription({ citation }: CitationDescriptionProps) { +export function CitationDescription({ citation, tooltip }: CitationDescriptionProps) { const citationAsReactElement = parse(citation) - return {citationAsReactElement} + return ( +
+ + {citationAsReactElement} {tooltip} + +
+ ) } diff --git a/src/sections/shared/citation/CitationLearnAbout.tsx b/src/sections/shared/citation/CitationLearnAbout.tsx new file mode 100644 index 000000000..68dced2c8 --- /dev/null +++ b/src/sections/shared/citation/CitationLearnAbout.tsx @@ -0,0 +1,17 @@ +import { useTranslation } from 'react-i18next' +import styles from './Citation.module.scss' + +export function CitationLearnAbout() { + const { t } = useTranslation('citationBlock') + return ( +
+ {t('learnAbout')}{' '} + + {t('standards')}. + +
+ ) +} diff --git a/tests/component/sections/shared/citation/CitationDescription.spec.tsx b/tests/component/sections/shared/citation/CitationDescription.spec.tsx index ce5b1a57e..b40ba9aae 100644 --- a/tests/component/sections/shared/citation/CitationDescription.spec.tsx +++ b/tests/component/sections/shared/citation/CitationDescription.spec.tsx @@ -9,4 +9,12 @@ describe('CitationDescription', () => { cy.findByText(/Finch, Fiona, 2023, "Darwin's Finches",/).should('exist') cy.findByRole('link', { name: 'https://doi.org/10.5072/FK2/0YFWKL' }).should('exist') }) + + it('renders the tooltip', () => { + const citation = 'Finch, Fiona, 2023, "Darwin\'s Finches"' + const tooltip = This is a tooltip + cy.customMount() + + cy.findByText('This is a tooltip').should('exist') + }) }) diff --git a/tests/component/sections/shared/citation/CitationLearnAbout.spec.tsx b/tests/component/sections/shared/citation/CitationLearnAbout.spec.tsx new file mode 100644 index 000000000..8c7bbb1c1 --- /dev/null +++ b/tests/component/sections/shared/citation/CitationLearnAbout.spec.tsx @@ -0,0 +1,10 @@ +import { CitationLearnAbout } from '../../../../../src/sections/shared/citation/CitationLearnAbout' + +describe('CitationLearnAbout', () => { + it('renders the component', () => { + cy.customMount() + + cy.findByText('Learn About').should('exist') + cy.findByRole('link', { name: 'Data Citation Standards.' }).should('exist') + }) +}) From 6d34d581d086f47ed437f52090f5db5bfe363552 Mon Sep 17 00:00:00 2001 From: MellyGray Date: Thu, 21 Dec 2023 12:47:26 +0100 Subject: [PATCH 12/33] feat(FileCitation): add FileCitation to File Page --- public/locales/en/file.json | 3 +- src/files/domain/models/File.ts | 1 + src/sections/file/File.tsx | 5 +- .../file-citation/FileCitation.module.scss | 13 +++++ .../file/file-citation/FileCitation.tsx | 29 ++++++++++ src/stories/dataset/Dataset.stories.tsx | 8 +-- .../dataset-files/DatasetFiles.stories.tsx | 8 +-- .../AccessFileMenu.stories.tsx | 2 +- .../file-thumbnail/FileThumbnail.stories.tsx | 2 +- src/stories/{files => file}/File.stories.tsx | 0 src/stories/{files => file}/FileMockData.ts | 0 .../FileMockLoadingRepository.ts | 0 .../FileMockNoDataRepository.ts | 0 .../FileMockNoFiltersRepository.ts | 0 .../{files => file}/FileMockRepository.ts | 0 .../FileWithDeniedPermissionsRepository.ts | 0 .../FileWithGrantedPermissionsRepository.ts | 0 .../file-citation/FileCitation.stories.tsx | 55 +++++++++++++++++++ .../WithFilePermissionsDenied.tsx | 0 .../WithFilePermissionsGranted.tsx | 0 .../files/domain/models/FileMother.ts | 19 ++++++- tests/component/sections/file/File.spec.tsx | 6 +- .../file/file-citation/FileCitation.spec.tsx | 29 ++++++++++ .../e2e/sections/file/File.spec.tsx | 2 +- 24 files changed, 167 insertions(+), 15 deletions(-) create mode 100644 src/sections/file/file-citation/FileCitation.module.scss create mode 100644 src/sections/file/file-citation/FileCitation.tsx rename src/stories/{files => file}/File.stories.tsx (100%) rename src/stories/{files => file}/FileMockData.ts (100%) rename src/stories/{files => file}/FileMockLoadingRepository.ts (100%) rename src/stories/{files => file}/FileMockNoDataRepository.ts (100%) rename src/stories/{files => file}/FileMockNoFiltersRepository.ts (100%) rename src/stories/{files => file}/FileMockRepository.ts (100%) rename src/stories/{files => file}/FileWithDeniedPermissionsRepository.ts (100%) rename src/stories/{files => file}/FileWithGrantedPermissionsRepository.ts (100%) create mode 100644 src/stories/file/file-citation/FileCitation.stories.tsx rename src/stories/{files => file}/file-permission/WithFilePermissionsDenied.tsx (100%) rename src/stories/{files => file}/file-permission/WithFilePermissionsGranted.tsx (100%) create mode 100644 tests/component/sections/file/file-citation/FileCitation.spec.tsx diff --git a/public/locales/en/file.json b/public/locales/en/file.json index 516ac5815..0a60e1032 100644 --- a/public/locales/en/file.json +++ b/public/locales/en/file.json @@ -3,5 +3,6 @@ "metadata": "Metadata" }, "subtext": "This file is part of \"{{datasetTitle}}\".", - "datasetCitation": "Dataset Citation" + "datasetCitationTitle": "Dataset Citation", + "fileCitationTitle": "File Citation" } diff --git a/src/files/domain/models/File.ts b/src/files/domain/models/File.ts index d348f4df8..54ec8eaab 100644 --- a/src/files/domain/models/File.ts +++ b/src/files/domain/models/File.ts @@ -3,4 +3,5 @@ import { DatasetVersion } from '../../../dataset/domain/models/Dataset' export interface File { name: string datasetVersion: DatasetVersion + citation: string } diff --git a/src/sections/file/File.tsx b/src/sections/file/File.tsx index 414d6a4f9..baf93f008 100644 --- a/src/sections/file/File.tsx +++ b/src/sections/file/File.tsx @@ -8,6 +8,7 @@ import { useEffect } from 'react' import { useLoading } from '../loading/LoadingContext' import { FileSkeleton } from './FileSkeleton' import { DatasetCitation } from '../dataset/dataset-citation/DatasetCitation' +import { FileCitation } from './file-citation/FileCitation' interface FileProps { repository: FileRepository @@ -41,7 +42,9 @@ export function File({ repository, id }: FileProps) {
- {t('datasetCitation')} + {t('fileCitationTitle')} + + {t('datasetCitationTitle')} diff --git a/src/sections/file/file-citation/FileCitation.module.scss b/src/sections/file/file-citation/FileCitation.module.scss new file mode 100644 index 000000000..3627cfc41 --- /dev/null +++ b/src/sections/file/file-citation/FileCitation.module.scss @@ -0,0 +1,13 @@ +@import "node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module"; + +.container { + margin: 0 0 20px 0; + padding: 10px 0; + border: 1px solid $dv-secondary-color; +} + +.deaccessioned { + margin: 0.5rem 0; + padding: 10px; + border: 1px solid $dv-danger-color; +} diff --git a/src/sections/file/file-citation/FileCitation.tsx b/src/sections/file/file-citation/FileCitation.tsx new file mode 100644 index 000000000..6beafed84 --- /dev/null +++ b/src/sections/file/file-citation/FileCitation.tsx @@ -0,0 +1,29 @@ +import { DatasetPublishingStatus, DatasetVersion } from '../../../dataset/domain/models/Dataset' +import styles from './FileCitation.module.scss' +import { CitationDescription } from '../../shared/citation/CitationDescription' +import { DatasetCitationTooltip } from '../../dataset/dataset-citation/DatasetCitationTooltip' +import { CitationLearnAbout } from '../../shared/citation/CitationLearnAbout' +import { Col, Row } from '@iqss/dataverse-design-system' + +interface FileCitationProps { + citation: string + datasetVersion: DatasetVersion +} +export function FileCitation({ citation, datasetVersion }: FileCitationProps) { + return ( + + + } + /> + + + + ) +} diff --git a/src/stories/dataset/Dataset.stories.tsx b/src/stories/dataset/Dataset.stories.tsx index 85fe96332..7b1364d59 100644 --- a/src/stories/dataset/Dataset.stories.tsx +++ b/src/stories/dataset/Dataset.stories.tsx @@ -4,12 +4,12 @@ import { WithLayout } from '../WithLayout' import { Dataset } from '../../sections/dataset/Dataset' import { WithAnonymizedView } from './WithAnonymizedView' import { WithDatasetPrivateUrl } from './WithDatasetPrivateUrl' -import { FileMockRepository } from '../files/FileMockRepository' +import { FileMockRepository } from '../file/FileMockRepository' import { WithCitationMetadataBlockInfo } from './WithCitationMetadataBlockInfo' -import { FileMockNoDataRepository } from '../files/FileMockNoDataRepository' +import { FileMockNoDataRepository } from '../file/FileMockNoDataRepository' import { WithSettings } from '../WithSettings' -import { WithFilePermissionsDenied } from '../files/file-permission/WithFilePermissionsDenied' -import { WithFilePermissionsGranted } from '../files/file-permission/WithFilePermissionsGranted' +import { WithFilePermissionsDenied } from '../file/file-permission/WithFilePermissionsDenied' +import { WithFilePermissionsGranted } from '../file/file-permission/WithFilePermissionsGranted' import { WithDataset } from './WithDataset' import { WithDatasetDraftAsOwner } from './WithDatasetDraftAsOwner' import { WithDatasetNotFound } from './WithDatasetNotFound' diff --git a/src/stories/dataset/dataset-files/DatasetFiles.stories.tsx b/src/stories/dataset/dataset-files/DatasetFiles.stories.tsx index ab8ba15cd..fe727aa71 100644 --- a/src/stories/dataset/dataset-files/DatasetFiles.stories.tsx +++ b/src/stories/dataset/dataset-files/DatasetFiles.stories.tsx @@ -1,11 +1,11 @@ import { Meta, StoryObj } from '@storybook/react' import { WithI18next } from '../../WithI18next' import { DatasetFiles } from '../../../sections/dataset/dataset-files/DatasetFiles' -import { FileMockRepository } from '../../files/FileMockRepository' -import { FileMockLoadingRepository } from '../../files/FileMockLoadingRepository' -import { FileMockNoDataRepository } from '../../files/FileMockNoDataRepository' +import { FileMockRepository } from '../../file/FileMockRepository' +import { FileMockLoadingRepository } from '../../file/FileMockLoadingRepository' +import { FileMockNoDataRepository } from '../../file/FileMockNoDataRepository' import { WithSettings } from '../../WithSettings' -import { FileMockNoFiltersRepository } from '../../files/FileMockNoFiltersRepository' +import { FileMockNoFiltersRepository } from '../../file/FileMockNoFiltersRepository' import { DatasetMother } from '../../../../tests/component/dataset/domain/models/DatasetMother' const meta: Meta = { diff --git a/src/stories/dataset/dataset-files/files-table/file-actions/file-action-buttons/access-file-menu/AccessFileMenu.stories.tsx b/src/stories/dataset/dataset-files/files-table/file-actions/file-action-buttons/access-file-menu/AccessFileMenu.stories.tsx index 73bc899db..7120e4b52 100644 --- a/src/stories/dataset/dataset-files/files-table/file-actions/file-action-buttons/access-file-menu/AccessFileMenu.stories.tsx +++ b/src/stories/dataset/dataset-files/files-table/file-actions/file-action-buttons/access-file-menu/AccessFileMenu.stories.tsx @@ -2,7 +2,7 @@ import { Meta, StoryObj } from '@storybook/react' import { AccessFileMenu } from '../../../../../../../sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/access-file-menu/AccessFileMenu' import { WithI18next } from '../../../../../../WithI18next' import { WithSettings } from '../../../../../../WithSettings' -import { WithFilePermissionsGranted } from '../../../../../../files/file-permission/WithFilePermissionsGranted' +import { WithFilePermissionsGranted } from '../../../../../../file/file-permission/WithFilePermissionsGranted' import { FilePreviewMother } from '../../../../../../../../tests/component/files/domain/models/FilePreviewMother' const meta: Meta = { diff --git a/src/stories/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/file-thumbnail/FileThumbnail.stories.tsx b/src/stories/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/file-thumbnail/FileThumbnail.stories.tsx index a77f0de4a..f654d23a5 100644 --- a/src/stories/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/file-thumbnail/FileThumbnail.stories.tsx +++ b/src/stories/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/file-thumbnail/FileThumbnail.stories.tsx @@ -2,7 +2,7 @@ import { Meta, StoryObj } from '@storybook/react' import { FileThumbnail } from '../../../../../../../../sections/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/file-thumbnail/FileThumbnail' import { WithI18next } from '../../../../../../../WithI18next' import { FilePreviewMother } from '../../../../../../../../../tests/component/files/domain/models/FilePreviewMother' -import { WithFilePermissionsGranted } from '../../../../../../../files/file-permission/WithFilePermissionsGranted' +import { WithFilePermissionsGranted } from '../../../../../../../file/file-permission/WithFilePermissionsGranted' const meta: Meta = { title: 'Sections/Dataset Page/DatasetFiles/FilesTable/FileInfoCell/FileThumbnail', diff --git a/src/stories/files/File.stories.tsx b/src/stories/file/File.stories.tsx similarity index 100% rename from src/stories/files/File.stories.tsx rename to src/stories/file/File.stories.tsx diff --git a/src/stories/files/FileMockData.ts b/src/stories/file/FileMockData.ts similarity index 100% rename from src/stories/files/FileMockData.ts rename to src/stories/file/FileMockData.ts diff --git a/src/stories/files/FileMockLoadingRepository.ts b/src/stories/file/FileMockLoadingRepository.ts similarity index 100% rename from src/stories/files/FileMockLoadingRepository.ts rename to src/stories/file/FileMockLoadingRepository.ts diff --git a/src/stories/files/FileMockNoDataRepository.ts b/src/stories/file/FileMockNoDataRepository.ts similarity index 100% rename from src/stories/files/FileMockNoDataRepository.ts rename to src/stories/file/FileMockNoDataRepository.ts diff --git a/src/stories/files/FileMockNoFiltersRepository.ts b/src/stories/file/FileMockNoFiltersRepository.ts similarity index 100% rename from src/stories/files/FileMockNoFiltersRepository.ts rename to src/stories/file/FileMockNoFiltersRepository.ts diff --git a/src/stories/files/FileMockRepository.ts b/src/stories/file/FileMockRepository.ts similarity index 100% rename from src/stories/files/FileMockRepository.ts rename to src/stories/file/FileMockRepository.ts diff --git a/src/stories/files/FileWithDeniedPermissionsRepository.ts b/src/stories/file/FileWithDeniedPermissionsRepository.ts similarity index 100% rename from src/stories/files/FileWithDeniedPermissionsRepository.ts rename to src/stories/file/FileWithDeniedPermissionsRepository.ts diff --git a/src/stories/files/FileWithGrantedPermissionsRepository.ts b/src/stories/file/FileWithGrantedPermissionsRepository.ts similarity index 100% rename from src/stories/files/FileWithGrantedPermissionsRepository.ts rename to src/stories/file/FileWithGrantedPermissionsRepository.ts diff --git a/src/stories/file/file-citation/FileCitation.stories.tsx b/src/stories/file/file-citation/FileCitation.stories.tsx new file mode 100644 index 000000000..3a7a84dd2 --- /dev/null +++ b/src/stories/file/file-citation/FileCitation.stories.tsx @@ -0,0 +1,55 @@ +import { Meta, StoryObj } from '@storybook/react' +import { WithI18next } from '../../WithI18next' +import { FileCitation } from '../../../sections/file/file-citation/FileCitation' +import { FileCitationMother } from '../../../../tests/component/files/domain/models/FileMother' +import { DatasetVersionMother } from '../../../../tests/component/dataset/domain/models/DatasetMother' + +const meta: Meta = { + title: 'Sections/File Page/FileCitation', + component: FileCitation, + decorators: [WithI18next] +} + +export default meta +type Story = StoryObj + +export const Default: Story = { + render: () => ( + <> +

+

+ + + ) +} + +export const Draft: Story = { + render: () => ( + <> +

+

+ + + ) +} + +export const Deaccessioned: Story = { + render: () => ( + <> +

+

+

+

+ + + ) +} diff --git a/src/stories/files/file-permission/WithFilePermissionsDenied.tsx b/src/stories/file/file-permission/WithFilePermissionsDenied.tsx similarity index 100% rename from src/stories/files/file-permission/WithFilePermissionsDenied.tsx rename to src/stories/file/file-permission/WithFilePermissionsDenied.tsx diff --git a/src/stories/files/file-permission/WithFilePermissionsGranted.tsx b/src/stories/file/file-permission/WithFilePermissionsGranted.tsx similarity index 100% rename from src/stories/files/file-permission/WithFilePermissionsGranted.tsx rename to src/stories/file/file-permission/WithFilePermissionsGranted.tsx diff --git a/tests/component/files/domain/models/FileMother.ts b/tests/component/files/domain/models/FileMother.ts index 28b245c94..4d3a30513 100644 --- a/tests/component/files/domain/models/FileMother.ts +++ b/tests/component/files/domain/models/FileMother.ts @@ -4,18 +4,35 @@ import { DatasetVersionMother } from '../../../dataset/domain/models/DatasetMoth export class FileMother { static create(props?: Partial): File { + const name = props?.name ?? faker.system.fileName() return { name: faker.system.fileName(), datasetVersion: DatasetVersionMother.create(), + citation: FileCitationMother.create(name), ...props } } static createRealistic(props?: Partial): File { return this.create({ - name: 'file.csv', + name: 'File Title', datasetVersion: DatasetVersionMother.createRealistic(), + citation: FileCitationMother.create('File Title'), ...props }) } } + +export class FileCitationMother { + static create(fileName: string): string { + return `Bennet, Elizabeth; Darcy, Fitzwilliam, 2023, "Dataset Title", https://doi.org/10.5072/FK2/BUDNRV, Root, V1; ${fileName} [fileName]` + } + + static createDraft(fileName: string): string { + return `Bennet, Elizabeth; Darcy, Fitzwilliam, 2023, "Dataset Title", https://doi.org/10.5072/FK2/BUDNRV, Root, DRAFT; ${fileName} [fileName]` + } + + static createDeaccessioned(fileName: string): string { + return `Bennet, Elizabeth; Darcy, Fitzwilliam, 2023, "Dataset Title", https://doi.org/10.5072/FK2/BUDNRV, Root, DEACCESSIONED; ${fileName} [fileName]` + } +} diff --git a/tests/component/sections/file/File.spec.tsx b/tests/component/sections/file/File.spec.tsx index 0340eddc1..41cf3a479 100644 --- a/tests/component/sections/file/File.spec.tsx +++ b/tests/component/sections/file/File.spec.tsx @@ -15,8 +15,12 @@ describe('File', () => { cy.findAllByText(testFile.name).should('exist') cy.findByText(`This file is part of "${testFile.datasetVersion.title}".`).should('exist') + cy.findByText('File Citation').should('exist') + cy.findByText(/fileName/).should('exist') cy.findByText('Dataset Citation').should('exist') - cy.findByText(/Bennet, Elizabeth; Darcy, Fitzwilliam, 2023, "Dataset Title",/).should('exist') + cy.findAllByText(/Bennet, Elizabeth; Darcy, Fitzwilliam, 2023, "Dataset Title",/).should( + 'exist' + ) }) it('renders skeleton while loading', () => { diff --git a/tests/component/sections/file/file-citation/FileCitation.spec.tsx b/tests/component/sections/file/file-citation/FileCitation.spec.tsx new file mode 100644 index 000000000..c9d0fb7fc --- /dev/null +++ b/tests/component/sections/file/file-citation/FileCitation.spec.tsx @@ -0,0 +1,29 @@ +import { FileCitation } from '../../../../../src/sections/file/file-citation/FileCitation' +import { FileCitationMother } from '../../../files/domain/models/FileMother' +import { DatasetVersionMother } from '../../../dataset/domain/models/DatasetMother' + +describe('FileCitation', () => { + it('renders the FileCitation', () => { + const citation = FileCitationMother.create('File Title') + const datasetVersion = DatasetVersionMother.createReleased() + + cy.customMount() + cy.findByText(/File Title/).should('exist') + cy.findByText(/Bennet, Elizabeth; Darcy, Fitzwilliam, 2023, "Dataset Title",/).should('exist') + cy.findByText(/RELEASED/).should('not.exist') + cy.findByText(/V1/).should('exist') + }) + + it('renders the FileCitation when the dataset is deaccessioned', () => { + const citation = FileCitationMother.create('File Title') + const datasetVersion = DatasetVersionMother.createDeaccessioned() + + cy.customMount() + cy.findByText(/File Title/).should('exist') + cy.findByText(/Bennet, Elizabeth; Darcy, Fitzwilliam, 2023, "Dataset Title",/).should('exist') + cy.findByRole('img', { name: 'tooltip icon' }).should('exist').trigger('mouseover') + cy.findByText( + /DEACCESSIONED VERSION has been added to the citation for this version since it is no longer available./ + ).should('exist') + }) +}) diff --git a/tests/e2e-integration/e2e/sections/file/File.spec.tsx b/tests/e2e-integration/e2e/sections/file/File.spec.tsx index dac419c86..c60850e25 100644 --- a/tests/e2e-integration/e2e/sections/file/File.spec.tsx +++ b/tests/e2e-integration/e2e/sections/file/File.spec.tsx @@ -1,6 +1,6 @@ describe('File', () => { it('successfully loads', () => { cy.visit('/spa/files?id=23') - cy.findAllByText('file.csv').should('exist') + cy.findAllByText('File Title').should('exist') }) }) From 4482c922cc5c864f5c54ef62a6a87cb120589e61 Mon Sep 17 00:00:00 2001 From: MellyGray Date: Thu, 21 Dec 2023 13:07:07 +0100 Subject: [PATCH 13/33] feat(FileCitation): add to skeleton --- public/locales/en/citationBlock.json | 3 +-- public/locales/en/file.json | 4 ++-- .../DatasetCitation.module.scss | 2 +- src/sections/file/FileSkeleton.tsx | 21 ++++++++++++++----- .../file-citation/FileCitation.module.scss | 2 +- .../dataset-card/DatasetCard.spec.tsx | 1 + .../dataset-card/DatasetCardInfo.spec.tsx | 2 ++ 7 files changed, 24 insertions(+), 11 deletions(-) diff --git a/public/locales/en/citationBlock.json b/public/locales/en/citationBlock.json index f782b979b..bb11901e9 100644 --- a/public/locales/en/citationBlock.json +++ b/public/locales/en/citationBlock.json @@ -1,2 +1 @@ -{"learnAbout": "Learn About", - "standards": "Data Citation Standards"} \ No newline at end of file +{ "learnAbout": "Learn About", "standards": "Data Citation Standards" } diff --git a/public/locales/en/file.json b/public/locales/en/file.json index 0a60e1032..3d81b14bb 100644 --- a/public/locales/en/file.json +++ b/public/locales/en/file.json @@ -3,6 +3,6 @@ "metadata": "Metadata" }, "subtext": "This file is part of \"{{datasetTitle}}\".", - "datasetCitationTitle": "Dataset Citation", - "fileCitationTitle": "File Citation" + "datasetCitationTitle": "Dataset Citation", + "fileCitationTitle": "File Citation" } diff --git a/src/sections/dataset/dataset-citation/DatasetCitation.module.scss b/src/sections/dataset/dataset-citation/DatasetCitation.module.scss index a2e5f09a5..c6c731334 100644 --- a/src/sections/dataset/dataset-citation/DatasetCitation.module.scss +++ b/src/sections/dataset/dataset-citation/DatasetCitation.module.scss @@ -1,7 +1,7 @@ @import "node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module"; .container { - margin: 0 0 20px 0; + margin: 0 0 20px; padding: 10px 0; border: 1px solid $dv-info-border-color; } diff --git a/src/sections/file/FileSkeleton.tsx b/src/sections/file/FileSkeleton.tsx index c92f46c0b..882e09075 100644 --- a/src/sections/file/FileSkeleton.tsx +++ b/src/sections/file/FileSkeleton.tsx @@ -1,23 +1,34 @@ -import styles from '../dataset/Dataset.module.scss' +import styles from './File.module.scss' import Skeleton, { SkeletonTheme } from 'react-loading-skeleton' -import { Tabs } from '@iqss/dataverse-design-system' +import { Col, Row, Tabs } from '@iqss/dataverse-design-system' +import { useTranslation } from 'react-i18next' export function FileSkeleton() { + const { t } = useTranslation('file') return (

- +

- +
+ + + {t('fileCitationTitle')} + + {t('datasetCitationTitle')} + + + - + <> +
diff --git a/src/sections/file/file-citation/FileCitation.module.scss b/src/sections/file/file-citation/FileCitation.module.scss index 3627cfc41..163a91410 100644 --- a/src/sections/file/file-citation/FileCitation.module.scss +++ b/src/sections/file/file-citation/FileCitation.module.scss @@ -1,7 +1,7 @@ @import "node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module"; .container { - margin: 0 0 20px 0; + margin: 0 0 20px; padding: 10px 0; border: 1px solid $dv-secondary-color; } diff --git a/tests/component/sections/home/datasets-list/dataset-card/DatasetCard.spec.tsx b/tests/component/sections/home/datasets-list/dataset-card/DatasetCard.spec.tsx index 8b66c37d1..45dd07ae5 100644 --- a/tests/component/sections/home/datasets-list/dataset-card/DatasetCard.spec.tsx +++ b/tests/component/sections/home/datasets-list/dataset-card/DatasetCard.spec.tsx @@ -15,6 +15,7 @@ describe('DatasetCard', () => { cy.findByText(/Finch, Fiona, 2023, "Darwin's Finches"/) .should('exist') .parent() + .parent() .should('have.class', styles['citation-box']) cy.findByText(dataset.abbreviatedDescription).should('exist') }) diff --git a/tests/component/sections/home/datasets-list/dataset-card/DatasetCardInfo.spec.tsx b/tests/component/sections/home/datasets-list/dataset-card/DatasetCardInfo.spec.tsx index 5563fe412..cc9a5ac47 100644 --- a/tests/component/sections/home/datasets-list/dataset-card/DatasetCardInfo.spec.tsx +++ b/tests/component/sections/home/datasets-list/dataset-card/DatasetCardInfo.spec.tsx @@ -12,6 +12,7 @@ describe('DatasetCardInfo', () => { cy.findByText(/Finch, Fiona, 2023, "Darwin's Finches"/) .should('exist') .parent() + .parent() .should('have.class', styles['citation-box']) cy.findByText(dataset.abbreviatedDescription).should('exist') }) @@ -23,6 +24,7 @@ describe('DatasetCardInfo', () => { cy.findByText(/Finch, Fiona, 2023, "Darwin's Finches"/) .should('exist') .parent() + .parent() .should('have.class', styles['citation-box-deaccessioned']) }) }) From bf972b9cc18101db07b7f744fdd3688e11d5d529 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Wed, 3 Jan 2024 20:26:33 -0500 Subject: [PATCH 14/33] add DatasetPreview mapper --- package-lock.json | 8 +-- package.json | 2 +- src/dataset/domain/models/DatasetPreview.ts | 57 ++++++++++++++++++- .../infrastructure/mappers/JSDatasetMapper.ts | 30 ++++++++++ .../DatasetJSDataverseRepository.ts | 19 ++++--- 5 files changed, 101 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index c5e902cbd..ba0c0c1ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.1.0", "dependencies": { "@faker-js/faker": "7.6.0", - "@iqss/dataverse-client-javascript": "2.0.0-pr105.302daff", + "@iqss/dataverse-client-javascript": "2.0.0-pr107.228a37e", "@iqss/dataverse-design-system": "*", "@istanbuljs/nyc-config-typescript": "1.0.2", "@tanstack/react-table": "8.9.2", @@ -3589,9 +3589,9 @@ }, "node_modules/@iqss/dataverse-client-javascript": { "name": "@IQSS/dataverse-client-javascript", - "version": "2.0.0-pr105.302daff", - "resolved": "https://npm.pkg.github.com/download/@IQSS/dataverse-client-javascript/2.0.0-pr105.302daff/c34263b284c0ae3c5cce7af678826c2b9724c6da", - "integrity": "sha512-Nw3u2mWmqrhnAsFbHIVzWNbgbT1YH3Bk1MpC6Qdpp6OmoLzz5GwWUSTl2DoebMEa1ERRZPjQ2/QGfjbenlkDmQ==", + "version": "2.0.0-pr107.228a37e", + "resolved": "https://npm.pkg.github.com/download/@IQSS/dataverse-client-javascript/2.0.0-pr107.228a37e/e3abc35bae153cce761c0297c7c59c4df0d3e0a9", + "integrity": "sha512-mqx7vvRObgdLZz/fZYscQ9AQzhxd2xGUcnLLMQFL8boQldakNIwQXSX2wTZXC5Ht+BKigejNhC8L8/UpL92fxQ==", "license": "MIT", "dependencies": { "@types/node": "^18.15.11", diff --git a/package.json b/package.json index b265a88aa..6c97e6688 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "7.6.0", - "@iqss/dataverse-client-javascript": "2.0.0-pr105.302daff", + "@iqss/dataverse-client-javascript": "2.0.0-pr107.228a37e", "@iqss/dataverse-design-system": "*", "@istanbuljs/nyc-config-typescript": "1.0.2", "@tanstack/react-table": "8.9.2", diff --git a/src/dataset/domain/models/DatasetPreview.ts b/src/dataset/domain/models/DatasetPreview.ts index 849ba4691..06276b50d 100644 --- a/src/dataset/domain/models/DatasetPreview.ts +++ b/src/dataset/domain/models/DatasetPreview.ts @@ -1,4 +1,10 @@ -import { DatasetLabel, DatasetVersion } from './Dataset' +import { + DatasetLabel, + DatasetLabelSemanticMeaning, + DatasetLabelValue, + DatasetPublishingStatus, + DatasetVersion +} from './Dataset' export class DatasetPreview { constructor( @@ -11,7 +17,9 @@ export class DatasetPreview { public releaseOrCreateDate: Date, public description: string, public thumbnail?: string - ) {} + ) { + this.withLabels() + } get abbreviatedDescription(): string { if (this.description.length > 280) { @@ -19,4 +27,49 @@ export class DatasetPreview { } return this.description } + + withLabels() { + this.withStatusLabel() + this.withVersionLabel() + } + + private withStatusLabel(): void { + if (this.version.publishingStatus === DatasetPublishingStatus.DRAFT) { + this.labels.push( + new DatasetLabel(DatasetLabelSemanticMeaning.DATASET, DatasetLabelValue.DRAFT) + ) + } + const isReleased = this.version.publishingStatus === DatasetPublishingStatus.RELEASED + if (!isReleased) { + this.labels.push( + new DatasetLabel(DatasetLabelSemanticMeaning.WARNING, DatasetLabelValue.UNPUBLISHED) + ) + } + + if (this.version.publishingStatus === DatasetPublishingStatus.DEACCESSIONED) { + this.labels.push( + new DatasetLabel(DatasetLabelSemanticMeaning.DANGER, DatasetLabelValue.DEACCESSIONED) + ) + } + + if (this.version.publishingStatus === DatasetPublishingStatus.EMBARGOED) { + this.labels.push( + new DatasetLabel(DatasetLabelSemanticMeaning.DATASET, DatasetLabelValue.EMBARGOED) + ) + } + + if (this.version.isInReview) { + this.labels.push( + new DatasetLabel(DatasetLabelSemanticMeaning.SUCCESS, DatasetLabelValue.IN_REVIEW) + ) + } + } + + private withVersionLabel(): void { + if (this.version.publishingStatus === DatasetPublishingStatus.RELEASED) { + this.labels.push( + new DatasetLabel(DatasetLabelSemanticMeaning.FILE, `Version ${this.version.toString()}`) + ) + } + } } diff --git a/src/dataset/infrastructure/mappers/JSDatasetMapper.ts b/src/dataset/infrastructure/mappers/JSDatasetMapper.ts index 0af446ac0..e61d08761 100644 --- a/src/dataset/infrastructure/mappers/JSDatasetMapper.ts +++ b/src/dataset/infrastructure/mappers/JSDatasetMapper.ts @@ -11,6 +11,9 @@ import { DatasetVersionState as JSDatasetVersionState } from '@iqss/dataverse-cl import { Dataset, DatasetDownloadUrls, + DatasetLabel, + DatasetLabelSemanticMeaning, + DatasetLabelValue, DatasetLock, DatasetLockReason, DatasetMetadataBlock, @@ -23,8 +26,34 @@ import { PrivateUrl } from '../../domain/models/Dataset' import { FileDownloadMode, FileDownloadSize, FileSizeUnit } from '../../../files/domain/models/File' +import { DatasetPreview } from '../../domain/models/DatasetPreview' export class JSDatasetMapper { + static toDatasetPreview(jsDatasetPreview: { + persistentId: string + title: string + versionId: number + versionInfo: JSDatasetVersionInfo + citation: string + description: string + }): DatasetPreview { + const version = JSDatasetMapper.toVersion( + jsDatasetPreview.versionId, + jsDatasetPreview.versionInfo + ) + return new DatasetPreview( + jsDatasetPreview.persistentId, + jsDatasetPreview.title, + version, + jsDatasetPreview.citation, + [], + true, + new Date(), + jsDatasetPreview.description, + 'thumbnail' + ) + } + static toDataset( jsDataset: JSDataset, citation: string, @@ -217,6 +246,7 @@ export class JSDatasetMapper { canDeleteDataset: jsDatasetPermissions.canManageDatasetPermissions } } + static toLocks(jsDatasetLocks: JSDatasetLock[]): DatasetLock[] { return jsDatasetLocks.map((jsDatasetLock) => { return { diff --git a/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts b/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts index c7036a14b..a2fe42ceb 100644 --- a/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts +++ b/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts @@ -2,9 +2,11 @@ import { DatasetRepository } from '../../domain/repositories/DatasetRepository' import { Dataset } from '../../domain/models/Dataset' import { getDataset, + getAllDatasetPreviews, getDatasetCitation, getDatasetSummaryFieldNames, Dataset as JSDataset, + DatasetPreview as JSDatasetPreview, DatasetUserPermissions as JSDatasetPermissions, getPrivateUrlDataset, getPrivateUrlDatasetCitation, @@ -13,25 +15,26 @@ import { getDatasetLocks, DatasetLock as JSDatasetLock, getDatasetFilesTotalDownloadSize, - FileDownloadSizeMode + FileDownloadSizeMode, + DatasetPreviewSubset } from '@iqss/dataverse-client-javascript' import { JSDatasetMapper } from '../mappers/JSDatasetMapper' import { TotalDatasetsCount } from '../../domain/models/TotalDatasetsCount' import { DatasetPaginationInfo } from '../../domain/models/DatasetPaginationInfo' import { DatasetPreview } from '../../domain/models/DatasetPreview' -import { DatasetPreviewMother } from '../../../../tests/component/dataset/domain/models/DatasetPreviewMother' const includeDeaccessioned = true export class DatasetJSDataverseRepository implements DatasetRepository { // eslint-disable-next-line unused-imports/no-unused-vars getAll(paginationInfo: DatasetPaginationInfo): Promise { - // TODO - Implement using the js-dataverse-client - return new Promise((resolve) => { - setTimeout(() => { - resolve(DatasetPreviewMother.createManyRealistic(10)) - }, 1000) - }) + return getAllDatasetPreviews + .execute(paginationInfo.pageSize, paginationInfo.offset) + .then((subset: DatasetPreviewSubset) => { + return subset.datasetPreviews.map((datasetPreview: JSDatasetPreview) => + JSDatasetMapper.toDatasetPreview(datasetPreview) + ) + }) } getTotalDatasetsCount(): Promise { From 3486d5823c81563001180f53fc1aa92d03ed5cf7 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Thu, 4 Jan 2024 15:49:50 -0500 Subject: [PATCH 15/33] refactor withLabels() to share logic between Dataset and DatasetPreview --- src/dataset/domain/models/Dataset.ts | 98 ++++++++++--------- src/dataset/domain/models/DatasetPreview.ts | 55 +---------- .../infrastructure/mappers/JSDatasetMapper.ts | 23 ++--- .../DatasetJSDataverseRepository.ts | 1 - 4 files changed, 63 insertions(+), 114 deletions(-) diff --git a/src/dataset/domain/models/Dataset.ts b/src/dataset/domain/models/Dataset.ts index 657fb4eac..f271e77e2 100644 --- a/src/dataset/domain/models/Dataset.ts +++ b/src/dataset/domain/models/Dataset.ts @@ -354,6 +354,57 @@ export class Dataset { return false } + static withDatasetLabels(version: DatasetVersion): DatasetLabel[] { + const statusLabels = Dataset.withStatusLabel(version.publishingStatus, version.isInReview) + const versionLabels = Dataset.withVersionLabel(version) + return [...statusLabels, ...versionLabels] // combine and return + } + + static withStatusLabel( + publishingStatus: DatasetPublishingStatus, + isInReview: boolean + ): DatasetLabel[] { + const labels: DatasetLabel[] = [] + if (publishingStatus === DatasetPublishingStatus.DRAFT) { + labels.push(new DatasetLabel(DatasetLabelSemanticMeaning.DATASET, DatasetLabelValue.DRAFT)) + } + const isReleased = publishingStatus === DatasetPublishingStatus.RELEASED + if (!isReleased) { + labels.push( + new DatasetLabel(DatasetLabelSemanticMeaning.WARNING, DatasetLabelValue.UNPUBLISHED) + ) + } + + if (publishingStatus === DatasetPublishingStatus.DEACCESSIONED) { + labels.push( + new DatasetLabel(DatasetLabelSemanticMeaning.DANGER, DatasetLabelValue.DEACCESSIONED) + ) + } + + if (publishingStatus === DatasetPublishingStatus.EMBARGOED) { + labels.push( + new DatasetLabel(DatasetLabelSemanticMeaning.DATASET, DatasetLabelValue.EMBARGOED) + ) + } + + if (isInReview) { + labels.push( + new DatasetLabel(DatasetLabelSemanticMeaning.SUCCESS, DatasetLabelValue.IN_REVIEW) + ) + } + return labels + } + + static withVersionLabel(version: DatasetVersion): DatasetLabel[] { + const labels: DatasetLabel[] = [] + if (version.publishingStatus === DatasetPublishingStatus.RELEASED) { + labels.push( + new DatasetLabel(DatasetLabelSemanticMeaning.FILE, `Version ${version.toString()}`) + ) + } + return labels + } + static Builder = class { public readonly labels: DatasetLabel[] = [] public readonly alerts: Alert[] = [] @@ -376,55 +427,10 @@ export class Dataset { public readonly thumbnail?: string, public readonly privateUrl?: PrivateUrl ) { - this.withLabels() + this.labels = Dataset.withDatasetLabels(version) this.withAlerts() } - withLabels() { - this.withStatusLabel() - this.withVersionLabel() - } - - private withStatusLabel(): void { - if (this.version.publishingStatus === DatasetPublishingStatus.DRAFT) { - this.labels.push( - new DatasetLabel(DatasetLabelSemanticMeaning.DATASET, DatasetLabelValue.DRAFT) - ) - } - - if (!this.isReleased) { - this.labels.push( - new DatasetLabel(DatasetLabelSemanticMeaning.WARNING, DatasetLabelValue.UNPUBLISHED) - ) - } - - if (this.version.publishingStatus === DatasetPublishingStatus.DEACCESSIONED) { - this.labels.push( - new DatasetLabel(DatasetLabelSemanticMeaning.DANGER, DatasetLabelValue.DEACCESSIONED) - ) - } - - if (this.version.publishingStatus === DatasetPublishingStatus.EMBARGOED) { - this.labels.push( - new DatasetLabel(DatasetLabelSemanticMeaning.DATASET, DatasetLabelValue.EMBARGOED) - ) - } - - if (this.version.isInReview) { - this.labels.push( - new DatasetLabel(DatasetLabelSemanticMeaning.SUCCESS, DatasetLabelValue.IN_REVIEW) - ) - } - } - - private withVersionLabel(): void { - if (this.version.publishingStatus === DatasetPublishingStatus.RELEASED) { - this.labels.push( - new DatasetLabel(DatasetLabelSemanticMeaning.FILE, `Version ${this.version.toString()}`) - ) - } - } - private withAlerts(): void { if ( this.version.publishingStatus === DatasetPublishingStatus.DRAFT && diff --git a/src/dataset/domain/models/DatasetPreview.ts b/src/dataset/domain/models/DatasetPreview.ts index 06276b50d..d8f71bc8c 100644 --- a/src/dataset/domain/models/DatasetPreview.ts +++ b/src/dataset/domain/models/DatasetPreview.ts @@ -1,10 +1,4 @@ -import { - DatasetLabel, - DatasetLabelSemanticMeaning, - DatasetLabelValue, - DatasetPublishingStatus, - DatasetVersion -} from './Dataset' +import { DatasetLabel, DatasetVersion, Dataset } from './Dataset' export class DatasetPreview { constructor( @@ -18,7 +12,7 @@ export class DatasetPreview { public description: string, public thumbnail?: string ) { - this.withLabels() + this.labels = Dataset.withDatasetLabels(version) } get abbreviatedDescription(): string { @@ -27,49 +21,4 @@ export class DatasetPreview { } return this.description } - - withLabels() { - this.withStatusLabel() - this.withVersionLabel() - } - - private withStatusLabel(): void { - if (this.version.publishingStatus === DatasetPublishingStatus.DRAFT) { - this.labels.push( - new DatasetLabel(DatasetLabelSemanticMeaning.DATASET, DatasetLabelValue.DRAFT) - ) - } - const isReleased = this.version.publishingStatus === DatasetPublishingStatus.RELEASED - if (!isReleased) { - this.labels.push( - new DatasetLabel(DatasetLabelSemanticMeaning.WARNING, DatasetLabelValue.UNPUBLISHED) - ) - } - - if (this.version.publishingStatus === DatasetPublishingStatus.DEACCESSIONED) { - this.labels.push( - new DatasetLabel(DatasetLabelSemanticMeaning.DANGER, DatasetLabelValue.DEACCESSIONED) - ) - } - - if (this.version.publishingStatus === DatasetPublishingStatus.EMBARGOED) { - this.labels.push( - new DatasetLabel(DatasetLabelSemanticMeaning.DATASET, DatasetLabelValue.EMBARGOED) - ) - } - - if (this.version.isInReview) { - this.labels.push( - new DatasetLabel(DatasetLabelSemanticMeaning.SUCCESS, DatasetLabelValue.IN_REVIEW) - ) - } - } - - private withVersionLabel(): void { - if (this.version.publishingStatus === DatasetPublishingStatus.RELEASED) { - this.labels.push( - new DatasetLabel(DatasetLabelSemanticMeaning.FILE, `Version ${this.version.toString()}`) - ) - } - } } diff --git a/src/dataset/infrastructure/mappers/JSDatasetMapper.ts b/src/dataset/infrastructure/mappers/JSDatasetMapper.ts index e61d08761..dfed91a85 100644 --- a/src/dataset/infrastructure/mappers/JSDatasetMapper.ts +++ b/src/dataset/infrastructure/mappers/JSDatasetMapper.ts @@ -1,6 +1,7 @@ import { Dataset as JSDataset, DatasetLock as JSDatasetLock, + DatasetPreview as JSDatasetPreview, DatasetMetadataBlock as JSDatasetMetadataBlock, DatasetMetadataBlocks as JSDatasetMetadataBlocks, DatasetMetadataFields as JSDatasetMetadataFields, @@ -11,9 +12,6 @@ import { DatasetVersionState as JSDatasetVersionState } from '@iqss/dataverse-cl import { Dataset, DatasetDownloadUrls, - DatasetLabel, - DatasetLabelSemanticMeaning, - DatasetLabelValue, DatasetLock, DatasetLockReason, DatasetMetadataBlock, @@ -29,14 +27,7 @@ import { FileDownloadMode, FileDownloadSize, FileSizeUnit } from '../../../files import { DatasetPreview } from '../../domain/models/DatasetPreview' export class JSDatasetMapper { - static toDatasetPreview(jsDatasetPreview: { - persistentId: string - title: string - versionId: number - versionInfo: JSDatasetVersionInfo - citation: string - description: string - }): DatasetPreview { + static toDatasetPreview(jsDatasetPreview: JSDatasetPreview): DatasetPreview { const version = JSDatasetMapper.toVersion( jsDatasetPreview.versionId, jsDatasetPreview.versionInfo @@ -47,13 +38,17 @@ export class JSDatasetMapper { version, jsDatasetPreview.citation, [], - true, - new Date(), + jsDatasetPreview.versionInfo.state === JSDatasetVersionState.DEACCESSIONED, + JSDatasetMapper.toPreviewDate(jsDatasetPreview.versionInfo), jsDatasetPreview.description, - 'thumbnail' + undefined // TODO: get dataset thumbnail from Dataverse https://github.com/IQSS/dataverse-frontend/issues/203 ) } + static toPreviewDate(jsVersionInfo: JSDatasetVersionInfo): Date { + return jsVersionInfo.releaseTime ? jsVersionInfo.releaseTime : jsVersionInfo.createTime + } + static toDataset( jsDataset: JSDataset, citation: string, diff --git a/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts b/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts index a2fe42ceb..0b5e9a687 100644 --- a/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts +++ b/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts @@ -26,7 +26,6 @@ import { DatasetPreview } from '../../domain/models/DatasetPreview' const includeDeaccessioned = true export class DatasetJSDataverseRepository implements DatasetRepository { - // eslint-disable-next-line unused-imports/no-unused-vars getAll(paginationInfo: DatasetPaginationInfo): Promise { return getAllDatasetPreviews .execute(paginationInfo.pageSize, paginationInfo.offset) From fba38c1f2a8e010f40fe7a5087465bb90afc311e Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Thu, 4 Jan 2024 16:16:14 -0500 Subject: [PATCH 16/33] refactor withLabels() to share logic between Dataset and DatasetPreview --- .../repositories/DatasetJSDataverseRepository.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts b/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts index 0b5e9a687..858d4a7a2 100644 --- a/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts +++ b/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts @@ -22,6 +22,7 @@ import { JSDatasetMapper } from '../mappers/JSDatasetMapper' import { TotalDatasetsCount } from '../../domain/models/TotalDatasetsCount' import { DatasetPaginationInfo } from '../../domain/models/DatasetPaginationInfo' import { DatasetPreview } from '../../domain/models/DatasetPreview' +import { getTotalDatasetsCount } from '../../domain/useCases/getTotalDatasetsCount' const includeDeaccessioned = true @@ -37,11 +38,9 @@ export class DatasetJSDataverseRepository implements DatasetRepository { } getTotalDatasetsCount(): Promise { - // TODO - Implement using the js-dataverse-client - return new Promise((resolve) => { - setTimeout(() => { - resolve(200) - }, 1000) + // TODO: refactor this so we don't make the same call twice + return getAllDatasetPreviews.execute(10, 1).then((subset: DatasetPreviewSubset) => { + return subset.totalDatasetCount }) } From f229fdff6aa0b49ae7d9ce4e047d1af1d0ec326e Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Thu, 4 Jan 2024 16:21:08 -0500 Subject: [PATCH 17/33] remove import --- .../infrastructure/repositories/DatasetJSDataverseRepository.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts b/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts index 858d4a7a2..2bf4d4a9d 100644 --- a/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts +++ b/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts @@ -22,7 +22,6 @@ import { JSDatasetMapper } from '../mappers/JSDatasetMapper' import { TotalDatasetsCount } from '../../domain/models/TotalDatasetsCount' import { DatasetPaginationInfo } from '../../domain/models/DatasetPaginationInfo' import { DatasetPreview } from '../../domain/models/DatasetPreview' -import { getTotalDatasetsCount } from '../../domain/useCases/getTotalDatasetsCount' const includeDeaccessioned = true From b59d4e210465508b3b97f99f35c15f9917bf8cca Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Fri, 5 Jan 2024 07:22:59 -0500 Subject: [PATCH 18/33] fix hard-coded year in test data --- .../datasets/DatasetJSDataverseRepository.spec.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts b/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts index 5d0336a02..bb40320fe 100644 --- a/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts +++ b/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts @@ -26,8 +26,9 @@ function getCurrentDateInYYYYMMDDFormat() { const datasetData = (persistentId: string, versionId: number) => { const persistentIdUrl = `https://doi.org/${persistentId.replace('doi:', '')}` + const year = new Date().getFullYear() return { - citation: `Finch, Fiona, 2023, "Darwin's Finches", ${persistentIdUrl}, Root, DRAFT VERSION`, + citation: `Finch, Fiona, ${year}, "Darwin's Finches", ${persistentIdUrl}, Root, DRAFT VERSION`, labels: [ { semanticMeaning: 'dataset', value: 'Draft' }, { semanticMeaning: 'warning', value: 'Unpublished' } @@ -263,6 +264,12 @@ describe('Dataset JSDataverse Repository', () => { expect(dataset.metadataBlocks[0].fields.citationDate).not.to.exist }) }) + it.only('gets the total dataset count', async () => { + const datasetResponse = await DatasetHelper.create() + await datasetRepository.getTotalDatasetsCount().then((count) => { + expect(count).to.equal(1) + }) + }) it.skip('gets the dataset by persistentId when the dataset is deaccessioned', async () => { // TODO - Implement once the getDatasetCitation includes deaccessioned datasets From 6658fe51bec08f744d19f09f1c2c1d7d285b5180 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Sat, 6 Jan 2024 10:29:29 -0500 Subject: [PATCH 19/33] Add integration test --- .../DatasetJSDataverseRepository.ts | 4 +-- .../DatasetJSDataverseRepository.spec.ts | 26 ++++++++++++++++--- .../shared/datasets/DatasetHelper.ts | 21 +++++++++++++++ 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts b/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts index 2bf4d4a9d..226d511fb 100644 --- a/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts +++ b/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts @@ -37,8 +37,8 @@ export class DatasetJSDataverseRepository implements DatasetRepository { } getTotalDatasetsCount(): Promise { - // TODO: refactor this so we don't make the same call twice - return getAllDatasetPreviews.execute(10, 1).then((subset: DatasetPreviewSubset) => { + // TODO: refactor this so we don't make the same call twice? + return getAllDatasetPreviews.execute(10, 0).then((subset: DatasetPreviewSubset) => { return subset.totalDatasetCount }) } diff --git a/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts b/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts index bb40320fe..a01416885 100644 --- a/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts +++ b/tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts @@ -13,6 +13,7 @@ import { FileDownloadSize, FileSizeUnit } from '../../../../src/files/domain/models/File' +import { DatasetPaginationInfo } from '../../../../src/dataset/domain/models/DatasetPaginationInfo' chai.use(chaiAsPromised) const expect = chai.expect @@ -111,7 +112,9 @@ const datasetData = (persistentId: string, versionId: number) => { const datasetRepository = new DatasetJSDataverseRepository() describe('Dataset JSDataverse Repository', () => { before(() => TestsUtils.setup()) - beforeEach(() => TestsUtils.login()) + beforeEach(() => { + TestsUtils.login() + }) it('gets the dataset by persistentId', async () => { const datasetResponse = await DatasetHelper.create() @@ -264,12 +267,29 @@ describe('Dataset JSDataverse Repository', () => { expect(dataset.metadataBlocks[0].fields.citationDate).not.to.exist }) }) - it.only('gets the total dataset count', async () => { - const datasetResponse = await DatasetHelper.create() + it('gets the total dataset count', async () => { + await DatasetHelper.destroyAll() + await datasetRepository.getTotalDatasetsCount().then((count) => { + expect(count).to.equal(0) + }) + await DatasetHelper.createAndPublish() + await datasetRepository.getTotalDatasetsCount().then((count) => { expect(count).to.equal(1) }) }) + it('gets the DatasetPreview', async () => { + await DatasetHelper.destroyAll() + + const datasetResponse = await DatasetHelper.createAndPublish() + const paginationInfo = new DatasetPaginationInfo(1, 20) + + await datasetRepository.getAll(paginationInfo).then((datasetPreview) => { + expect(datasetPreview.length).to.equal(1) + expect(datasetPreview[0].title).to.equal("Darwin's Finches") + expect(datasetPreview[0].persistentId).to.equal(datasetResponse.persistentId) + }) + }) it.skip('gets the dataset by persistentId when the dataset is deaccessioned', async () => { // TODO - Implement once the getDatasetCitation includes deaccessioned datasets diff --git a/tests/e2e-integration/shared/datasets/DatasetHelper.ts b/tests/e2e-integration/shared/datasets/DatasetHelper.ts index e46519395..aa0b42f41 100644 --- a/tests/e2e-integration/shared/datasets/DatasetHelper.ts +++ b/tests/e2e-integration/shared/datasets/DatasetHelper.ts @@ -2,6 +2,7 @@ import newDatasetData from '../../fixtures/dataset-finch1.json' import { DataverseApiHelper } from '../DataverseApiHelper' import { FileData } from '../files/FileHelper' import { DatasetLockReason } from '../../../../src/dataset/domain/models/Dataset' +import { TestsUtils } from '../TestsUtils' export interface DatasetResponse { persistentId: string @@ -17,6 +18,26 @@ export class DatasetHelper extends DataverseApiHelper { static async create(): Promise { return this.request(`/dataverses/root/datasets`, 'POST', newDatasetData) } + static async destroy(persistentId: string): Promise { + return this.request( + `/datasets/:persistentId/destroy/?persistentId=${persistentId}`, + 'DELETE' + ) + } + static async createAndPublish(): Promise { + const datasetResponse = await DatasetHelper.create() + await DatasetHelper.publish(datasetResponse.persistentId) + await TestsUtils.waitForNoLocks(datasetResponse.persistentId) + return datasetResponse + } + static async destroyAll(): Promise { + const response = await this.request<{ + items: Array<{ global_id: string }> + }>('/search?q=*&type=dataset&sort=date&order=desc&per_page=500&start=0', 'GET') + for (const dataset of response.items as Array<{ global_id: string }>) { + await this.destroy(dataset.global_id) + } + } static async publish(persistentId: string): Promise<{ status: string From 2693ed5795d7b4f963b7896c633e53081d2e9c12 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Sat, 6 Jan 2024 12:01:07 -0500 Subject: [PATCH 20/33] fix: only set status labels in DatasetPreview --- src/dataset/domain/models/DatasetPreview.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dataset/domain/models/DatasetPreview.ts b/src/dataset/domain/models/DatasetPreview.ts index d8f71bc8c..019466bef 100644 --- a/src/dataset/domain/models/DatasetPreview.ts +++ b/src/dataset/domain/models/DatasetPreview.ts @@ -12,7 +12,7 @@ export class DatasetPreview { public description: string, public thumbnail?: string ) { - this.labels = Dataset.withDatasetLabels(version) + this.labels = Dataset.withStatusLabel(version.publishingStatus, version.isInReview) } get abbreviatedDescription(): string { From 4151a7a81c8879da520b1bea6219af43a3efadbd Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Sun, 7 Jan 2024 10:24:57 -0500 Subject: [PATCH 21/33] add e2e test for Home Page --- .../e2e/sections/home/Home.spec.ts | 20 +++++++++++++++++++ .../shared/datasets/DatasetHelper.ts | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/tests/e2e-integration/e2e/sections/home/Home.spec.ts b/tests/e2e-integration/e2e/sections/home/Home.spec.ts index 1f85bc181..604740a22 100644 --- a/tests/e2e-integration/e2e/sections/home/Home.spec.ts +++ b/tests/e2e-integration/e2e/sections/home/Home.spec.ts @@ -1,9 +1,29 @@ +import { DatasetHelper } from '../../../shared/datasets/DatasetHelper' +import { TestsUtils } from '../../../shared/TestsUtils' +import { faker } from '@faker-js/faker' + describe('Home Page', () => { + const title = faker.lorem.sentence() + before(() => { + TestsUtils.setup() + }) + + beforeEach(() => {}) it('successfully loads', () => { cy.visit('/spa') cy.findAllByText(/Root/i).should('exist') }) + it('goes to dataset page', () => { + cy.loginAsAdmin('/spa') + DatasetHelper.destroyAll() + DatasetHelper.createWithTitle(title) + cy.findByText(title).should('be.visible') + cy.findByText(title).click({ force: true }) + cy.url().should('include', 'persistentId') + cy.findAllByText(title).should('be.visible') + }) + it('log in Dataverse Admin user', () => { cy.loginAsAdmin('/spa') diff --git a/tests/e2e-integration/shared/datasets/DatasetHelper.ts b/tests/e2e-integration/shared/datasets/DatasetHelper.ts index aa0b42f41..80a92bd88 100644 --- a/tests/e2e-integration/shared/datasets/DatasetHelper.ts +++ b/tests/e2e-integration/shared/datasets/DatasetHelper.ts @@ -18,6 +18,10 @@ export class DatasetHelper extends DataverseApiHelper { static async create(): Promise { return this.request(`/dataverses/root/datasets`, 'POST', newDatasetData) } + static async createWithTitle(title: string): Promise { + newDatasetData.datasetVersion.metadataBlocks.citation.fields[0].value = title + return this.request(`/dataverses/root/datasets`, 'POST', newDatasetData) + } static async destroy(persistentId: string): Promise { return this.request( `/datasets/:persistentId/destroy/?persistentId=${persistentId}`, From 74680cbd7dbf5a4ff151c65a2765261e5a4ab6a6 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Sun, 7 Jan 2024 10:52:41 -0500 Subject: [PATCH 22/33] fix: lint error --- tests/e2e-integration/e2e/sections/home/Home.spec.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/e2e-integration/e2e/sections/home/Home.spec.ts b/tests/e2e-integration/e2e/sections/home/Home.spec.ts index 604740a22..ae5878d78 100644 --- a/tests/e2e-integration/e2e/sections/home/Home.spec.ts +++ b/tests/e2e-integration/e2e/sections/home/Home.spec.ts @@ -14,10 +14,11 @@ describe('Home Page', () => { cy.findAllByText(/Root/i).should('exist') }) - it('goes to dataset page', () => { - cy.loginAsAdmin('/spa') - DatasetHelper.destroyAll() - DatasetHelper.createWithTitle(title) + it('goes to dataset page from list', () => { + void DatasetHelper.destroyAll() + void DatasetHelper.createWithTitle(title) + cy.loginAsAdmin() + cy.findByText(/Dataverse Admin/i).should('exist') cy.findByText(title).should('be.visible') cy.findByText(title).click({ force: true }) cy.url().should('include', 'persistentId') From 9b660a26ffdf05cb1fc8cd30bc60f3a56f6bc18d Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Sun, 7 Jan 2024 18:38:01 -0500 Subject: [PATCH 23/33] fix: if deaccessioned, only show deaccessioned label --- src/dataset/domain/models/Dataset.ts | 31 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/dataset/domain/models/Dataset.ts b/src/dataset/domain/models/Dataset.ts index f271e77e2..effa28781 100644 --- a/src/dataset/domain/models/Dataset.ts +++ b/src/dataset/domain/models/Dataset.ts @@ -365,28 +365,27 @@ export class Dataset { isInReview: boolean ): DatasetLabel[] { const labels: DatasetLabel[] = [] - if (publishingStatus === DatasetPublishingStatus.DRAFT) { - labels.push(new DatasetLabel(DatasetLabelSemanticMeaning.DATASET, DatasetLabelValue.DRAFT)) - } - const isReleased = publishingStatus === DatasetPublishingStatus.RELEASED - if (!isReleased) { - labels.push( - new DatasetLabel(DatasetLabelSemanticMeaning.WARNING, DatasetLabelValue.UNPUBLISHED) - ) - } if (publishingStatus === DatasetPublishingStatus.DEACCESSIONED) { labels.push( new DatasetLabel(DatasetLabelSemanticMeaning.DANGER, DatasetLabelValue.DEACCESSIONED) ) + } else { + if (publishingStatus === DatasetPublishingStatus.DRAFT) { + labels.push(new DatasetLabel(DatasetLabelSemanticMeaning.DATASET, DatasetLabelValue.DRAFT)) + } + const isReleased = publishingStatus === DatasetPublishingStatus.RELEASED + if (!isReleased) { + labels.push( + new DatasetLabel(DatasetLabelSemanticMeaning.WARNING, DatasetLabelValue.UNPUBLISHED) + ) + } + if (publishingStatus === DatasetPublishingStatus.EMBARGOED) { + labels.push( + new DatasetLabel(DatasetLabelSemanticMeaning.DATASET, DatasetLabelValue.EMBARGOED) + ) + } } - - if (publishingStatus === DatasetPublishingStatus.EMBARGOED) { - labels.push( - new DatasetLabel(DatasetLabelSemanticMeaning.DATASET, DatasetLabelValue.EMBARGOED) - ) - } - if (isInReview) { labels.push( new DatasetLabel(DatasetLabelSemanticMeaning.SUCCESS, DatasetLabelValue.IN_REVIEW) From 24cdda19792bf2ca750126bb5d2cc57c47930588 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 9 Jan 2024 10:36:03 -0500 Subject: [PATCH 24/33] fix: remove DomainFileMapper.toJSPagination() --- src/files/infrastructure/FileJSDataverseRepository.ts | 5 ++--- src/files/infrastructure/mappers/DomainFileMapper.ts | 10 ---------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/files/infrastructure/FileJSDataverseRepository.ts b/src/files/infrastructure/FileJSDataverseRepository.ts index 64b46ce53..39047c579 100644 --- a/src/files/infrastructure/FileJSDataverseRepository.ts +++ b/src/files/infrastructure/FileJSDataverseRepository.ts @@ -32,14 +32,13 @@ export class FileJSDataverseRepository implements FileRepository { paginationInfo: FilePaginationInfo = new FilePaginationInfo(), criteria: FileCriteria = new FileCriteria() ): Promise { - const jsPagination = DomainFileMapper.toJSPagination(paginationInfo) return getDatasetFiles .execute( datasetPersistentId, datasetVersion.toString(), includeDeaccessioned, - jsPagination.limit, - jsPagination.offset, + paginationInfo.pageSize, + paginationInfo.offset, DomainFileMapper.toJSFileSearchCriteria(criteria), DomainFileMapper.toJSFileOrderCriteria(criteria.sortBy) ) diff --git a/src/files/infrastructure/mappers/DomainFileMapper.ts b/src/files/infrastructure/mappers/DomainFileMapper.ts index 9c8921102..7b594a519 100644 --- a/src/files/infrastructure/mappers/DomainFileMapper.ts +++ b/src/files/infrastructure/mappers/DomainFileMapper.ts @@ -13,16 +13,6 @@ import { FileType } from '../../domain/models/File' import { FilePaginationInfo } from '../../domain/models/FilePaginationInfo' export class DomainFileMapper { - static toJSPagination(paginationInfo: FilePaginationInfo): { - limit?: number - offset?: number - } { - return { - limit: paginationInfo.pageSize, - offset: (paginationInfo.page - 1) * paginationInfo.pageSize - } - } - static toJSFileSearchCriteria(criteria: FileCriteria): JSFileSearchCriteria { return new JSFileSearchCriteria( this.toJSContentType(criteria.filterByType), From bf3e03dc53de70131df46c6b85561ae9d1520c03 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 9 Jan 2024 10:57:24 -0500 Subject: [PATCH 25/33] refactor: Breakup JSDatasetMapper.ts into smaller files --- .../infrastructure/mappers/JSDatasetMapper.ts | 59 +------------------ .../mappers/JSDatasetPreviewMapper.ts | 30 ++++++++++ .../mappers/JSDatasetVersionMapper.ts | 36 +++++++++++ .../DatasetJSDataverseRepository.ts | 3 +- 4 files changed, 70 insertions(+), 58 deletions(-) create mode 100644 src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts create mode 100644 src/dataset/infrastructure/mappers/JSDatasetVersionMapper.ts diff --git a/src/dataset/infrastructure/mappers/JSDatasetMapper.ts b/src/dataset/infrastructure/mappers/JSDatasetMapper.ts index dfed91a85..cf807c68e 100644 --- a/src/dataset/infrastructure/mappers/JSDatasetMapper.ts +++ b/src/dataset/infrastructure/mappers/JSDatasetMapper.ts @@ -1,14 +1,12 @@ import { Dataset as JSDataset, DatasetLock as JSDatasetLock, - DatasetPreview as JSDatasetPreview, DatasetMetadataBlock as JSDatasetMetadataBlock, DatasetMetadataBlocks as JSDatasetMetadataBlocks, DatasetMetadataFields as JSDatasetMetadataFields, DatasetUserPermissions as JSDatasetPermissions, DatasetVersionInfo as JSDatasetVersionInfo } from '@iqss/dataverse-client-javascript' -import { DatasetVersionState as JSDatasetVersionState } from '@iqss/dataverse-client-javascript/dist/datasets/domain/models/Dataset' import { Dataset, DatasetDownloadUrls, @@ -18,37 +16,14 @@ import { DatasetMetadataBlocks, DatasetMetadataFields, DatasetPermissions, - DatasetPublishingStatus, DatasetVersion, MetadataBlockName, PrivateUrl } from '../../domain/models/Dataset' import { FileDownloadMode, FileDownloadSize, FileSizeUnit } from '../../../files/domain/models/File' -import { DatasetPreview } from '../../domain/models/DatasetPreview' +import { JSDatasetVersionMapper } from './JSDatasetVersionMapper' export class JSDatasetMapper { - static toDatasetPreview(jsDatasetPreview: JSDatasetPreview): DatasetPreview { - const version = JSDatasetMapper.toVersion( - jsDatasetPreview.versionId, - jsDatasetPreview.versionInfo - ) - return new DatasetPreview( - jsDatasetPreview.persistentId, - jsDatasetPreview.title, - version, - jsDatasetPreview.citation, - [], - jsDatasetPreview.versionInfo.state === JSDatasetVersionState.DEACCESSIONED, - JSDatasetMapper.toPreviewDate(jsDatasetPreview.versionInfo), - jsDatasetPreview.description, - undefined // TODO: get dataset thumbnail from Dataverse https://github.com/IQSS/dataverse-frontend/issues/203 - ) - } - - static toPreviewDate(jsVersionInfo: JSDatasetVersionInfo): Date { - return jsVersionInfo.releaseTime ? jsVersionInfo.releaseTime : jsVersionInfo.createTime - } - static toDataset( jsDataset: JSDataset, citation: string, @@ -60,7 +35,7 @@ export class JSDatasetMapper { requestedVersion?: string, privateUrl?: PrivateUrl ): Dataset { - const version = JSDatasetMapper.toVersion( + const version = JSDatasetVersionMapper.toDatasetVersion( jsDataset.versionId, jsDataset.versionInfo, requestedVersion @@ -93,36 +68,6 @@ export class JSDatasetMapper { ).build() } - static toVersion( - jDatasetVersionId: number, - jsDatasetVersionInfo: JSDatasetVersionInfo, - requestedVersion?: string - ): DatasetVersion { - return new DatasetVersion( - jDatasetVersionId, - JSDatasetMapper.toStatus(jsDatasetVersionInfo.state), - true, // TODO Connect with dataset version isLatest - false, // TODO Connect with dataset version isInReview - JSDatasetMapper.toStatus(jsDatasetVersionInfo.state), // TODO Connect with dataset version latestVersionState - jsDatasetVersionInfo.majorNumber, - jsDatasetVersionInfo.minorNumber, - requestedVersion - ) - } - - static toStatus(jsDatasetVersionState: JSDatasetVersionState): DatasetPublishingStatus { - switch (jsDatasetVersionState) { - case JSDatasetVersionState.DRAFT: - return DatasetPublishingStatus.DRAFT - case JSDatasetVersionState.DEACCESSIONED: - return DatasetPublishingStatus.DEACCESSIONED - case JSDatasetVersionState.RELEASED: - return DatasetPublishingStatus.RELEASED - default: - return DatasetPublishingStatus.DRAFT - } - } - static toSummaryFields( jsDatasetMetadataBlocks: JSDatasetMetadataBlocks, summaryFieldsNames: string[] diff --git a/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts b/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts new file mode 100644 index 000000000..45c505eeb --- /dev/null +++ b/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts @@ -0,0 +1,30 @@ +import { DatasetPreview as JSDatasetPreview } from '@iqss/dataverse-client-javascript/dist/datasets/domain/models/DatasetPreview' +import { DatasetPreview } from '../../domain/models/DatasetPreview' +import { + DatasetVersionInfo as JSDatasetVersionInfo, + DatasetVersionState as JSDatasetVersionState +} from '@iqss/dataverse-client-javascript/dist/datasets/domain/models/Dataset' +import { JSDatasetVersionMapper } from './JSDatasetVersionMapper' + +export class JSDatasetPreviewMapper { + static toDatasetPreview(jsDatasetPreview: JSDatasetPreview): DatasetPreview { + return new DatasetPreview( + jsDatasetPreview.persistentId, + jsDatasetPreview.title, + JSDatasetVersionMapper.toDatasetVersion( + jsDatasetPreview.versionId, + jsDatasetPreview.versionInfo + ), + jsDatasetPreview.citation, + [], + jsDatasetPreview.versionInfo.state === JSDatasetVersionState.DEACCESSIONED, + JSDatasetPreviewMapper.toPreviewDate(jsDatasetPreview.versionInfo), + jsDatasetPreview.description, + undefined // TODO: get dataset thumbnail from Dataverse https://github.com/IQSS/dataverse-frontend/issues/203 + ) + } + + static toPreviewDate(jsVersionInfo: JSDatasetVersionInfo): Date { + return jsVersionInfo.releaseTime ? jsVersionInfo.releaseTime : jsVersionInfo.createTime + } +} diff --git a/src/dataset/infrastructure/mappers/JSDatasetVersionMapper.ts b/src/dataset/infrastructure/mappers/JSDatasetVersionMapper.ts new file mode 100644 index 000000000..c537636c9 --- /dev/null +++ b/src/dataset/infrastructure/mappers/JSDatasetVersionMapper.ts @@ -0,0 +1,36 @@ +import { + DatasetVersionInfo as JSDatasetVersionInfo, + DatasetVersionState as JSDatasetVersionState +} from '@iqss/dataverse-client-javascript/dist/datasets/domain/models/Dataset' +import { DatasetPublishingStatus, DatasetVersion } from '../../domain/models/Dataset' +export class JSDatasetVersionMapper { + static toDatasetVersion( + jDatasetVersionId: number, + jsDatasetVersionInfo: JSDatasetVersionInfo, + requestedVersion?: string + ): DatasetVersion { + return new DatasetVersion( + jDatasetVersionId, + JSDatasetVersionMapper.toStatus(jsDatasetVersionInfo.state), + true, // TODO Connect with dataset version isLatest + false, // TODO Connect with dataset version isInReview + JSDatasetVersionMapper.toStatus(jsDatasetVersionInfo.state), // TODO Connect with dataset version latestVersionState + jsDatasetVersionInfo.majorNumber, + jsDatasetVersionInfo.minorNumber, + requestedVersion + ) + } + + static toStatus(jsDatasetVersionState: JSDatasetVersionState): DatasetPublishingStatus { + switch (jsDatasetVersionState) { + case JSDatasetVersionState.DRAFT: + return DatasetPublishingStatus.DRAFT + case JSDatasetVersionState.DEACCESSIONED: + return DatasetPublishingStatus.DEACCESSIONED + case JSDatasetVersionState.RELEASED: + return DatasetPublishingStatus.RELEASED + default: + return DatasetPublishingStatus.DRAFT + } + } +} diff --git a/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts b/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts index 226d511fb..ca5794a6b 100644 --- a/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts +++ b/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts @@ -22,6 +22,7 @@ import { JSDatasetMapper } from '../mappers/JSDatasetMapper' import { TotalDatasetsCount } from '../../domain/models/TotalDatasetsCount' import { DatasetPaginationInfo } from '../../domain/models/DatasetPaginationInfo' import { DatasetPreview } from '../../domain/models/DatasetPreview' +import { JSDatasetPreviewMapper } from '../mappers/JSDatasetPreviewMapper' const includeDeaccessioned = true @@ -31,7 +32,7 @@ export class DatasetJSDataverseRepository implements DatasetRepository { .execute(paginationInfo.pageSize, paginationInfo.offset) .then((subset: DatasetPreviewSubset) => { return subset.datasetPreviews.map((datasetPreview: JSDatasetPreview) => - JSDatasetMapper.toDatasetPreview(datasetPreview) + JSDatasetPreviewMapper.toDatasetPreview(datasetPreview) ) }) } From 22980bc4dafef32d1832fcf65674d98ae8b97637 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 9 Jan 2024 15:16:24 -0500 Subject: [PATCH 26/33] fix: remove labels[] from constructor, change label function names --- src/dataset/domain/models/Dataset.ts | 4 ++-- src/dataset/domain/models/DatasetPreview.ts | 4 ++-- src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/dataset/domain/models/Dataset.ts b/src/dataset/domain/models/Dataset.ts index effa28781..e30803556 100644 --- a/src/dataset/domain/models/Dataset.ts +++ b/src/dataset/domain/models/Dataset.ts @@ -355,12 +355,12 @@ export class Dataset { } static withDatasetLabels(version: DatasetVersion): DatasetLabel[] { - const statusLabels = Dataset.withStatusLabel(version.publishingStatus, version.isInReview) + const statusLabels = Dataset.createStatusLabels(version.publishingStatus, version.isInReview) const versionLabels = Dataset.withVersionLabel(version) return [...statusLabels, ...versionLabels] // combine and return } - static withStatusLabel( + static createStatusLabels( publishingStatus: DatasetPublishingStatus, isInReview: boolean ): DatasetLabel[] { diff --git a/src/dataset/domain/models/DatasetPreview.ts b/src/dataset/domain/models/DatasetPreview.ts index 019466bef..d9d1fa39e 100644 --- a/src/dataset/domain/models/DatasetPreview.ts +++ b/src/dataset/domain/models/DatasetPreview.ts @@ -1,18 +1,18 @@ import { DatasetLabel, DatasetVersion, Dataset } from './Dataset' export class DatasetPreview { + public labels: DatasetLabel[] constructor( public persistentId: string, public title: string, public version: DatasetVersion, public citation: string, - public labels: DatasetLabel[], public isDeaccessioned: boolean, public releaseOrCreateDate: Date, public description: string, public thumbnail?: string ) { - this.labels = Dataset.withStatusLabel(version.publishingStatus, version.isInReview) + this.labels = Dataset.createStatusLabels(version.publishingStatus, version.isInReview) } get abbreviatedDescription(): string { diff --git a/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts b/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts index 45c505eeb..5d312aee4 100644 --- a/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts +++ b/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts @@ -16,7 +16,6 @@ export class JSDatasetPreviewMapper { jsDatasetPreview.versionInfo ), jsDatasetPreview.citation, - [], jsDatasetPreview.versionInfo.state === JSDatasetVersionState.DEACCESSIONED, JSDatasetPreviewMapper.toPreviewDate(jsDatasetPreview.versionInfo), jsDatasetPreview.description, From 9a5231973bf7959bf5a5cd2c6ee3cde3ecb93af2 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 9 Jan 2024 16:20:48 -0500 Subject: [PATCH 27/33] fix: use TestUtils.login --- tests/e2e-integration/e2e/sections/home/Home.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e-integration/e2e/sections/home/Home.spec.ts b/tests/e2e-integration/e2e/sections/home/Home.spec.ts index ae5878d78..b40e1897f 100644 --- a/tests/e2e-integration/e2e/sections/home/Home.spec.ts +++ b/tests/e2e-integration/e2e/sections/home/Home.spec.ts @@ -17,7 +17,7 @@ describe('Home Page', () => { it('goes to dataset page from list', () => { void DatasetHelper.destroyAll() void DatasetHelper.createWithTitle(title) - cy.loginAsAdmin() + TestsUtils.login() cy.findByText(/Dataverse Admin/i).should('exist') cy.findByText(title).should('be.visible') cy.findByText(title).click({ force: true }) From efdb516e1647afb2b3fb17f7ba339c52d90e10aa Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 9 Jan 2024 16:59:04 -0500 Subject: [PATCH 28/33] fix: logic for createStatusLabels() --- src/dataset/domain/models/Dataset.ts | 46 +++++++++++-------- src/dataset/domain/models/DatasetPreview.ts | 8 +++- .../mappers/JSDatasetPreviewMapper.ts | 1 + 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/dataset/domain/models/Dataset.ts b/src/dataset/domain/models/Dataset.ts index e30803556..d8b866069 100644 --- a/src/dataset/domain/models/Dataset.ts +++ b/src/dataset/domain/models/Dataset.ts @@ -354,43 +354,51 @@ export class Dataset { return false } - static withDatasetLabels(version: DatasetVersion): DatasetLabel[] { - const statusLabels = Dataset.createStatusLabels(version.publishingStatus, version.isInReview) + static withDatasetLabels(version: DatasetVersion, isReleased: boolean): DatasetLabel[] { + const statusLabels = Dataset.createStatusLabels( + version.publishingStatus, + version.isInReview, + isReleased + ) const versionLabels = Dataset.withVersionLabel(version) return [...statusLabels, ...versionLabels] // combine and return } static createStatusLabels( publishingStatus: DatasetPublishingStatus, - isInReview: boolean + isInReview: boolean, + isReleased: boolean ): DatasetLabel[] { const labels: DatasetLabel[] = [] + if (publishingStatus === DatasetPublishingStatus.DRAFT) { + labels.push(new DatasetLabel(DatasetLabelSemanticMeaning.DATASET, DatasetLabelValue.DRAFT)) + } + + if (!isReleased) { + labels.push( + new DatasetLabel(DatasetLabelSemanticMeaning.WARNING, DatasetLabelValue.UNPUBLISHED) + ) + } + if (publishingStatus === DatasetPublishingStatus.DEACCESSIONED) { labels.push( new DatasetLabel(DatasetLabelSemanticMeaning.DANGER, DatasetLabelValue.DEACCESSIONED) ) - } else { - if (publishingStatus === DatasetPublishingStatus.DRAFT) { - labels.push(new DatasetLabel(DatasetLabelSemanticMeaning.DATASET, DatasetLabelValue.DRAFT)) - } - const isReleased = publishingStatus === DatasetPublishingStatus.RELEASED - if (!isReleased) { - labels.push( - new DatasetLabel(DatasetLabelSemanticMeaning.WARNING, DatasetLabelValue.UNPUBLISHED) - ) - } - if (publishingStatus === DatasetPublishingStatus.EMBARGOED) { - labels.push( - new DatasetLabel(DatasetLabelSemanticMeaning.DATASET, DatasetLabelValue.EMBARGOED) - ) - } } + + if (publishingStatus === DatasetPublishingStatus.EMBARGOED) { + labels.push( + new DatasetLabel(DatasetLabelSemanticMeaning.DATASET, DatasetLabelValue.EMBARGOED) + ) + } + if (isInReview) { labels.push( new DatasetLabel(DatasetLabelSemanticMeaning.SUCCESS, DatasetLabelValue.IN_REVIEW) ) } + return labels } @@ -426,7 +434,7 @@ export class Dataset { public readonly thumbnail?: string, public readonly privateUrl?: PrivateUrl ) { - this.labels = Dataset.withDatasetLabels(version) + this.labels = Dataset.withDatasetLabels(version, isReleased) this.withAlerts() } diff --git a/src/dataset/domain/models/DatasetPreview.ts b/src/dataset/domain/models/DatasetPreview.ts index d9d1fa39e..d7f850bc0 100644 --- a/src/dataset/domain/models/DatasetPreview.ts +++ b/src/dataset/domain/models/DatasetPreview.ts @@ -2,17 +2,23 @@ import { DatasetLabel, DatasetVersion, Dataset } from './Dataset' export class DatasetPreview { public labels: DatasetLabel[] + constructor( public persistentId: string, public title: string, public version: DatasetVersion, + public isReleased: boolean, public citation: string, public isDeaccessioned: boolean, public releaseOrCreateDate: Date, public description: string, public thumbnail?: string ) { - this.labels = Dataset.createStatusLabels(version.publishingStatus, version.isInReview) + this.labels = Dataset.createStatusLabels( + version.publishingStatus, + version.isInReview, + this.isReleased + ) } get abbreviatedDescription(): string { diff --git a/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts b/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts index 5d312aee4..322580bb4 100644 --- a/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts +++ b/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts @@ -15,6 +15,7 @@ export class JSDatasetPreviewMapper { jsDatasetPreview.versionId, jsDatasetPreview.versionInfo ), + jsDatasetPreview.versionInfo.releaseTime !== undefined, jsDatasetPreview.citation, jsDatasetPreview.versionInfo.state === JSDatasetVersionState.DEACCESSIONED, JSDatasetPreviewMapper.toPreviewDate(jsDatasetPreview.versionInfo), From 13fc18c7339ba37b76da508b5527f0d80e4809c9 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 9 Jan 2024 17:08:23 -0500 Subject: [PATCH 29/33] fix: lint error --- src/files/infrastructure/mappers/DomainFileMapper.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/files/infrastructure/mappers/DomainFileMapper.ts b/src/files/infrastructure/mappers/DomainFileMapper.ts index 7b594a519..a85dc3112 100644 --- a/src/files/infrastructure/mappers/DomainFileMapper.ts +++ b/src/files/infrastructure/mappers/DomainFileMapper.ts @@ -10,7 +10,6 @@ import { FileOrderCriteria as JSFileOrderCriteria } from '@iqss/dataverse-client-javascript' import { FileType } from '../../domain/models/File' -import { FilePaginationInfo } from '../../domain/models/FilePaginationInfo' export class DomainFileMapper { static toJSFileSearchCriteria(criteria: FileCriteria): JSFileSearchCriteria { From c50a2b35a7890b22a6a561f67240f61ff761a8c0 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 9 Jan 2024 17:24:23 -0500 Subject: [PATCH 30/33] fix: DatasetPreview mapper and mock data --- src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts | 2 +- tests/component/dataset/domain/models/DatasetPreviewMother.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts b/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts index 322580bb4..04d0bc00f 100644 --- a/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts +++ b/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts @@ -15,7 +15,7 @@ export class JSDatasetPreviewMapper { jsDatasetPreview.versionId, jsDatasetPreview.versionInfo ), - jsDatasetPreview.versionInfo.releaseTime !== undefined, + jsDatasetPreview.versionInfo.releaseTime == undefined ? true : false, jsDatasetPreview.citation, jsDatasetPreview.versionInfo.state === JSDatasetVersionState.DEACCESSIONED, JSDatasetPreviewMapper.toPreviewDate(jsDatasetPreview.versionInfo), diff --git a/tests/component/dataset/domain/models/DatasetPreviewMother.ts b/tests/component/dataset/domain/models/DatasetPreviewMother.ts index 83e080ff9..fe73c75d6 100644 --- a/tests/component/dataset/domain/models/DatasetPreviewMother.ts +++ b/tests/component/dataset/domain/models/DatasetPreviewMother.ts @@ -16,6 +16,7 @@ export class DatasetPreviewMother { persistentId: faker.datatype.uuid(), title: faker.lorem.sentence(), labels: DatasetLabelsMother.create(), + isReleased: faker.datatype.boolean(), isDeaccessioned: faker.datatype.boolean(), thumbnail: faker.datatype.boolean() ? faker.image.imageUrl() : undefined, releaseOrCreateDate: faker.date.past(), @@ -29,8 +30,8 @@ export class DatasetPreviewMother { datasetPreview.persistentId, datasetPreview.title, datasetPreview.version, + datasetPreview.isReleased, datasetPreview.citation, - datasetPreview.labels, datasetPreview.isDeaccessioned, datasetPreview.releaseOrCreateDate, datasetPreview.description, From 37520f1d02067b8070ab0bb59a4e94934167087e Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 9 Jan 2024 17:45:00 -0500 Subject: [PATCH 31/33] fix: function names --- src/dataset/domain/models/Dataset.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dataset/domain/models/Dataset.ts b/src/dataset/domain/models/Dataset.ts index d8b866069..6cf14f2e7 100644 --- a/src/dataset/domain/models/Dataset.ts +++ b/src/dataset/domain/models/Dataset.ts @@ -354,13 +354,13 @@ export class Dataset { return false } - static withDatasetLabels(version: DatasetVersion, isReleased: boolean): DatasetLabel[] { + static createDatasetLabels(version: DatasetVersion, isReleased: boolean): DatasetLabel[] { const statusLabels = Dataset.createStatusLabels( version.publishingStatus, version.isInReview, isReleased ) - const versionLabels = Dataset.withVersionLabel(version) + const versionLabels = Dataset.createVersionLabel(version) return [...statusLabels, ...versionLabels] // combine and return } @@ -402,7 +402,7 @@ export class Dataset { return labels } - static withVersionLabel(version: DatasetVersion): DatasetLabel[] { + static createVersionLabel(version: DatasetVersion): DatasetLabel[] { const labels: DatasetLabel[] = [] if (version.publishingStatus === DatasetPublishingStatus.RELEASED) { labels.push( @@ -434,7 +434,7 @@ export class Dataset { public readonly thumbnail?: string, public readonly privateUrl?: PrivateUrl ) { - this.labels = Dataset.withDatasetLabels(version, isReleased) + this.labels = Dataset.(version, isReleased) this.withAlerts() } From 06e7b42b7689b938fc0bec8615ab4be1da9f67f9 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 9 Jan 2024 17:46:01 -0500 Subject: [PATCH 32/33] fix: typo --- src/dataset/domain/models/Dataset.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dataset/domain/models/Dataset.ts b/src/dataset/domain/models/Dataset.ts index 6cf14f2e7..af9eb9125 100644 --- a/src/dataset/domain/models/Dataset.ts +++ b/src/dataset/domain/models/Dataset.ts @@ -434,7 +434,7 @@ export class Dataset { public readonly thumbnail?: string, public readonly privateUrl?: PrivateUrl ) { - this.labels = Dataset.(version, isReleased) + this.labels = Dataset.createDatasetLabels(version, isReleased) this.withAlerts() } From f7b6f618927fad504068adf9309762f0ce671fc8 Mon Sep 17 00:00:00 2001 From: MellyGray Date: Wed, 10 Jan 2024 11:17:47 +0100 Subject: [PATCH 33/33] fix: isReleased mapping inverted result --- src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts b/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts index 04d0bc00f..b821962f9 100644 --- a/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts +++ b/src/dataset/infrastructure/mappers/JSDatasetPreviewMapper.ts @@ -15,7 +15,7 @@ export class JSDatasetPreviewMapper { jsDatasetPreview.versionId, jsDatasetPreview.versionInfo ), - jsDatasetPreview.versionInfo.releaseTime == undefined ? true : false, + jsDatasetPreview.versionInfo.releaseTime != undefined, jsDatasetPreview.citation, jsDatasetPreview.versionInfo.state === JSDatasetVersionState.DEACCESSIONED, JSDatasetPreviewMapper.toPreviewDate(jsDatasetPreview.versionInfo),