Skip to content

Commit

Permalink
Merge branch 'IQSS:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jayanthkomarraju authored May 30, 2024
2 parents 3993ea1 + 2ec048c commit 573f987
Show file tree
Hide file tree
Showing 15 changed files with 113 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/accessibility.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: accessibility

on: push
on: [push, pull_request]

jobs:
interaction-and-accessibility:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/chromatic-design-system.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'Chromatic Design System '

# Event for the workflow
on: push
on: [push, pull_request]

# List of jobs
jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'Chromatic'

# Event for the workflow
on: push
on: [push, pull_request]

# List of jobs
jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: lint

on: push
on: [push, pull_request]

jobs:
lint:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: test

on: push
on: [push, pull_request]

env:
E2E_DATAVERSE_IMAGE_TAG: unstable
Expand Down
3 changes: 3 additions & 0 deletions public/locales/en/uploadDatasetFiles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"breadcrumbActionItem": "Upload Files"
}
31 changes: 31 additions & 0 deletions src/assets/dataverse_brand_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions src/assets/logo.svg

This file was deleted.

10 changes: 8 additions & 2 deletions src/dataset/infrastructure/mappers/JSDatasetMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ export class JSDatasetMapper {
jsDatasetFilesTotalOriginalDownloadSize,
jsDatasetFilesTotalArchivalDownloadSize
),
JSDatasetMapper.toHierarchy(jsDataset.persistentId, version, jsDataset.isPartOf),
JSDatasetMapper.toHierarchy(
jsDataset.id,
jsDataset.persistentId,
version,
jsDataset.isPartOf
),
undefined, // TODO: get dataset thumbnail from js-dataverse https://github.com/IQSS/dataverse-frontend/issues/203
privateUrl,
requestedVersion
Expand Down Expand Up @@ -232,15 +237,16 @@ export class JSDatasetMapper {
}

static toHierarchy(
id: number,
persistentId: string,
version: DatasetVersion,
jsUpwardHierarchyNode: JSUpwardHierarchyNode
): UpwardHierarchyNode {
return new UpwardHierarchyNode(
version.title,
DvObjectType.DATASET,
id.toString(),
persistentId,
undefined,
version.number.toString(),
JSUpwardHierarchyNodeMapper.toUpwardHierarchyNode(jsUpwardHierarchyNode)
)
Expand Down
4 changes: 2 additions & 2 deletions src/sections/layout/header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import logo from '../../../assets/logo.svg'
import dataverse_logo from '../../../assets/dataverse_brand_icon.svg'
import { useTranslation } from 'react-i18next'
import { Navbar } from '@iqss/dataverse-design-system'
import { Route } from '../../Route.enum'
Expand All @@ -25,7 +25,7 @@ export function Header() {
brand={{
title: t('brandTitle'),
href: `/spa${Route.HOME}`,
logoImgSrc: logo
logoImgSrc: dataverse_logo
}}>
{user ? (
<>
Expand Down
24 changes: 19 additions & 5 deletions src/sections/shared/hierarchy/BreadcrumbsGenerator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,29 @@ import { UpwardHierarchyNode } from '../../../shared/hierarchy/domain/models/Upw
import { LinkToPage } from '../link-to-page/LinkToPage'
import { Route } from '../../Route.enum'

interface BreadcrumbGeneratorProps {
hierarchy: UpwardHierarchyNode
}
type BreadcrumbGeneratorProps =
| {
hierarchy: UpwardHierarchyNode
withActionItem?: false
actionItemText?: never
}
| {
hierarchy: UpwardHierarchyNode
withActionItem: true
actionItemText: string
}

export function BreadcrumbsGenerator({ hierarchy }: BreadcrumbGeneratorProps) {
export function BreadcrumbsGenerator({
hierarchy,
withActionItem,
actionItemText
}: BreadcrumbGeneratorProps) {
const hierarchyArray = hierarchy.toArray()

return (
<Breadcrumb>
{hierarchyArray.map((item, index) => {
const isLast = index === hierarchyArray.length - 1
const isLast = withActionItem ? false : index === hierarchyArray.length - 1
const isFirst = index === 0

if (isLast) {
Expand Down Expand Up @@ -49,6 +62,7 @@ export function BreadcrumbsGenerator({ hierarchy }: BreadcrumbGeneratorProps) {
</Breadcrumb.Item>
)
})}
{withActionItem && <Breadcrumb.Item active>{actionItemText}</Breadcrumb.Item>}
</Breadcrumb>
)
}
Expand Down
8 changes: 7 additions & 1 deletion src/sections/upload-dataset-files/UploadDatasetFiles.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useEffect } from 'react'
import { useTranslation } from 'react-i18next'
import { FileRepository } from '../../files/domain/repositories/FileRepository'
import { useLoading } from '../loading/LoadingContext'
import { useDataset } from '../dataset/DatasetContext'
Expand All @@ -14,6 +15,7 @@ export const UploadDatasetFiles = ({
}: UploadDatasetFilesProps) => {
const { setIsLoading } = useLoading()
const { dataset, isLoading } = useDataset()
const { t } = useTranslation('uploadDatasetFiles')

useEffect(() => {
setIsLoading(isLoading)
Expand All @@ -29,7 +31,11 @@ export const UploadDatasetFiles = ({
<PageNotFound />
) : (
<>
<BreadcrumbsGenerator hierarchy={dataset.hierarchy} />
<BreadcrumbsGenerator
hierarchy={dataset.hierarchy}
withActionItem
actionItemText={t('breadcrumbActionItem')}
/>
<article>
<p>Metadata Files uploading goes here</p>
</article>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ const expectedDataset = {
hierarchy: new UpwardHierarchyNode(
"Darwin's Finches",
DvObjectType.DATASET,
'505',
'doi:10.5072/FK2/B4B2MJ',
undefined,
'0.0',
new UpwardHierarchyNode('Root', DvObjectType.COLLECTION, 'root')
)
Expand Down Expand Up @@ -285,8 +285,8 @@ const expectedDatasetAlternateVersion = {
hierarchy: new UpwardHierarchyNode(
"Darwin's Finches",
DvObjectType.DATASET,
'505',
'doi:10.5072/FK2/B4B2MJ',
undefined,
'0.0',
new UpwardHierarchyNode('Root', DvObjectType.COLLECTION, 'root')
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,23 @@ describe('BreadcrumbsGenerator', () => {
cy.customMount(<BreadcrumbsGenerator hierarchy={root} />)
cy.findByText('Root').should('have.class', 'active')
})

it('shows the action item active when withActionItem is true', () => {
const root = UpwardHierarchyNodeMother.createCollection({
name: 'Root',
id: 'root'
})
const dataset = UpwardHierarchyNodeMother.createDataset({
name: 'Dataset',
parent: root,
version: '1.0',
persistentId: 'doi:10.5072/FK2/ABC123'
})

cy.customMount(
<BreadcrumbsGenerator hierarchy={dataset} withActionItem actionItemText="Action Item Text" />
)
cy.findByText('Action Item Text').should('exist').should('have.class', 'active')
cy.findByText('Dataset').should('exist').should('not.have.class', 'active')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,35 @@ import { Dataset as DatasetModel } from '../../../../src/dataset/domain/models/D
import { ReactNode } from 'react'
import { DatasetProvider } from '../../../../src/sections/dataset/DatasetProvider'
import { UploadDatasetFiles } from '../../../../src/sections/upload-dataset-files/UploadDatasetFiles'
import { LoadingProvider } from '../../../../src/sections/loading/LoadingProvider'

const fileRepository: FileRepository = {} as FileRepository
const datasetRepository: DatasetRepository = {} as DatasetRepository

describe('Dataset', () => {
describe('UploadDatasetFiles', () => {
const mountWithDataset = (component: ReactNode, dataset: DatasetModel | undefined) => {
const searchParams = { persistentId: 'some-persistent-id' }
datasetRepository.getByPersistentId = cy.stub().resolves(dataset)

cy.customMount(
<DatasetProvider repository={datasetRepository} searchParams={searchParams}>
{component}
</DatasetProvider>
<LoadingProvider>
<DatasetProvider repository={datasetRepository} searchParams={searchParams}>
{component}
</DatasetProvider>
</LoadingProvider>
)
}

it('renders the breadcrumbs', () => {
const testDataset = DatasetMother.create()

mountWithDataset(<UploadDatasetFiles fileRepository={fileRepository} />, testDataset)

cy.findByRole('link', { name: 'Root' }).should('exist')
cy.findByRole('link', { name: 'Dataset Title' }).should('exist')
cy.findByText('Upload Files').should('exist').should('have.class', 'active')
})

it('renders skeleton while loading', () => {
const testDataset = DatasetMother.create()

Expand All @@ -37,13 +50,4 @@ describe('Dataset', () => {

cy.findByText('Page Not Found').should('exist')
})

it('renders the breadcrumbs', () => {
const testDataset = DatasetMother.create()

mountWithDataset(<UploadDatasetFiles fileRepository={fileRepository} />, testDataset)

cy.findByText('Dataset Title').should('exist').should('have.class', 'active')
cy.findByRole('link', { name: 'Root' }).should('exist')
})
})

0 comments on commit 573f987

Please sign in to comment.