Skip to content

Commit

Permalink
fix: remove Breadcrumbs from Account.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
ekraffmiller committed Nov 1, 2024
1 parent 632dbbd commit 44b2569
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 59 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
>
</details>
<p align="right">(<a href="#readme-top">back to top</a>)</p>
Expand Down
5 changes: 5 additions & 0 deletions src/sections/account/Account.module.scss
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down
32 changes: 2 additions & 30 deletions src/sections/account/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <BreadcrumbsSkeleton />
}
const rootHierarchy = new UpwardHierarchyNode(
collection.name,
DvObjectType.COLLECTION,
collection.id
)
return (
<section>
<BreadcrumbsGenerator hierarchy={rootHierarchy} withActionItem actionItemText="Account" />

<header>
<header className={styles['header']}>
<h1>{t('pageTitle')}</h1>
</header>

Expand Down
10 changes: 1 addition & 9 deletions src/sections/account/AccountFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -16,10 +13,5 @@ function AccountWithSearchParams() {
const [searchParams] = useSearchParams()
const defaultActiveTabKey = AccountHelper.defineSelectedTabKey(searchParams)

return (
<Account
collectionRepository={collectionRepository}
defaultActiveTabKey={defaultActiveTabKey}
/>
)
return <Account defaultActiveTabKey={defaultActiveTabKey} />
}
2 changes: 1 addition & 1 deletion src/stories/collection/CollectionErrorMockRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CollectionFacet } from '../../collection/domain/models/CollectionFacet'
import { CollectionMockRepository } from './CollectionMockRepository'

export class CollectionErrorMockRepository extends CollectionMockRepository {
getById(_id?: string): Promise<Collection> {
getById(_id: string): Promise<Collection> {
return new Promise((_resolve, reject) => {
setTimeout(() => {
reject('Something went wrong')
Expand Down
25 changes: 7 additions & 18 deletions tests/component/sections/account/Account.spec.tsx
Original file line number Diff line number Diff line change
@@ -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(
<Account
collectionRepository={collectionRepository}
defaultActiveTabKey={AccountHelper.ACCOUNT_PANEL_TABS_KEYS.apiToken}
/>
<Account defaultActiveTabKey={AccountHelper.ACCOUNT_PANEL_TABS_KEYS.apiToken} />
)

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')
})
})

0 comments on commit 44b2569

Please sign in to comment.