From bdc11b3dc1d877d801655986ebfce42aa044b131 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Fri, 25 Oct 2024 14:40:40 -0400 Subject: [PATCH 01/22] fix: get Root Collection alias using ':root' keyword --- src/collection/domain/models/Collection.ts | 2 +- .../domain/useCases/getCollectionById.ts | 2 +- src/sections/Route.enum.ts | 10 ++---- src/sections/collection/Collection.tsx | 31 ++++++++++--------- src/sections/collection/CollectionFactory.tsx | 3 +- src/sections/create-dataset/CreateDataset.tsx | 6 ++-- src/sections/layout/Layout.tsx | 4 +-- src/sections/layout/header/Header.tsx | 9 +++--- src/sections/layout/header/HeaderFactory.tsx | 11 +++++++ .../layout/header/LoggedInHeaderActions.tsx | 14 +++++++-- .../add-data-actions/AddDataActionsButton.tsx | 2 +- .../create-dataset/CreateDataset.spec.tsx | 21 +++++-------- .../sections/layout/header/Header.spec.tsx | 17 ++++++---- 13 files changed, 75 insertions(+), 57 deletions(-) create mode 100644 src/sections/layout/header/HeaderFactory.tsx diff --git a/src/collection/domain/models/Collection.ts b/src/collection/domain/models/Collection.ts index dca9ed2c5..de1235f8c 100644 --- a/src/collection/domain/models/Collection.ts +++ b/src/collection/domain/models/Collection.ts @@ -16,4 +16,4 @@ export interface CollectionInputLevel { required: boolean } -export const ROOT_COLLECTION_ALIAS = 'root' +export const ROOT_COLLECTION_ALIAS = ':root' diff --git a/src/collection/domain/useCases/getCollectionById.ts b/src/collection/domain/useCases/getCollectionById.ts index 5de6cb61d..7fc9a9a40 100644 --- a/src/collection/domain/useCases/getCollectionById.ts +++ b/src/collection/domain/useCases/getCollectionById.ts @@ -4,7 +4,7 @@ import { CollectionRepository } from '../repositories/CollectionRepository' export async function getCollectionById( collectionRepository: CollectionRepository, id: string -): Promise { +): Promise { return collectionRepository.getById(id).catch((error: Error) => { throw new Error(error.message) }) diff --git a/src/sections/Route.enum.ts b/src/sections/Route.enum.ts index e2d5a5248..2062d1b80 100644 --- a/src/sections/Route.enum.ts +++ b/src/sections/Route.enum.ts @@ -1,5 +1,3 @@ -import { ROOT_COLLECTION_ALIAS } from '../collection/domain/models/Collection' - export enum Route { HOME = '/', SIGN_UP = '/dataverseuser.xhtml?editMode=CREATE&redirectPage=%2Fdataverse.xhtml', @@ -17,11 +15,9 @@ export enum Route { } export const RouteWithParams = { - COLLECTIONS: (collectionId?: string) => `/collections/${collectionId ?? 'root'}`, - CREATE_COLLECTION: (ownerCollectionId?: string) => - `/collections/${ownerCollectionId ?? ROOT_COLLECTION_ALIAS}/create`, - CREATE_DATASET: (collectionId?: string) => - `/datasets/${collectionId ?? ROOT_COLLECTION_ALIAS}/create` + COLLECTIONS: (collectionId: string) => `/collections/${collectionId}`, + CREATE_COLLECTION: (ownerCollectionId: string) => `/collections/${ownerCollectionId}/create`, + CREATE_DATASET: (collectionId: string) => `/datasets/${collectionId}/create` } export enum QueryParamKey { diff --git a/src/sections/collection/Collection.tsx b/src/sections/collection/Collection.tsx index 0db7f0916..e8e2c3bcc 100644 --- a/src/sections/collection/Collection.tsx +++ b/src/sections/collection/Collection.tsx @@ -75,23 +75,24 @@ export function Collection({ /> )} + + + ) : null + } + /> )} - - ) : null - } - /> ) diff --git a/src/sections/collection/CollectionFactory.tsx b/src/sections/collection/CollectionFactory.tsx index 6865ad81d..252902cde 100644 --- a/src/sections/collection/CollectionFactory.tsx +++ b/src/sections/collection/CollectionFactory.tsx @@ -4,6 +4,7 @@ import { CollectionJSDataverseRepository } from '../../collection/infrastructure import { Collection } from './Collection' import { INFINITE_SCROLL_ENABLED } from './config' import { useGetCollectionQueryParams } from './useGetCollectionQueryParams' +import { ROOT_COLLECTION_ALIAS } from '@/collection/domain/models/Collection' const collectionRepository = new CollectionJSDataverseRepository() export class CollectionFactory { @@ -14,7 +15,7 @@ export class CollectionFactory { function CollectionWithSearchParams() { const collectionQueryParams = useGetCollectionQueryParams() - const { collectionId = 'root' } = useParams<{ collectionId: string }>() + const { collectionId = ROOT_COLLECTION_ALIAS } = useParams<{ collectionId: string }>() const location = useLocation() const state = location.state as { published: boolean; created: boolean } | undefined const created = state?.created ?? false diff --git a/src/sections/create-dataset/CreateDataset.tsx b/src/sections/create-dataset/CreateDataset.tsx index a7862eb83..70d234a16 100644 --- a/src/sections/create-dataset/CreateDataset.tsx +++ b/src/sections/create-dataset/CreateDataset.tsx @@ -22,14 +22,14 @@ interface CreateDatasetProps { datasetRepository: DatasetRepository metadataBlockInfoRepository: MetadataBlockInfoRepository collectionRepository: CollectionRepository - collectionId?: string + collectionId: string } export function CreateDataset({ datasetRepository, metadataBlockInfoRepository, collectionRepository, - collectionId = ROOT_COLLECTION_ALIAS + collectionId }: CreateDatasetProps) { const { t } = useTranslation('createDataset') const { isModalOpen, hideModal } = useNotImplementedModal() @@ -84,7 +84,7 @@ export function CreateDataset({

{t('pageTitle')}

- + -
+ {HeaderFactory.create()}
diff --git a/src/sections/layout/header/Header.tsx b/src/sections/layout/header/Header.tsx index 092b7b8ef..8937eff6e 100644 --- a/src/sections/layout/header/Header.tsx +++ b/src/sections/layout/header/Header.tsx @@ -5,12 +5,13 @@ import { Route } from '../../Route.enum' import { useSession } from '../../session/SessionContext' import { BASE_URL } from '../../../config' import { LoggedInHeaderActions } from './LoggedInHeaderActions' -import { CollectionJSDataverseRepository } from '../../../collection/infrastructure/repositories/CollectionJSDataverseRepository' import styles from './Header.module.scss' +import { CollectionRepository } from '@/collection/domain/repositories/CollectionRepository' -const collectionRepository = new CollectionJSDataverseRepository() - -export function Header() { +interface HeaderProps { + collectionRepository: CollectionRepository +} +export function Header({ collectionRepository }: HeaderProps) { const { t } = useTranslation('header') const { user } = useSession() diff --git a/src/sections/layout/header/HeaderFactory.tsx b/src/sections/layout/header/HeaderFactory.tsx new file mode 100644 index 000000000..a00eaa5ce --- /dev/null +++ b/src/sections/layout/header/HeaderFactory.tsx @@ -0,0 +1,11 @@ +import { ReactElement } from 'react' +import { Header } from './Header' +import { CollectionJSDataverseRepository } from '@/collection/infrastructure/repositories/CollectionJSDataverseRepository' + +const collectionRepository = new CollectionJSDataverseRepository() + +export class HeaderFactory { + static create(): ReactElement { + return
+ } +} diff --git a/src/sections/layout/header/LoggedInHeaderActions.tsx b/src/sections/layout/header/LoggedInHeaderActions.tsx index 1d44f715e..17fd584de 100644 --- a/src/sections/layout/header/LoggedInHeaderActions.tsx +++ b/src/sections/layout/header/LoggedInHeaderActions.tsx @@ -8,6 +8,8 @@ import { User } from '../../../users/domain/models/User' import { CollectionRepository } from '../../../collection/domain/repositories/CollectionRepository' import { ROOT_COLLECTION_ALIAS } from '../../../collection/domain/models/Collection' import { AccountHelper } from '../../account/AccountHelper' +import { useCollection } from '@/sections/collection/useCollection' +import Skeleton from 'react-loading-skeleton' const currentPage = 0 @@ -23,6 +25,7 @@ export const LoggedInHeaderActions = ({ const { t } = useTranslation('header') const { logout } = useSession() const navigate = useNavigate() + const { collection, isLoading } = useCollection(collectionRepository, ROOT_COLLECTION_ALIAS) const { collectionUserPermissions } = useGetCollectionUserPermissions({ collectionIdOrAlias: ROOT_COLLECTION_ALIAS, @@ -34,9 +37,16 @@ export const LoggedInHeaderActions = ({ navigate(currentPage) }) } + if (isLoading) { + return + } + + if (!collection) { + return null + } - const createCollectionRoute = RouteWithParams.CREATE_COLLECTION() - const createDatasetRoute = RouteWithParams.CREATE_DATASET() + const createCollectionRoute = RouteWithParams.CREATE_COLLECTION(collection.id) + const createDatasetRoute = RouteWithParams.CREATE_DATASET(collection.id) const canUserAddCollectionToRoot = Boolean(collectionUserPermissions?.canAddCollection) const canUserAddDatasetToRoot = Boolean(collectionUserPermissions?.canAddDataset) diff --git a/src/sections/shared/add-data-actions/AddDataActionsButton.tsx b/src/sections/shared/add-data-actions/AddDataActionsButton.tsx index 517a0238d..e55d8bd8b 100644 --- a/src/sections/shared/add-data-actions/AddDataActionsButton.tsx +++ b/src/sections/shared/add-data-actions/AddDataActionsButton.tsx @@ -7,7 +7,7 @@ import { RouteWithParams } from '../../Route.enum' import styles from './AddDataActionsButton.module.scss' interface AddDataActionsButtonProps { - collectionId?: string + collectionId: string canAddCollection: boolean canAddDataset: boolean } diff --git a/tests/component/sections/create-dataset/CreateDataset.spec.tsx b/tests/component/sections/create-dataset/CreateDataset.spec.tsx index 159942511..99deb0f20 100644 --- a/tests/component/sections/create-dataset/CreateDataset.spec.tsx +++ b/tests/component/sections/create-dataset/CreateDataset.spec.tsx @@ -16,7 +16,7 @@ const collectionMetadataBlocksInfo = MetadataBlockInfoMother.getByCollectionIdDisplayedOnCreateTrue() const COLLECTION_NAME = 'Collection Name' -const collection = CollectionMother.create({ name: COLLECTION_NAME }) +const collection = CollectionMother.create({ name: COLLECTION_NAME, id: 'test-alias' }) describe('Create Dataset', () => { beforeEach(() => { @@ -36,6 +36,7 @@ describe('Create Dataset', () => { datasetRepository={datasetRepository} metadataBlockInfoRepository={metadataBlockInfoRepository} collectionRepository={collectionRepository} + collectionId={'non-existing-collection'} /> ) cy.findByText('Page Not Found').should('exist') @@ -52,6 +53,7 @@ describe('Create Dataset', () => { datasetRepository={datasetRepository} metadataBlockInfoRepository={metadataBlockInfoRepository} collectionRepository={collectionRepository} + collectionId={'test-collectionId'} /> ) cy.clock() @@ -67,6 +69,7 @@ describe('Create Dataset', () => { datasetRepository={datasetRepository} metadataBlockInfoRepository={metadataBlockInfoRepository} collectionRepository={collectionRepository} + collectionId={'test-collectionId'} /> ) @@ -78,18 +81,6 @@ describe('Create Dataset', () => { .should('have.class', 'active') }) - it('renders the Host Collection Form for root collection', () => { - cy.customMount( - - ) - cy.findByText(/^Host Collection/i).should('exist') - cy.findByDisplayValue('root').should('exist') - }) - it('renders the Host Collection Form', () => { cy.customMount( @@ -102,7 +93,7 @@ describe('Create Dataset', () => { ) cy.findByText(/^Host Collection/i).should('exist') - cy.findByDisplayValue('test-collectionId').should('exist') + cy.findByDisplayValue('test-alias').should('exist') cy.findByText(/^Edit Host Collection/i) .should('exist') .click() @@ -123,6 +114,7 @@ describe('Create Dataset', () => { datasetRepository={datasetRepository} metadataBlockInfoRepository={metadataBlockInfoRepository} collectionRepository={collectionRepository} + collectionId={'test-collectionId'} /> ) cy.findAllByTestId('not-allowed-to-create-dataset-alert').should('exist') @@ -134,6 +126,7 @@ describe('Create Dataset', () => { datasetRepository={datasetRepository} metadataBlockInfoRepository={metadataBlockInfoRepository} collectionRepository={collectionRepository} + collectionId={'test-collectionId'} /> ) cy.findAllByTestId('not-allowed-to-create-dataset-alert').should('not.exist') diff --git a/tests/component/sections/layout/header/Header.spec.tsx b/tests/component/sections/layout/header/Header.spec.tsx index f74b956ef..fe10d19e7 100644 --- a/tests/component/sections/layout/header/Header.spec.tsx +++ b/tests/component/sections/layout/header/Header.spec.tsx @@ -2,19 +2,24 @@ import { UserMother } from '../../../users/domain/models/UserMother' import { UserRepository } from '../../../../../src/users/domain/repositories/UserRepository' import { Header } from '../../../../../src/sections/layout/header/Header' import { SessionProvider } from '../../../../../src/sections/session/SessionProvider' +import { CollectionMother } from '@tests/component/collection/domain/models/CollectionMother' +import { CollectionRepository } from '@/collection/domain/repositories/CollectionRepository' const testUser = UserMother.create() +const rootCollection = CollectionMother.create({ id: 'root' }) const userRepository: UserRepository = {} as UserRepository +const collectionRepository: CollectionRepository = {} as CollectionRepository describe('Header component', () => { beforeEach(() => { userRepository.getAuthenticated = cy.stub().resolves(testUser) userRepository.removeAuthenticated = cy.stub().resolves() + collectionRepository.getById = cy.stub().resolves(rootCollection) }) it('displays the brand', () => { cy.customMount( -
+
) @@ -25,7 +30,7 @@ describe('Header component', () => { it('displays the user name when the user is logged in', () => { cy.customMount( -
+
) @@ -40,7 +45,7 @@ describe('Header component', () => { it('displays the Add Data Button when the user is logged in', () => { cy.customMount( -
+
) @@ -59,7 +64,7 @@ describe('Header component', () => { cy.customMount( -
+
) @@ -76,7 +81,7 @@ describe('Header component', () => { cy.customMount( -
+
) @@ -89,7 +94,7 @@ describe('Header component', () => { it('log outs the user after clicking Log Out', () => { cy.customMount( -
+
) From ff5efd53aff89a4303cd8888061ed06aa35443c2 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Fri, 25 Oct 2024 14:47:22 -0400 Subject: [PATCH 02/22] fix: remove unused import --- src/sections/create-dataset/CreateDataset.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sections/create-dataset/CreateDataset.tsx b/src/sections/create-dataset/CreateDataset.tsx index 70d234a16..6c630dd21 100644 --- a/src/sections/create-dataset/CreateDataset.tsx +++ b/src/sections/create-dataset/CreateDataset.tsx @@ -11,7 +11,6 @@ import { DatasetMetadataForm } from '../shared/form/DatasetMetadataForm' import { useGetCollectionUserPermissions } from '../../shared/hooks/useGetCollectionUserPermissions' import { CollectionRepository } from '../../collection/domain/repositories/CollectionRepository' import { useLoading } from '../loading/LoadingContext' -import { ROOT_COLLECTION_ALIAS } from '../../collection/domain/models/Collection' import { BreadcrumbsGenerator } from '../shared/hierarchy/BreadcrumbsGenerator' import { useCollection } from '../collection/useCollection' From ae32e6ca5b7f06141b8b8188dc2ae054a24cb7c1 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Fri, 25 Oct 2024 15:38:52 -0400 Subject: [PATCH 03/22] fix: lint errors --- src/sections/create-dataset/CreateDatasetFactory.tsx | 4 +++- src/stories/create-dataset/CreateDataset.stories.tsx | 3 +++ src/stories/layout/header/Header.stories.tsx | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/sections/create-dataset/CreateDatasetFactory.tsx b/src/sections/create-dataset/CreateDatasetFactory.tsx index 98c54d33a..a1fec5ae1 100644 --- a/src/sections/create-dataset/CreateDatasetFactory.tsx +++ b/src/sections/create-dataset/CreateDatasetFactory.tsx @@ -22,7 +22,9 @@ export class CreateDatasetFactory { function CreateDatasetWithSearchParams() { const { collectionId } = useParams<{ collectionId: string }>() - + if (!collectionId) { + throw new Error('collectionId is required') + } return ( ) @@ -41,6 +42,7 @@ export const Loading: Story = { datasetRepository={new DatasetMockRepository()} metadataBlockInfoRepository={new MetadataBlockInfoMockLoadingRepository()} collectionRepository={new CollectionMockRepository()} + collectionId={'collectionId'} /> ) } @@ -64,6 +66,7 @@ export const NotAllowedToAddDataset: Story = { datasetRepository={new DatasetMockRepository()} metadataBlockInfoRepository={new MetadataBlockInfoMockRepository()} collectionRepository={collectionRepositoryWithoutPermissionsToCreateDataset} + collectionId={'collectionId'} /> ) } diff --git a/src/stories/layout/header/Header.stories.tsx b/src/stories/layout/header/Header.stories.tsx index 83fb841ee..aef730840 100644 --- a/src/stories/layout/header/Header.stories.tsx +++ b/src/stories/layout/header/Header.stories.tsx @@ -2,6 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react' import { WithI18next } from '../../WithI18next' import { Header } from '../../../sections/layout/header/Header' import { WithLoggedInUser } from '../../WithLoggedInUser' +import { CollectionMockRepository } from '@/stories/collection/CollectionMockRepository' const meta: Meta = { title: 'Layout/Header', @@ -14,13 +15,13 @@ type Story = StoryObj export const LoggedOut: Story = { render: () => { - return
+ return
} } export const LoggedIn: Story = { decorators: [WithLoggedInUser], render: () => { - return
+ return
} } From 4c7f434e2804a676e53a0e5607a89d241ac6b97f Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Sat, 26 Oct 2024 08:25:16 -0400 Subject: [PATCH 04/22] fix: unit tests --- .../header/LoggedInHeaderActions.spec.tsx | 2 +- .../AddDataActionsButton.spec.tsx | 53 ++++++++++++++----- 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/tests/component/sections/layout/header/LoggedInHeaderActions.spec.tsx b/tests/component/sections/layout/header/LoggedInHeaderActions.spec.tsx index 26751e0ee..9a172df70 100644 --- a/tests/component/sections/layout/header/LoggedInHeaderActions.spec.tsx +++ b/tests/component/sections/layout/header/LoggedInHeaderActions.spec.tsx @@ -14,7 +14,7 @@ describe('LoggedInHeaderActions', () => { canAddCollection: false }) ) - + collectionRepository.getById = cy.stub().resolves(CollectionMother.create()) cy.customMount( ) diff --git a/tests/component/sections/shared/add-data-actions/AddDataActionsButton.spec.tsx b/tests/component/sections/shared/add-data-actions/AddDataActionsButton.spec.tsx index bdd636346..43407b797 100644 --- a/tests/component/sections/shared/add-data-actions/AddDataActionsButton.spec.tsx +++ b/tests/component/sections/shared/add-data-actions/AddDataActionsButton.spec.tsx @@ -2,7 +2,13 @@ import AddDataActionsButton from '../../../../../src/sections/shared/add-data-ac describe('AddDataActionsButton', () => { it('renders the button', () => { - cy.customMount() + cy.customMount( + + ) cy.findByRole('button', { name: /Add Data/i }).should('exist') cy.findByRole('button', { name: /Add Data/ }).click() @@ -10,15 +16,6 @@ describe('AddDataActionsButton', () => { cy.findByText('New Dataset').should('be.visible') }) - it('renders the new dataset button with the correct generated link', () => { - cy.customMount() - - cy.findByRole('button', { name: /Add Data/i }).click() - cy.findByText('New Dataset') - .should('be.visible') - .should('have.attr', 'href', '/datasets/root/create') - }) - it('renders the new dataset button with the correct generated link for specified collectionId', () => { const collectionId = 'some-collection-id' cy.customMount( @@ -36,7 +33,14 @@ describe('AddDataActionsButton', () => { }) it('shows New Collection button enabled if user has permissions to create collection', () => { - cy.customMount() + const collectionId = 'some-collection-id' + cy.customMount( + + ) cy.findByRole('button', { name: /Add Data/i }).as('addDataBtn') cy.get('@addDataBtn').should('exist') @@ -47,7 +51,14 @@ describe('AddDataActionsButton', () => { }) it('shows New Dataset button enabled if user has permissions to create dataset', () => { - cy.customMount() + const collectionId = 'some-collection-id' + cy.customMount( + + ) cy.findByRole('button', { name: /Add Data/i }).as('addDataBtn') cy.get('@addDataBtn').should('exist') @@ -58,7 +69,14 @@ describe('AddDataActionsButton', () => { }) it('shows New Collection button disabled if user does not have permissions to create collection', () => { - cy.customMount() + const collectionId = 'some-collection-id' + cy.customMount( + + ) cy.findByRole('button', { name: /Add Data/i }).as('addDataBtn') cy.get('@addDataBtn').should('exist') @@ -69,7 +87,14 @@ describe('AddDataActionsButton', () => { }) it('shows New Dataset button disabled if user does not have permissions to create dataset', () => { - cy.customMount() + const collectionId = 'some-collection-id' + cy.customMount( + + ) cy.findByRole('button', { name: /Add Data/i }).as('addDataBtn') cy.get('@addDataBtn').should('exist') From 21acc36a6d3017c58618b74d441f2170798e5067 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 29 Oct 2024 17:13:08 -0400 Subject: [PATCH 05/22] removed references to ROOT_COLLECTION_ALIAS from components (using default instead) Updated components that depend on collectionId. --- package-lock.json | 8 ++--- package.json | 2 +- src/collection/domain/models/Collection.ts | 2 -- .../repositories/CollectionRepository.ts | 6 ++-- .../domain/useCases/createCollection.ts | 2 +- .../domain/useCases/getCollectionById.ts | 2 +- .../useCases/getCollectionUserPermissions.ts | 2 +- .../CollectionJSDataverseRepository.ts | 7 +++-- .../domain/repositories/DatasetRepository.ts | 2 +- .../DatasetJSDataverseRepository.ts | 6 +--- src/sections/account/Account.tsx | 29 ++++++++++++------- src/sections/account/AccountFactory.tsx | 10 ++++++- src/sections/collection/Collection.tsx | 16 ++++++---- src/sections/collection/CollectionFactory.tsx | 5 ++-- .../CollectionItemsPanel.tsx | 1 + .../items-list/ItemsList.tsx | 7 ++++- .../collection-card/CollectionCard.tsx | 8 +++-- .../collection-card/CollectionCardInfo.tsx | 12 ++++---- src/sections/collection/useCollection.tsx | 5 ++-- .../CreateCollectionFactory.tsx | 7 +++-- .../layout/header/LoggedInHeaderActions.tsx | 5 ++-- .../hooks/useGetCollectionUserPermissions.ts | 2 +- .../CreateCollection.stories.tsx | 3 +- .../AddDataActionsButton.stories.tsx | 3 +- .../CollectionItemsPanel.spec.tsx | 3 +- .../useGetCollectionFacets.spec.tsx | 3 +- .../shared/collection/CollectionHelper.ts | 2 ++ .../shared/datasets/DatasetHelper.ts | 3 +- 28 files changed, 98 insertions(+), 65 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1d975f33c..c485f7295 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-alpha.2", + "@iqss/dataverse-client-javascript": "npm:@IQSS/dataverse-client-javascript@^2.0.0-pr207.d14dc1c", "@iqss/dataverse-design-system": "*", "@istanbuljs/nyc-config-typescript": "1.0.2", "@tanstack/react-table": "8.9.2", @@ -3674,9 +3674,9 @@ }, "node_modules/@iqss/dataverse-client-javascript": { "name": "@IQSS/dataverse-client-javascript", - "version": "2.0.0-alpha.2", - "resolved": "https://npm.pkg.github.com/download/@IQSS/dataverse-client-javascript/2.0.0-alpha.2/6f926581c976bbf8649053323e1c82a729d56706", - "integrity": "sha512-bJgGirBFr4gL+pVFz0zNAlMovxWHJMi9RCN9v6lnpkLU+fKHUTeMkEgQdGxoA0lI3V8cvA+e2xcpoi7/24vRKg==", + "version": "2.0.0-pr207.d14dc1c", + "resolved": "https://npm.pkg.github.com/download/@IQSS/dataverse-client-javascript/2.0.0-pr207.d14dc1c/e1aad714bbd5a7e15904e1da1188823b4f41bcac", + "integrity": "sha512-1dXVQ5xdPeQUkePlZH2G5uHi7Jas3zaexM0Tx3UYzDTFihuBLoEfMqMYSRZIDlfRMP4omxsr8yKoccrEEqo0qQ==", "dependencies": { "@types/node": "^18.15.11", "@types/turndown": "^5.0.1", diff --git a/package.json b/package.json index fe43d59f1..f2f231e11 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-alpha.2", + "@iqss/dataverse-client-javascript": "npm:@IQSS/dataverse-client-javascript@^2.0.0-pr207.d14dc1c", "@iqss/dataverse-design-system": "*", "@istanbuljs/nyc-config-typescript": "1.0.2", "@tanstack/react-table": "8.9.2", diff --git a/src/collection/domain/models/Collection.ts b/src/collection/domain/models/Collection.ts index de1235f8c..885c0a13a 100644 --- a/src/collection/domain/models/Collection.ts +++ b/src/collection/domain/models/Collection.ts @@ -15,5 +15,3 @@ export interface CollectionInputLevel { include: boolean required: boolean } - -export const ROOT_COLLECTION_ALIAS = ':root' diff --git a/src/collection/domain/repositories/CollectionRepository.ts b/src/collection/domain/repositories/CollectionRepository.ts index 75c77005c..d4a8567a4 100644 --- a/src/collection/domain/repositories/CollectionRepository.ts +++ b/src/collection/domain/repositories/CollectionRepository.ts @@ -7,10 +7,10 @@ import { CollectionUserPermissions } from '../models/CollectionUserPermissions' import { CollectionDTO } from '../useCases/DTOs/CollectionDTO' export interface CollectionRepository { - getById: (id: string) => Promise + getById: (id?: string) => Promise create(collection: CollectionDTO, hostCollection?: string): Promise - getFacets(collectionIdOrAlias: number | string): Promise - getUserPermissions(collectionIdOrAlias: number | string): Promise + getFacets(collectionIdOrAlias?: number | string): Promise + getUserPermissions(collectionIdOrAlias?: number | string): Promise publish(collectionIdOrAlias: number | string): Promise getItems( collectionId: string, diff --git a/src/collection/domain/useCases/createCollection.ts b/src/collection/domain/useCases/createCollection.ts index 68af8ba32..67da6fef5 100644 --- a/src/collection/domain/useCases/createCollection.ts +++ b/src/collection/domain/useCases/createCollection.ts @@ -5,7 +5,7 @@ import { CollectionDTO } from './DTOs/CollectionDTO' export function createCollection( collectionRepository: CollectionRepository, collection: CollectionDTO, - hostCollection?: string + hostCollection: string ): Promise { return collectionRepository.create(collection, hostCollection).catch((error: WriteError) => { throw error diff --git a/src/collection/domain/useCases/getCollectionById.ts b/src/collection/domain/useCases/getCollectionById.ts index 7fc9a9a40..c2da48d87 100644 --- a/src/collection/domain/useCases/getCollectionById.ts +++ b/src/collection/domain/useCases/getCollectionById.ts @@ -3,7 +3,7 @@ import { CollectionRepository } from '../repositories/CollectionRepository' export async function getCollectionById( collectionRepository: CollectionRepository, - id: string + id?: string ): Promise { return collectionRepository.getById(id).catch((error: Error) => { throw new Error(error.message) diff --git a/src/collection/domain/useCases/getCollectionUserPermissions.ts b/src/collection/domain/useCases/getCollectionUserPermissions.ts index fb5d10a6d..1c51b23f3 100644 --- a/src/collection/domain/useCases/getCollectionUserPermissions.ts +++ b/src/collection/domain/useCases/getCollectionUserPermissions.ts @@ -3,7 +3,7 @@ import { CollectionUserPermissions } from '../models/CollectionUserPermissions' export function getCollectionUserPermissions( collectionRepository: CollectionRepository, - collectionIdOrAlias: number | string + collectionIdOrAlias?: number | string ): Promise { return collectionRepository.getUserPermissions(collectionIdOrAlias).catch((error: Error) => { throw new Error(error.message) diff --git a/src/collection/infrastructure/repositories/CollectionJSDataverseRepository.ts b/src/collection/infrastructure/repositories/CollectionJSDataverseRepository.ts index 3f745a569..4a04c1545 100644 --- a/src/collection/infrastructure/repositories/CollectionJSDataverseRepository.ts +++ b/src/collection/infrastructure/repositories/CollectionJSDataverseRepository.ts @@ -18,7 +18,8 @@ import { CollectionSearchCriteria } from '../../domain/models/CollectionSearchCr import { JSCollectionItemsMapper } from '../mappers/JSCollectionItemsMapper' export class CollectionJSDataverseRepository implements CollectionRepository { - getById(id: string): Promise { + getById(id?: string): Promise { + console.log('calling getCollection.execute with id:', id) return getCollection .execute(id) .then((jsCollection) => JSCollectionMapper.toCollection(jsCollection)) @@ -30,11 +31,11 @@ export class CollectionJSDataverseRepository implements CollectionRepository { .then((newCollectionIdentifier) => newCollectionIdentifier) } - getFacets(collectionIdOrAlias: number | string): Promise { + getFacets(collectionIdOrAlias?: number | string): Promise { return getCollectionFacets.execute(collectionIdOrAlias).then((facets) => facets) } - getUserPermissions(collectionIdOrAlias: number | string): Promise { + getUserPermissions(collectionIdOrAlias?: number | string): Promise { return getCollectionUserPermissions .execute(collectionIdOrAlias) .then((jsCollectionUserPermissions) => jsCollectionUserPermissions) diff --git a/src/dataset/domain/repositories/DatasetRepository.ts b/src/dataset/domain/repositories/DatasetRepository.ts index d829934dc..0e708786b 100644 --- a/src/dataset/domain/repositories/DatasetRepository.ts +++ b/src/dataset/domain/repositories/DatasetRepository.ts @@ -8,7 +8,7 @@ export interface DatasetRepository { getByPersistentId: (persistentId: string, version?: string) => Promise getLocks(persistentId: string): Promise getByPrivateUrlToken: (privateUrlToken: string) => Promise - create: (dataset: DatasetDTO, collectionId?: string) => Promise<{ persistentId: string }> + create: (dataset: DatasetDTO, collectionId: string) => Promise<{ persistentId: string }> updateMetadata: (datasetId: string | number, datasetDTO: DatasetDTO) => Promise getAllWithCount: ( collectionId: string, diff --git a/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts b/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts index cb352631a..84c4d93e2 100644 --- a/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts +++ b/src/dataset/infrastructure/repositories/DatasetJSDataverseRepository.ts @@ -32,7 +32,6 @@ import { DatasetDTO } from '../../domain/useCases/DTOs/DatasetDTO' import { DatasetDTOMapper } from '../mappers/DatasetDTOMapper' import { DatasetsWithCount } from '../../domain/models/DatasetsWithCount' import { VersionUpdateType } from '../../domain/models/VersionUpdateType' -import { ROOT_COLLECTION_ALIAS } from '../../../collection/domain/models/Collection' const includeDeaccessioned = true type DatasetDetails = [JSDataset, string[], string, JSDatasetPermissions, JSDatasetLock[]] @@ -223,10 +222,7 @@ export class DatasetJSDataverseRepository implements DatasetRepository { }) } - create( - dataset: DatasetDTO, - collectionId = ROOT_COLLECTION_ALIAS - ): Promise<{ persistentId: string }> { + create(dataset: DatasetDTO, collectionId: string): Promise<{ persistentId: string }> { return createDataset .execute(DatasetDTOMapper.toJSDatasetDTO(dataset), collectionId) .then((jsDatasetIdentifiers: JSDatasetIdentifiers) => ({ diff --git a/src/sections/account/Account.tsx b/src/sections/account/Account.tsx index 06d5a9fbb..8a9977f9d 100644 --- a/src/sections/account/Account.tsx +++ b/src/sections/account/Account.tsx @@ -1,37 +1,44 @@ -import { useEffect } from 'react' import { useTranslation } from 'react-i18next' import { Tabs } from '@iqss/dataverse-design-system' -import { useLoading } from '../loading/LoadingContext' import { AccountHelper, AccountPanelTabKey } from './AccountHelper' import { ApiTokenSection } from './api-token-section/ApiTokenSection' import { BreadcrumbsGenerator } from '../shared/hierarchy/BreadcrumbsGenerator' +import { useCollection } from '@/sections/collection/useCollection' +import { useLoading } from '../loading/LoadingContext' +import { CollectionRepository } from '@/collection/domain/repositories/CollectionRepository' import styles from './Account.module.scss' import { DvObjectType, UpwardHierarchyNode } from '../../shared/hierarchy/domain/models/UpwardHierarchyNode' -import { ROOT_COLLECTION_ALIAS } from '../../collection/domain/models/Collection' + +import { useEffect } from 'react' +import { BreadcrumbsSkeleton } from '@/sections/shared/hierarchy/BreadcrumbsSkeleton' const tabsKeys = AccountHelper.ACCOUNT_PANEL_TABS_KEYS interface AccountProps { defaultActiveTabKey: AccountPanelTabKey + collectionRepository: CollectionRepository } -export const Account = ({ defaultActiveTabKey }: AccountProps) => { +export const Account = ({ defaultActiveTabKey, collectionRepository }: AccountProps) => { const { t } = useTranslation('account') + const { collection, isLoading: collectionIsLoading } = useCollection(collectionRepository) const { setIsLoading } = useLoading() + useEffect(() => { + setIsLoading(collectionIsLoading) + }, [collectionIsLoading, setIsLoading]) + + if (collectionIsLoading || !collection) { + return + } const rootHierarchy = new UpwardHierarchyNode( - 'Root', + collection.name, DvObjectType.COLLECTION, - ROOT_COLLECTION_ALIAS + collection.id ) - - useEffect(() => { - setIsLoading(false) - }, [setIsLoading]) - return (
diff --git a/src/sections/account/AccountFactory.tsx b/src/sections/account/AccountFactory.tsx index 0ecbab6b5..218d44c55 100644 --- a/src/sections/account/AccountFactory.tsx +++ b/src/sections/account/AccountFactory.tsx @@ -2,6 +2,9 @@ import { ReactElement } from 'react' import { useSearchParams } from 'react-router-dom' import { AccountHelper } from './AccountHelper' import { Account } from './Account' +import { CollectionJSDataverseRepository } from '@/collection/infrastructure/repositories/CollectionJSDataverseRepository' + +const collectionRepository = new CollectionJSDataverseRepository() export class AccountFactory { static create(): ReactElement { @@ -13,5 +16,10 @@ function AccountWithSearchParams() { const [searchParams] = useSearchParams() const defaultActiveTabKey = AccountHelper.defineSelectedTabKey(searchParams) - return + return ( + + ) } diff --git a/src/sections/collection/Collection.tsx b/src/sections/collection/Collection.tsx index e8e2c3bcc..f90964f0b 100644 --- a/src/sections/collection/Collection.tsx +++ b/src/sections/collection/Collection.tsx @@ -18,7 +18,7 @@ import styles from './Collection.module.scss' interface CollectionProps { collectionRepository: CollectionRepository - collectionId: string + collectionIdFromParams: string | undefined created: boolean published: boolean collectionQueryParams: UseCollectionQueryParamsReturnType @@ -26,7 +26,7 @@ interface CollectionProps { } export function Collection({ - collectionId, + collectionIdFromParams, collectionRepository, created, published, @@ -35,9 +35,13 @@ export function Collection({ useTranslation('collection') useScrollTop() const { user } = useSession() - const { collection, isLoading } = useCollection(collectionRepository, collectionId, published) + const { collection, isLoading } = useCollection( + collectionRepository, + collectionIdFromParams, + published + ) const { collectionUserPermissions } = useGetCollectionUserPermissions({ - collectionIdOrAlias: collectionId, + collectionIdOrAlias: collectionIdFromParams, collectionRepository }) @@ -77,8 +81,8 @@ export function Collection({ )} () + const { collectionId } = useParams<{ collectionId: string }>() const location = useLocation() const state = location.state as { published: boolean; created: boolean } | undefined const created = state?.created ?? false @@ -24,7 +23,7 @@ function CollectionWithSearchParams() { return ( (
  • {collectionItem?.type === CollectionItemType.COLLECTION && ( - + )} {collectionItem?.type === CollectionItemType.DATASET && ( diff --git a/src/sections/collection/collection-items-panel/items-list/collection-card/CollectionCard.tsx b/src/sections/collection/collection-items-panel/items-list/collection-card/CollectionCard.tsx index 768d77d10..abeb31e39 100644 --- a/src/sections/collection/collection-items-panel/items-list/collection-card/CollectionCard.tsx +++ b/src/sections/collection/collection-items-panel/items-list/collection-card/CollectionCard.tsx @@ -6,15 +6,19 @@ import styles from './CollectionCard.module.scss' interface CollectionCardProps { collectionPreview: CollectionItemTypePreview + parentCollectionAlias: string } -export function CollectionCard({ collectionPreview }: CollectionCardProps) { +export function CollectionCard({ collectionPreview, parentCollectionAlias }: CollectionCardProps) { return (
    - +
    ) diff --git a/src/sections/collection/collection-items-panel/items-list/collection-card/CollectionCardInfo.tsx b/src/sections/collection/collection-items-panel/items-list/collection-card/CollectionCardInfo.tsx index 5c182b285..7fcaf07d6 100644 --- a/src/sections/collection/collection-items-panel/items-list/collection-card/CollectionCardInfo.tsx +++ b/src/sections/collection/collection-items-panel/items-list/collection-card/CollectionCardInfo.tsx @@ -1,6 +1,4 @@ -import { useParams } from 'react-router-dom' import { Stack } from '@iqss/dataverse-design-system' -import { ROOT_COLLECTION_ALIAS } from '@/collection/domain/models/Collection' import { CollectionItemTypePreview } from '@/collection/domain/models/CollectionItemTypePreview' import { DvObjectType } from '@/shared/hierarchy/domain/models/UpwardHierarchyNode' import { DateHelper } from '@/shared/helpers/DateHelper' @@ -10,11 +8,15 @@ import styles from './CollectionCard.module.scss' interface CollectionCardInfoProps { collectionPreview: CollectionItemTypePreview + parentCollectionAlias: string } -export function CollectionCardInfo({ collectionPreview }: CollectionCardInfoProps) { - const { collectionId = ROOT_COLLECTION_ALIAS } = useParams<{ collectionId: string }>() - const isStandingOnParentCollectionPage = collectionPreview.parentCollectionAlias === collectionId +export function CollectionCardInfo({ + collectionPreview, + parentCollectionAlias +}: CollectionCardInfoProps) { + const isStandingOnParentCollectionPage = + collectionPreview.parentCollectionAlias === parentCollectionAlias return (
    diff --git a/src/sections/collection/useCollection.tsx b/src/sections/collection/useCollection.tsx index 74c99159f..48a8742a2 100644 --- a/src/sections/collection/useCollection.tsx +++ b/src/sections/collection/useCollection.tsx @@ -5,7 +5,7 @@ import { getCollectionById } from '../../collection/domain/useCases/getCollectio export function useCollection( collectionRepository: CollectionRepository, - collectionId: string, + collectionId?: string | undefined, published?: boolean ) { const [isLoading, setIsLoading] = useState(true) @@ -15,7 +15,8 @@ export function useCollection( setIsLoading(true) setCollection(undefined) getCollectionById(collectionRepository, collectionId) - .then((collection: Collection | undefined) => { + .then((collection: Collection) => { + console.log('useCollection: returning collection', collection) setCollection(collection) }) .catch((error) => { diff --git a/src/sections/create-collection/CreateCollectionFactory.tsx b/src/sections/create-collection/CreateCollectionFactory.tsx index 1e65d3b9b..bce567238 100644 --- a/src/sections/create-collection/CreateCollectionFactory.tsx +++ b/src/sections/create-collection/CreateCollectionFactory.tsx @@ -2,7 +2,6 @@ import { ReactElement } from 'react' import { useParams } from 'react-router-dom' import { CollectionJSDataverseRepository } from '../../collection/infrastructure/repositories/CollectionJSDataverseRepository' import { CreateCollection } from './CreateCollection' -import { ROOT_COLLECTION_ALIAS } from '../../collection/domain/models/Collection' import { MetadataBlockInfoJSDataverseRepository } from '../../metadata-block-info/infrastructure/repositories/MetadataBlockInfoJSDataverseRepository' const collectionRepository = new CollectionJSDataverseRepository() @@ -15,8 +14,10 @@ export class CreateCollectionFactory { } function CreateCollectionWithParams() { - const { ownerCollectionId = ROOT_COLLECTION_ALIAS } = useParams<{ ownerCollectionId: string }>() - + const { ownerCollectionId } = useParams<{ ownerCollectionId: string }>() + if (!ownerCollectionId) { + throw new Error('ownerCollectionId is required') + } return ( = { title: 'Pages/Create Collection', component: CreateCollection, diff --git a/src/stories/shared/add-data-actions/AddDataActionsButton.stories.tsx b/src/stories/shared/add-data-actions/AddDataActionsButton.stories.tsx index 1da6ce4f7..069fcdb2a 100644 --- a/src/stories/shared/add-data-actions/AddDataActionsButton.stories.tsx +++ b/src/stories/shared/add-data-actions/AddDataActionsButton.stories.tsx @@ -1,7 +1,8 @@ import { Meta, StoryObj } from '@storybook/react' import { WithI18next } from '../../WithI18next' import AddDataActionsButton from '../../../sections/shared/add-data-actions/AddDataActionsButton' -import { ROOT_COLLECTION_ALIAS } from '../../../collection/domain/models/Collection' + +import { ROOT_COLLECTION_ALIAS } from '@tests/e2e-integration/shared/collection/CollectionHelper' const meta: Meta = { title: 'Sections/Shared/AddDataActions/AddDataActionsButton', diff --git a/tests/component/sections/collection/collection-items-panel/CollectionItemsPanel.spec.tsx b/tests/component/sections/collection/collection-items-panel/CollectionItemsPanel.spec.tsx index 4ea332bfa..871f3f272 100644 --- a/tests/component/sections/collection/collection-items-panel/CollectionItemsPanel.spec.tsx +++ b/tests/component/sections/collection/collection-items-panel/CollectionItemsPanel.spec.tsx @@ -1,5 +1,4 @@ import { CollectionItemsPanel } from '@/sections/collection/collection-items-panel/CollectionItemsPanel' -import { ROOT_COLLECTION_ALIAS } from '@/collection/domain/models/Collection' import { CollectionItem, CollectionItemSubset @@ -8,6 +7,8 @@ import { CollectionRepository } from '@/collection/domain/repositories/Collectio import { CollectionItemsMother } from '@tests/component/collection/domain/models/CollectionItemsMother' import { CollectionItemType } from '@/collection/domain/models/CollectionItemType' +import { ROOT_COLLECTION_ALIAS } from '@tests/e2e-integration/shared/collection/CollectionHelper' + const collectionRepository: CollectionRepository = {} as CollectionRepository const totalItemCount = 200 diff --git a/tests/component/sections/create-collection/useGetCollectionFacets.spec.tsx b/tests/component/sections/create-collection/useGetCollectionFacets.spec.tsx index 55b9962a9..2ba1780ee 100644 --- a/tests/component/sections/create-collection/useGetCollectionFacets.spec.tsx +++ b/tests/component/sections/create-collection/useGetCollectionFacets.spec.tsx @@ -2,7 +2,8 @@ import { act, renderHook } from '@testing-library/react' import { useGetCollectionFacets } from '../../../../src/sections/create-collection/useGetCollectionFacets' import { CollectionRepository } from '../../../../src/collection/domain/repositories/CollectionRepository' import { CollectionFacetMother } from '../../collection/domain/models/CollectionFacetMother' -import { ROOT_COLLECTION_ALIAS } from '../../../../src/collection/domain/models/Collection' + +import { ROOT_COLLECTION_ALIAS } from '@tests/e2e-integration/shared/collection/CollectionHelper' const collectionRepository: CollectionRepository = {} as CollectionRepository const collectionFacetsMock = CollectionFacetMother.createFacets() diff --git a/tests/e2e-integration/shared/collection/CollectionHelper.ts b/tests/e2e-integration/shared/collection/CollectionHelper.ts index 5fab95465..30a2bd12a 100644 --- a/tests/e2e-integration/shared/collection/CollectionHelper.ts +++ b/tests/e2e-integration/shared/collection/CollectionHelper.ts @@ -50,3 +50,5 @@ export class CollectionHelper extends DataverseApiHelper { return collectionResponse } } + +export const ROOT_COLLECTION_ALIAS = 'root' diff --git a/tests/e2e-integration/shared/datasets/DatasetHelper.ts b/tests/e2e-integration/shared/datasets/DatasetHelper.ts index faba4c5e1..5b1f91acf 100644 --- a/tests/e2e-integration/shared/datasets/DatasetHelper.ts +++ b/tests/e2e-integration/shared/datasets/DatasetHelper.ts @@ -3,7 +3,8 @@ import { DataverseApiHelper } from '../DataverseApiHelper' import { FileData } from '../files/FileHelper' import { DatasetLockReason } from '../../../../src/dataset/domain/models/Dataset' import { TestsUtils } from '../TestsUtils' -import { ROOT_COLLECTION_ALIAS } from '../../../../src/collection/domain/models/Collection' + +import { ROOT_COLLECTION_ALIAS } from '@tests/e2e-integration/shared/collection/CollectionHelper' export interface DatasetResponse { persistentId: string From d57826a84f4ed672d0aebb6f2b61fea7e423776d Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 29 Oct 2024 17:36:02 -0400 Subject: [PATCH 06/22] fix lint errors in stories --- src/stories/account/Account.stories.tsx | 8 +++++++- src/stories/collection/Collection.stories.tsx | 12 +++++------ .../CollectionLoadingMockRepository.ts | 2 +- .../collection/CollectionMockRepository.ts | 2 +- .../UnpublishedCollectionMockRepository.ts | 2 +- .../CollectionCard.stories.tsx | 20 ++++++++++++++----- 6 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/stories/account/Account.stories.tsx b/src/stories/account/Account.stories.tsx index b19475721..65081c710 100644 --- a/src/stories/account/Account.stories.tsx +++ b/src/stories/account/Account.stories.tsx @@ -4,6 +4,7 @@ import { WithI18next } from '../WithI18next' import { WithLayout } from '../WithLayout' import { WithLoggedInUser } from '../WithLoggedInUser' import { AccountHelper } from '../../sections/account/AccountHelper' +import { CollectionMockRepository } from '@/stories/collection/CollectionMockRepository' const meta: Meta = { title: 'Pages/Account', @@ -18,5 +19,10 @@ export default meta type Story = StoryObj export const APITokenTab: Story = { - render: () => + render: () => ( + + ) } diff --git a/src/stories/collection/Collection.stories.tsx b/src/stories/collection/Collection.stories.tsx index c56e42f20..f48b6235d 100644 --- a/src/stories/collection/Collection.stories.tsx +++ b/src/stories/collection/Collection.stories.tsx @@ -24,7 +24,7 @@ export const Default: Story = { render: () => ( ( ( ( ( ( { + getById(_id?: string): Promise { return new Promise(() => {}) } create(_collection: CollectionDTO, _hostCollection?: string): Promise { diff --git a/src/stories/collection/CollectionMockRepository.ts b/src/stories/collection/CollectionMockRepository.ts index 9766af900..efb2e116a 100644 --- a/src/stories/collection/CollectionMockRepository.ts +++ b/src/stories/collection/CollectionMockRepository.ts @@ -13,7 +13,7 @@ import { CollectionItemsMother } from '../../../tests/component/collection/domai import { CollectionItemType } from '@/collection/domain/models/CollectionItemType' export class CollectionMockRepository implements CollectionRepository { - getById(_id: string): Promise { + getById(_id?: string): Promise { return new Promise((resolve) => { setTimeout(() => { resolve(CollectionMother.createRealistic()) diff --git a/src/stories/collection/UnpublishedCollectionMockRepository.ts b/src/stories/collection/UnpublishedCollectionMockRepository.ts index c9194f4f7..9bc90dd61 100644 --- a/src/stories/collection/UnpublishedCollectionMockRepository.ts +++ b/src/stories/collection/UnpublishedCollectionMockRepository.ts @@ -4,7 +4,7 @@ import { FakerHelper } from '../../../tests/component/shared/FakerHelper' import { CollectionMockRepository } from '@/stories/collection/CollectionMockRepository' export class UnpublishedCollectionMockRepository extends CollectionMockRepository { - getById(_id: string): Promise { + getById(_id?: string): Promise { return new Promise((resolve) => { setTimeout(() => { resolve(CollectionMother.createUnpublished()) diff --git a/src/stories/collection/collection-items-panel/CollectionCard.stories.tsx b/src/stories/collection/collection-items-panel/CollectionCard.stories.tsx index 05443406e..e50285374 100644 --- a/src/stories/collection/collection-items-panel/CollectionCard.stories.tsx +++ b/src/stories/collection/collection-items-panel/CollectionCard.stories.tsx @@ -15,7 +15,10 @@ type Story = StoryObj export const Default: Story = { render: () => ( - + ) } @@ -24,19 +27,26 @@ export const WithLongDescription: Story = { const collectionPreview = CollectionItemTypePreviewMother.create({ description: FakerHelper.paragraph(20) }) - - return + return ( + + ) } } export const Unpublished: Story = { render: () => ( - + ) } export const WithThumbnail: Story = { render: () => ( - + ) } From c8eec6b6a0a5cd9bd4f5d2108970c0a63303d389 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 29 Oct 2024 17:43:44 -0400 Subject: [PATCH 07/22] fix component tests --- .../sections/account/Account.spec.tsx | 15 ++++++++++++++- .../sections/collection/Collection.spec.tsx | 18 +++++++++--------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/tests/component/sections/account/Account.spec.tsx b/tests/component/sections/account/Account.spec.tsx index 77fc048eb..dcf7d3862 100644 --- a/tests/component/sections/account/Account.spec.tsx +++ b/tests/component/sections/account/Account.spec.tsx @@ -1,8 +1,21 @@ import { Account } from '../../../../src/sections/account/Account' +import { AccountHelper } from '../../../../src/sections/account/AccountHelper' +import { CollectionRepository } from '@/collection/domain/repositories/CollectionRepository' +import { CollectionMother } from '@tests/component/collection/domain/models/CollectionMother' +const collectionRepository = {} as CollectionRepository +const collection = CollectionMother.create({ name: 'Root' }) describe('Account', () => { + beforeEach(() => { + collectionRepository.getById = cy.stub().resolves(collection) + }) it('should render the correct breadcrumbs', () => { - cy.mountAuthenticated() + cy.mountAuthenticated( + + ) cy.findByRole('link', { name: 'Root' }).should('exist') diff --git a/tests/component/sections/collection/Collection.spec.tsx b/tests/component/sections/collection/Collection.spec.tsx index 15f1e32de..a707d6094 100644 --- a/tests/component/sections/collection/Collection.spec.tsx +++ b/tests/component/sections/collection/Collection.spec.tsx @@ -21,7 +21,7 @@ describe('Collection page', () => { cy.customMount( { cy.customMount( { cy.customMount( { cy.customMount( { cy.customMount( { cy.mountAuthenticated( { cy.customMount( { cy.customMount( { cy.mountAuthenticated( Date: Tue, 29 Oct 2024 17:48:59 -0400 Subject: [PATCH 08/22] fix useGetCollectionFacets.spec.tsx --- .../create-collection/useGetCollectionFacets.spec.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/component/sections/create-collection/useGetCollectionFacets.spec.tsx b/tests/component/sections/create-collection/useGetCollectionFacets.spec.tsx index 2ba1780ee..797eef2e1 100644 --- a/tests/component/sections/create-collection/useGetCollectionFacets.spec.tsx +++ b/tests/component/sections/create-collection/useGetCollectionFacets.spec.tsx @@ -3,8 +3,6 @@ import { useGetCollectionFacets } from '../../../../src/sections/create-collecti import { CollectionRepository } from '../../../../src/collection/domain/repositories/CollectionRepository' import { CollectionFacetMother } from '../../collection/domain/models/CollectionFacetMother' -import { ROOT_COLLECTION_ALIAS } from '@tests/e2e-integration/shared/collection/CollectionHelper' - const collectionRepository: CollectionRepository = {} as CollectionRepository const collectionFacetsMock = CollectionFacetMother.createFacets() @@ -15,7 +13,7 @@ describe('useGetCollectionFacets', () => { const { result } = renderHook(() => useGetCollectionFacets({ collectionRepository, - collectionId: ROOT_COLLECTION_ALIAS + collectionId: 'collectionId' }) ) @@ -38,7 +36,7 @@ describe('useGetCollectionFacets', () => { const { result } = renderHook(() => useGetCollectionFacets({ collectionRepository, - collectionId: ROOT_COLLECTION_ALIAS + collectionId: 'collectionId' }) ) @@ -59,7 +57,7 @@ describe('useGetCollectionFacets', () => { const { result } = renderHook(() => useGetCollectionFacets({ collectionRepository, - collectionId: ROOT_COLLECTION_ALIAS + collectionId: 'collectionId' }) ) From 6edfaa06849d57becf7f49522d04c3fd070eabf7 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 29 Oct 2024 17:53:58 -0400 Subject: [PATCH 09/22] fix Mock CollectionRepository classes --- src/stories/collection/CollectionErrorMockRepository.ts | 2 +- src/stories/collection/NoCollectionMockRepository.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stories/collection/CollectionErrorMockRepository.ts b/src/stories/collection/CollectionErrorMockRepository.ts index 2d5e8b4e7..b897f3853 100644 --- a/src/stories/collection/CollectionErrorMockRepository.ts +++ b/src/stories/collection/CollectionErrorMockRepository.ts @@ -7,7 +7,7 @@ import { CollectionFacet } from '../../collection/domain/models/CollectionFacet' import { CollectionMockRepository } from './CollectionMockRepository' export class CollectionErrorMockRepository extends CollectionMockRepository { - getById(_id: string): Promise { + getById(_id?: string): Promise { return new Promise((_resolve, reject) => { setTimeout(() => { reject('Something went wrong') diff --git a/src/stories/collection/NoCollectionMockRepository.ts b/src/stories/collection/NoCollectionMockRepository.ts index 17cb063a0..63d8c5e00 100644 --- a/src/stories/collection/NoCollectionMockRepository.ts +++ b/src/stories/collection/NoCollectionMockRepository.ts @@ -7,7 +7,7 @@ import { CollectionFacet } from '../../collection/domain/models/CollectionFacet' import { CollectionMockRepository } from './CollectionMockRepository' export class NoCollectionMockRepository extends CollectionMockRepository { - getById(_id: string): Promise { + getById(_id?: string): Promise { return new Promise((_resolve, reject) => { setTimeout(() => { reject('Collection not found') From 70864132f64d6321830be295a0ee7cfea96cffa6 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Tue, 29 Oct 2024 20:30:07 -0400 Subject: [PATCH 10/22] move constant to a separate file --- src/stories/create-collection/CreateCollection.stories.tsx | 2 +- .../shared/add-data-actions/AddDataActionsButton.stories.tsx | 2 +- .../collection-items-panel/CollectionItemsPanel.spec.tsx | 3 +-- tests/e2e-integration/shared/collection/CollectionHelper.ts | 2 -- .../e2e-integration/shared/collection/ROOT_COLLECTION_ALIAS.ts | 1 + tests/e2e-integration/shared/datasets/DatasetHelper.ts | 2 +- 6 files changed, 5 insertions(+), 7 deletions(-) create mode 100644 tests/e2e-integration/shared/collection/ROOT_COLLECTION_ALIAS.ts diff --git a/src/stories/create-collection/CreateCollection.stories.tsx b/src/stories/create-collection/CreateCollection.stories.tsx index 52f3ca45a..f868a305d 100644 --- a/src/stories/create-collection/CreateCollection.stories.tsx +++ b/src/stories/create-collection/CreateCollection.stories.tsx @@ -12,7 +12,7 @@ import { MetadataBlockInfoMockRepository } from '../shared-mock-repositories/met import { MetadataBlockInfoMockLoadingRepository } from '../shared-mock-repositories/metadata-block-info/MetadataBlockInfoMockLoadingRepository' import { MetadataBlockInfoMockErrorRepository } from '../shared-mock-repositories/metadata-block-info/MetadataBlockInfoMockErrorRepository' -import { ROOT_COLLECTION_ALIAS } from '@tests/e2e-integration/shared/collection/CollectionHelper' +import { ROOT_COLLECTION_ALIAS } from '@tests/e2e-integration/shared/collection/ROOT_COLLECTION_ALIAS' const meta: Meta = { title: 'Pages/Create Collection', diff --git a/src/stories/shared/add-data-actions/AddDataActionsButton.stories.tsx b/src/stories/shared/add-data-actions/AddDataActionsButton.stories.tsx index 069fcdb2a..77df60b5a 100644 --- a/src/stories/shared/add-data-actions/AddDataActionsButton.stories.tsx +++ b/src/stories/shared/add-data-actions/AddDataActionsButton.stories.tsx @@ -2,7 +2,7 @@ import { Meta, StoryObj } from '@storybook/react' import { WithI18next } from '../../WithI18next' import AddDataActionsButton from '../../../sections/shared/add-data-actions/AddDataActionsButton' -import { ROOT_COLLECTION_ALIAS } from '@tests/e2e-integration/shared/collection/CollectionHelper' +import { ROOT_COLLECTION_ALIAS } from '@tests/e2e-integration/shared/collection/ROOT_COLLECTION_ALIAS' const meta: Meta = { title: 'Sections/Shared/AddDataActions/AddDataActionsButton', diff --git a/tests/component/sections/collection/collection-items-panel/CollectionItemsPanel.spec.tsx b/tests/component/sections/collection/collection-items-panel/CollectionItemsPanel.spec.tsx index 871f3f272..20dc0c072 100644 --- a/tests/component/sections/collection/collection-items-panel/CollectionItemsPanel.spec.tsx +++ b/tests/component/sections/collection/collection-items-panel/CollectionItemsPanel.spec.tsx @@ -7,8 +7,7 @@ import { CollectionRepository } from '@/collection/domain/repositories/Collectio import { CollectionItemsMother } from '@tests/component/collection/domain/models/CollectionItemsMother' import { CollectionItemType } from '@/collection/domain/models/CollectionItemType' -import { ROOT_COLLECTION_ALIAS } from '@tests/e2e-integration/shared/collection/CollectionHelper' - +const ROOT_COLLECTION_ALIAS = 'root' const collectionRepository: CollectionRepository = {} as CollectionRepository const totalItemCount = 200 diff --git a/tests/e2e-integration/shared/collection/CollectionHelper.ts b/tests/e2e-integration/shared/collection/CollectionHelper.ts index 30a2bd12a..5fab95465 100644 --- a/tests/e2e-integration/shared/collection/CollectionHelper.ts +++ b/tests/e2e-integration/shared/collection/CollectionHelper.ts @@ -50,5 +50,3 @@ export class CollectionHelper extends DataverseApiHelper { return collectionResponse } } - -export const ROOT_COLLECTION_ALIAS = 'root' diff --git a/tests/e2e-integration/shared/collection/ROOT_COLLECTION_ALIAS.ts b/tests/e2e-integration/shared/collection/ROOT_COLLECTION_ALIAS.ts new file mode 100644 index 000000000..2160f412a --- /dev/null +++ b/tests/e2e-integration/shared/collection/ROOT_COLLECTION_ALIAS.ts @@ -0,0 +1 @@ +export const ROOT_COLLECTION_ALIAS = 'root' diff --git a/tests/e2e-integration/shared/datasets/DatasetHelper.ts b/tests/e2e-integration/shared/datasets/DatasetHelper.ts index 5b1f91acf..219b059e8 100644 --- a/tests/e2e-integration/shared/datasets/DatasetHelper.ts +++ b/tests/e2e-integration/shared/datasets/DatasetHelper.ts @@ -4,7 +4,7 @@ import { FileData } from '../files/FileHelper' import { DatasetLockReason } from '../../../../src/dataset/domain/models/Dataset' import { TestsUtils } from '../TestsUtils' -import { ROOT_COLLECTION_ALIAS } from '@tests/e2e-integration/shared/collection/CollectionHelper' +import { ROOT_COLLECTION_ALIAS } from '@tests/e2e-integration/shared/collection/ROOT_COLLECTION_ALIAS' export interface DatasetResponse { persistentId: string From 632dbbd6fad5de7df2492a64fdf753dcf69c0f86 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Wed, 30 Oct 2024 06:23:50 -0400 Subject: [PATCH 11/22] fix: remove console.log --- .../repositories/CollectionJSDataverseRepository.ts | 1 - src/sections/collection/useCollection.tsx | 1 - tests/e2e-integration/e2e/sections/collection/Collection.spec.ts | 1 - tests/e2e-integration/shared/collection/CollectionHelper.ts | 1 - 4 files changed, 4 deletions(-) diff --git a/src/collection/infrastructure/repositories/CollectionJSDataverseRepository.ts b/src/collection/infrastructure/repositories/CollectionJSDataverseRepository.ts index 4a04c1545..996b6750a 100644 --- a/src/collection/infrastructure/repositories/CollectionJSDataverseRepository.ts +++ b/src/collection/infrastructure/repositories/CollectionJSDataverseRepository.ts @@ -19,7 +19,6 @@ import { JSCollectionItemsMapper } from '../mappers/JSCollectionItemsMapper' export class CollectionJSDataverseRepository implements CollectionRepository { getById(id?: string): Promise { - console.log('calling getCollection.execute with id:', id) return getCollection .execute(id) .then((jsCollection) => JSCollectionMapper.toCollection(jsCollection)) diff --git a/src/sections/collection/useCollection.tsx b/src/sections/collection/useCollection.tsx index 48a8742a2..de58cdcba 100644 --- a/src/sections/collection/useCollection.tsx +++ b/src/sections/collection/useCollection.tsx @@ -16,7 +16,6 @@ export function useCollection( setCollection(undefined) getCollectionById(collectionRepository, collectionId) .then((collection: Collection) => { - console.log('useCollection: returning collection', collection) setCollection(collection) }) .catch((error) => { diff --git a/tests/e2e-integration/e2e/sections/collection/Collection.spec.ts b/tests/e2e-integration/e2e/sections/collection/Collection.spec.ts index 8af6e0b6f..03bcf7b5b 100644 --- a/tests/e2e-integration/e2e/sections/collection/Collection.spec.ts +++ b/tests/e2e-integration/e2e/sections/collection/Collection.spec.ts @@ -38,7 +38,6 @@ describe('Collection Page', () => { cy.wrap(CollectionHelper.create(uniqueCollectionId)) .its('id') .then((collectionId: string) => { - console.log('collectionId', collectionId) cy.visit(`/spa/collections/${collectionId}`) cy.findByText('Unpublished').should('exist') cy.findByRole('button', { name: 'Publish' }).click() diff --git a/tests/e2e-integration/shared/collection/CollectionHelper.ts b/tests/e2e-integration/shared/collection/CollectionHelper.ts index 5fab95465..ebca9d668 100644 --- a/tests/e2e-integration/shared/collection/CollectionHelper.ts +++ b/tests/e2e-integration/shared/collection/CollectionHelper.ts @@ -43,7 +43,6 @@ export class CollectionHelper extends DataverseApiHelper { } static async createAndPublish(id = 'subcollection'): Promise { const collectionResponse = await CollectionHelper.create(id) - console.log(collectionResponse) if (!collectionResponse.isReleased) { await CollectionHelper.publish(collectionResponse.id) } From 44b2569f23e000d41a76ff0c9f45125d18d5d214 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Fri, 1 Nov 2024 09:29:06 -0400 Subject: [PATCH 12/22] fix: remove Breadcrumbs from Account.tsx --- README.md | 6 +++- src/sections/account/Account.module.scss | 5 +++ src/sections/account/Account.tsx | 32 ++----------------- src/sections/account/AccountFactory.tsx | 10 +----- .../CollectionErrorMockRepository.ts | 2 +- .../sections/account/Account.spec.tsx | 25 ++++----------- 6 files changed, 21 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index 162c6ac3b..c5dfe3d1c 100644 --- a/README.md +++ b/README.md @@ -219,7 +219,11 @@ The environment is accessible through the following URLs: > > Given that at the moment the SPA only supports file uploading through direct upload (S3), the storage selector on the create collection > page is disabled. The collection is always created using the default storage, which must be S3 - +> +> #### Account Page BreadCrumbs +> +> The Account Page has been updated to remove breadcrumbs, as the page is not part of the main navigation. +>

    (back to top)

    diff --git a/src/sections/account/Account.module.scss b/src/sections/account/Account.module.scss index e76e0535b..6ce690ed5 100644 --- a/src/sections/account/Account.module.scss +++ b/src/sections/account/Account.module.scss @@ -1,5 +1,10 @@ @import 'node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module'; +.header { + margin-bottom: 20px; + padding: 20px 0; +} + .tab-container { padding: 1rem; } diff --git a/src/sections/account/Account.tsx b/src/sections/account/Account.tsx index 8a9977f9d..3d06c6ec3 100644 --- a/src/sections/account/Account.tsx +++ b/src/sections/account/Account.tsx @@ -2,48 +2,20 @@ import { useTranslation } from 'react-i18next' import { Tabs } from '@iqss/dataverse-design-system' import { AccountHelper, AccountPanelTabKey } from './AccountHelper' import { ApiTokenSection } from './api-token-section/ApiTokenSection' -import { BreadcrumbsGenerator } from '../shared/hierarchy/BreadcrumbsGenerator' -import { useCollection } from '@/sections/collection/useCollection' -import { useLoading } from '../loading/LoadingContext' -import { CollectionRepository } from '@/collection/domain/repositories/CollectionRepository' import styles from './Account.module.scss' -import { - DvObjectType, - UpwardHierarchyNode -} from '../../shared/hierarchy/domain/models/UpwardHierarchyNode' - -import { useEffect } from 'react' -import { BreadcrumbsSkeleton } from '@/sections/shared/hierarchy/BreadcrumbsSkeleton' const tabsKeys = AccountHelper.ACCOUNT_PANEL_TABS_KEYS interface AccountProps { defaultActiveTabKey: AccountPanelTabKey - collectionRepository: CollectionRepository } -export const Account = ({ defaultActiveTabKey, collectionRepository }: AccountProps) => { +export const Account = ({ defaultActiveTabKey }: AccountProps) => { const { t } = useTranslation('account') - const { collection, isLoading: collectionIsLoading } = useCollection(collectionRepository) - const { setIsLoading } = useLoading() - - useEffect(() => { - setIsLoading(collectionIsLoading) - }, [collectionIsLoading, setIsLoading]) - if (collectionIsLoading || !collection) { - return - } - const rootHierarchy = new UpwardHierarchyNode( - collection.name, - DvObjectType.COLLECTION, - collection.id - ) return (
    - - -
    +

    {t('pageTitle')}

    diff --git a/src/sections/account/AccountFactory.tsx b/src/sections/account/AccountFactory.tsx index 218d44c55..0ecbab6b5 100644 --- a/src/sections/account/AccountFactory.tsx +++ b/src/sections/account/AccountFactory.tsx @@ -2,9 +2,6 @@ import { ReactElement } from 'react' import { useSearchParams } from 'react-router-dom' import { AccountHelper } from './AccountHelper' import { Account } from './Account' -import { CollectionJSDataverseRepository } from '@/collection/infrastructure/repositories/CollectionJSDataverseRepository' - -const collectionRepository = new CollectionJSDataverseRepository() export class AccountFactory { static create(): ReactElement { @@ -16,10 +13,5 @@ function AccountWithSearchParams() { const [searchParams] = useSearchParams() const defaultActiveTabKey = AccountHelper.defineSelectedTabKey(searchParams) - return ( - - ) + return } diff --git a/src/stories/collection/CollectionErrorMockRepository.ts b/src/stories/collection/CollectionErrorMockRepository.ts index b897f3853..2d5e8b4e7 100644 --- a/src/stories/collection/CollectionErrorMockRepository.ts +++ b/src/stories/collection/CollectionErrorMockRepository.ts @@ -7,7 +7,7 @@ import { CollectionFacet } from '../../collection/domain/models/CollectionFacet' import { CollectionMockRepository } from './CollectionMockRepository' export class CollectionErrorMockRepository extends CollectionMockRepository { - getById(_id?: string): Promise { + getById(_id: string): Promise { return new Promise((_resolve, reject) => { setTimeout(() => { reject('Something went wrong') diff --git a/tests/component/sections/account/Account.spec.tsx b/tests/component/sections/account/Account.spec.tsx index dcf7d3862..3a3176ba4 100644 --- a/tests/component/sections/account/Account.spec.tsx +++ b/tests/component/sections/account/Account.spec.tsx @@ -1,27 +1,16 @@ import { Account } from '../../../../src/sections/account/Account' import { AccountHelper } from '../../../../src/sections/account/AccountHelper' -import { CollectionRepository } from '@/collection/domain/repositories/CollectionRepository' -import { CollectionMother } from '@tests/component/collection/domain/models/CollectionMother' -const collectionRepository = {} as CollectionRepository -const collection = CollectionMother.create({ name: 'Root' }) describe('Account', () => { - beforeEach(() => { - collectionRepository.getById = cy.stub().resolves(collection) - }) - it('should render the correct breadcrumbs', () => { + it('should render the component', () => { cy.mountAuthenticated( - + ) - cy.findByRole('link', { name: 'Root' }).should('exist') - - cy.get('li[aria-current="page"]') - .should('exist') - .should('have.text', 'Account') - .should('have.class', 'active') + cy.get('h1').should('contain.text', 'Account') + cy.findByRole('tab', { name: 'My Data' }).should('exist').and('be.disabled') + cy.findByRole('tab', { name: 'Account Information' }).should('exist').and('be.disabled') + cy.findByRole('tab', { name: 'Notifications' }).should('exist').and('be.disabled') + cy.findByRole('tab', { name: 'API Token' }).should('be.enabled') }) }) From adbe8838919cc918ad23933f449e126bda76c3d0 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Fri, 1 Nov 2024 09:59:41 -0400 Subject: [PATCH 13/22] return null instead of Skeleton while root collection is loading --- src/sections/layout/header/LoggedInHeaderActions.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/sections/layout/header/LoggedInHeaderActions.tsx b/src/sections/layout/header/LoggedInHeaderActions.tsx index 619241318..3aec88b67 100644 --- a/src/sections/layout/header/LoggedInHeaderActions.tsx +++ b/src/sections/layout/header/LoggedInHeaderActions.tsx @@ -8,7 +8,7 @@ import { User } from '../../../users/domain/models/User' import { CollectionRepository } from '../../../collection/domain/repositories/CollectionRepository' import { AccountHelper } from '../../account/AccountHelper' import { useCollection } from '@/sections/collection/useCollection' -import Skeleton from 'react-loading-skeleton' +import { PageNotFound } from '@/sections/page-not-found/PageNotFound' const currentPage = 0 @@ -36,11 +36,12 @@ export const LoggedInHeaderActions = ({ navigate(currentPage) }) } - if (isLoading) { - return + + if (!isLoading && !collection) { + return } - if (!collection) { + if (isLoading || !collection) { return null } From 2cd8e9284b3abaeb0f79eda4ae3979ded0c31fcb Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Fri, 1 Nov 2024 10:51:36 -0400 Subject: [PATCH 14/22] fix lint errors --- src/stories/account/Account.stories.tsx | 8 +------- src/stories/collection/CollectionErrorMockRepository.ts | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/stories/account/Account.stories.tsx b/src/stories/account/Account.stories.tsx index 65081c710..b19475721 100644 --- a/src/stories/account/Account.stories.tsx +++ b/src/stories/account/Account.stories.tsx @@ -4,7 +4,6 @@ import { WithI18next } from '../WithI18next' import { WithLayout } from '../WithLayout' import { WithLoggedInUser } from '../WithLoggedInUser' import { AccountHelper } from '../../sections/account/AccountHelper' -import { CollectionMockRepository } from '@/stories/collection/CollectionMockRepository' const meta: Meta = { title: 'Pages/Account', @@ -19,10 +18,5 @@ export default meta type Story = StoryObj export const APITokenTab: Story = { - render: () => ( - - ) + render: () => } diff --git a/src/stories/collection/CollectionErrorMockRepository.ts b/src/stories/collection/CollectionErrorMockRepository.ts index 2d5e8b4e7..b897f3853 100644 --- a/src/stories/collection/CollectionErrorMockRepository.ts +++ b/src/stories/collection/CollectionErrorMockRepository.ts @@ -7,7 +7,7 @@ import { CollectionFacet } from '../../collection/domain/models/CollectionFacet' import { CollectionMockRepository } from './CollectionMockRepository' export class CollectionErrorMockRepository extends CollectionMockRepository { - getById(_id: string): Promise { + getById(_id?: string): Promise { return new Promise((_resolve, reject) => { setTimeout(() => { reject('Something went wrong') From 02d38887c598857249a9cd3a12808085b7d1a12e Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Fri, 1 Nov 2024 11:04:53 -0400 Subject: [PATCH 15/22] fix prettier error --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c5dfe3d1c..fcfdd4684 100644 --- a/README.md +++ b/README.md @@ -223,7 +223,7 @@ The environment is accessible through the following URLs: > #### Account Page BreadCrumbs > > The Account Page has been updated to remove breadcrumbs, as the page is not part of the main navigation. -> +

    (back to top)

    From f6310336ce53fd7fd44bd0367ae21c48ec733010 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Fri, 1 Nov 2024 11:27:28 -0400 Subject: [PATCH 16/22] update package.json with merged js-dataverse version --- 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 c485f7295..54339ba7e 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": "npm:@IQSS/dataverse-client-javascript@^2.0.0-pr207.d14dc1c", + "@iqss/dataverse-client-javascript": "npm:@IQSS/dataverse-client-javascript@^2.0.0-alpha.4", "@iqss/dataverse-design-system": "*", "@istanbuljs/nyc-config-typescript": "1.0.2", "@tanstack/react-table": "8.9.2", @@ -3674,9 +3674,9 @@ }, "node_modules/@iqss/dataverse-client-javascript": { "name": "@IQSS/dataverse-client-javascript", - "version": "2.0.0-pr207.d14dc1c", - "resolved": "https://npm.pkg.github.com/download/@IQSS/dataverse-client-javascript/2.0.0-pr207.d14dc1c/e1aad714bbd5a7e15904e1da1188823b4f41bcac", - "integrity": "sha512-1dXVQ5xdPeQUkePlZH2G5uHi7Jas3zaexM0Tx3UYzDTFihuBLoEfMqMYSRZIDlfRMP4omxsr8yKoccrEEqo0qQ==", + "version": "2.0.0-alpha.4", + "resolved": "https://npm.pkg.github.com/download/@IQSS/dataverse-client-javascript/2.0.0-alpha.4/10ab7e0ed2a31a09b1b32d27521b96f84ef50f4f", + "integrity": "sha512-SJdkBIks+yjJxEVw8G7sf4YY2Bujl+8vOD+fZqt2qhIGmyPSlj9ld0APnYyoVX6lI8lGsREHZzYYjzeAmYfxhw==", "dependencies": { "@types/node": "^18.15.11", "@types/turndown": "^5.0.1", diff --git a/package.json b/package.json index f2f231e11..9e4e19a6c 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "7.6.0", - "@iqss/dataverse-client-javascript": "npm:@IQSS/dataverse-client-javascript@^2.0.0-pr207.d14dc1c", + "@iqss/dataverse-client-javascript": "npm:@IQSS/dataverse-client-javascript@^2.0.0-alpha.4", "@iqss/dataverse-design-system": "*", "@istanbuljs/nyc-config-typescript": "1.0.2", "@tanstack/react-table": "8.9.2", From f89de2ff5b5cea92e55dd18238106e9a0845e21d Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Fri, 1 Nov 2024 16:26:09 -0400 Subject: [PATCH 17/22] fix: js-dataverse dependency --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9e4e19a6c..db411a652 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "7.6.0", - "@iqss/dataverse-client-javascript": "npm:@IQSS/dataverse-client-javascript@^2.0.0-alpha.4", + "@iqss/dataverse-client-javascript": "2.0.0-alpha.4", "@iqss/dataverse-design-system": "*", "@istanbuljs/nyc-config-typescript": "1.0.2", "@tanstack/react-table": "8.9.2", From 05e42f06bc3da0262535dd133fc95ec211b535d5 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Sat, 2 Nov 2024 07:00:27 -0400 Subject: [PATCH 18/22] make collectionId optional in COLLECTIONS Route.enum.ts --- src/sections/Route.enum.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sections/Route.enum.ts b/src/sections/Route.enum.ts index 2062d1b80..93a88ee49 100644 --- a/src/sections/Route.enum.ts +++ b/src/sections/Route.enum.ts @@ -15,7 +15,8 @@ export enum Route { } export const RouteWithParams = { - COLLECTIONS: (collectionId: string) => `/collections/${collectionId}`, + COLLECTIONS: (collectionId?: string) => + collectionId ? `/collections/${collectionId}` : Route.COLLECTIONS_BASE, CREATE_COLLECTION: (ownerCollectionId: string) => `/collections/${ownerCollectionId}/create`, CREATE_DATASET: (collectionId: string) => `/datasets/${collectionId}/create` } From f91eb9f0551c2b7e4c7b476379d9b1fe9bb8fac5 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Sat, 2 Nov 2024 07:08:23 -0400 Subject: [PATCH 19/22] improve padding for Account Header --- src/sections/account/Account.module.scss | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sections/account/Account.module.scss b/src/sections/account/Account.module.scss index 6ce690ed5..ff579901d 100644 --- a/src/sections/account/Account.module.scss +++ b/src/sections/account/Account.module.scss @@ -1,8 +1,7 @@ @import 'node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module'; .header { - margin-bottom: 20px; - padding: 20px 0; + padding-block: 1rem; } .tab-container { From f035c26400f104ea84c2136d3199239c3202b38e Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Sat, 2 Nov 2024 07:11:55 -0400 Subject: [PATCH 20/22] fix: use casting to rather than if condition in CollectionFactory.tsx --- src/sections/create-collection/CreateCollectionFactory.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/sections/create-collection/CreateCollectionFactory.tsx b/src/sections/create-collection/CreateCollectionFactory.tsx index bce567238..af55ee266 100644 --- a/src/sections/create-collection/CreateCollectionFactory.tsx +++ b/src/sections/create-collection/CreateCollectionFactory.tsx @@ -14,9 +14,8 @@ export class CreateCollectionFactory { } function CreateCollectionWithParams() { - const { ownerCollectionId } = useParams<{ ownerCollectionId: string }>() - if (!ownerCollectionId) { - throw new Error('ownerCollectionId is required') + const { ownerCollectionId } = useParams<{ ownerCollectionId: string }>() as { + ownerCollectionId: string } return ( Date: Sat, 2 Nov 2024 07:26:14 -0400 Subject: [PATCH 21/22] fix: return null if collection is undefined in LoggedInHeaderActions.tsx --- src/sections/layout/header/LoggedInHeaderActions.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/sections/layout/header/LoggedInHeaderActions.tsx b/src/sections/layout/header/LoggedInHeaderActions.tsx index 3aec88b67..6bcc3e695 100644 --- a/src/sections/layout/header/LoggedInHeaderActions.tsx +++ b/src/sections/layout/header/LoggedInHeaderActions.tsx @@ -8,7 +8,6 @@ import { User } from '../../../users/domain/models/User' import { CollectionRepository } from '../../../collection/domain/repositories/CollectionRepository' import { AccountHelper } from '../../account/AccountHelper' import { useCollection } from '@/sections/collection/useCollection' -import { PageNotFound } from '@/sections/page-not-found/PageNotFound' const currentPage = 0 @@ -24,7 +23,7 @@ export const LoggedInHeaderActions = ({ const { t } = useTranslation('header') const { logout } = useSession() const navigate = useNavigate() - const { collection, isLoading } = useCollection(collectionRepository) + const { collection } = useCollection(collectionRepository) const { collectionUserPermissions } = useGetCollectionUserPermissions({ collectionIdOrAlias: undefined, @@ -37,11 +36,7 @@ export const LoggedInHeaderActions = ({ }) } - if (!isLoading && !collection) { - return - } - - if (isLoading || !collection) { + if (!collection) { return null } From c15d083f98cf179ccd39e5f9aa6f9fca9f0c3222 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Sun, 3 Nov 2024 20:46:15 -0500 Subject: [PATCH 22/22] fix: cast collectionId from useParams to string --- src/sections/create-dataset/CreateDatasetFactory.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/sections/create-dataset/CreateDatasetFactory.tsx b/src/sections/create-dataset/CreateDatasetFactory.tsx index a1fec5ae1..d20823149 100644 --- a/src/sections/create-dataset/CreateDatasetFactory.tsx +++ b/src/sections/create-dataset/CreateDatasetFactory.tsx @@ -21,10 +21,8 @@ export class CreateDatasetFactory { } function CreateDatasetWithSearchParams() { - const { collectionId } = useParams<{ collectionId: string }>() - if (!collectionId) { - throw new Error('collectionId is required') - } + const { collectionId } = useParams<{ collectionId: string }>() as { collectionId: string } + return (