-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch develop into feature/355-select-multiple-component
- Loading branch information
Showing
11 changed files
with
202 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline | |
- **FormLabel:** extend Props Interface to accept `htmlFor` prop. | ||
- **SelectMultiple:** NEW multiple selector for occasions when you can choose more than one option. | ||
- **FormSelectMultiple:** The new multiple selector is added to the "FormGroup" components. | ||
- **DropdownButtonItem:** extend Props Interface to accept `as` prop. | ||
|
||
# [1.1.0](https://github.com/IQSS/dataverse-frontend/compare/@iqss/[email protected]...@iqss/[email protected]) (2024-03-12) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 40 additions & 9 deletions
49
src/sections/dataset/dataset-action-buttons/edit-dataset-menu/EditDatasetMenu.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 11 additions & 9 deletions
20
src/sections/dataset/dataset-files/dataset-upload-files-button/DatasetUploadFilesButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { useEffect } from 'react' | ||
import { FileRepository } from '../../files/domain/repositories/FileRepository' | ||
import { useLoading } from '../loading/LoadingContext' | ||
import { useDataset } from '../dataset/DatasetContext' | ||
import { PageNotFound } from '../page-not-found/PageNotFound' | ||
import { BreadcrumbsGenerator } from '../shared/hierarchy/BreadcrumbsGenerator' | ||
|
||
interface UploadDatasetFilesProps { | ||
fileRepository: FileRepository | ||
} | ||
|
||
export const UploadDatasetFiles = ({ | ||
fileRepository: _fileRepository | ||
}: UploadDatasetFilesProps) => { | ||
const { setIsLoading } = useLoading() | ||
const { dataset, isLoading } = useDataset() | ||
|
||
useEffect(() => { | ||
setIsLoading(isLoading) | ||
}, [isLoading]) | ||
|
||
if (isLoading) { | ||
return <p>Temporary Loading until having shape of skeleton</p> | ||
} | ||
|
||
return ( | ||
<> | ||
{!dataset ? ( | ||
<PageNotFound /> | ||
) : ( | ||
<> | ||
<BreadcrumbsGenerator hierarchy={dataset.hierarchy} /> | ||
<article> | ||
<p>Metadata Files uploading goes here</p> | ||
</article> | ||
</> | ||
)} | ||
</> | ||
) | ||
} |
26 changes: 26 additions & 0 deletions
26
src/sections/upload-dataset-files/UploadDatasetFilesFactory.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ReactElement } from 'react' | ||
import { useSearchParams } from 'react-router-dom' | ||
import { DatasetJSDataverseRepository } from '../../dataset/infrastructure/repositories/DatasetJSDataverseRepository' | ||
import { FileJSDataverseRepository } from '../../files/infrastructure/FileJSDataverseRepository' | ||
import { DatasetProvider } from '../dataset/DatasetProvider' | ||
import { UploadDatasetFiles } from './UploadDatasetFiles' | ||
|
||
const datasetRepository = new DatasetJSDataverseRepository() | ||
const fileRepository = new FileJSDataverseRepository() | ||
|
||
export class UploadDatasetFilesFactory { | ||
static create(): ReactElement { | ||
return <UploadDatasetFilesWithSearchParams /> | ||
} | ||
} | ||
|
||
function UploadDatasetFilesWithSearchParams() { | ||
const [searchParams] = useSearchParams() | ||
const persistentId = searchParams.get('persistentId') ?? undefined | ||
|
||
return ( | ||
<DatasetProvider repository={datasetRepository} searchParams={{ persistentId: persistentId }}> | ||
<UploadDatasetFiles fileRepository={fileRepository} /> | ||
</DatasetProvider> | ||
) | ||
} |
24 changes: 24 additions & 0 deletions
24
src/stories/upload-dataset-files/UploadDatasetFiles.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { WithI18next } from '../WithI18next' | ||
import { WithLayout } from '../WithLayout' | ||
import { UploadDatasetFiles } from '../../sections/upload-dataset-files/UploadDatasetFiles' | ||
import { FileMockRepository } from '../file/FileMockRepository' | ||
import { WithDataset } from '../dataset/WithDataset' | ||
|
||
const meta: Meta<typeof UploadDatasetFiles> = { | ||
title: 'Pages/Upload Dataset Files', | ||
component: UploadDatasetFiles, | ||
decorators: [WithI18next], | ||
parameters: { | ||
// Sets the delay for all stories. | ||
chromatic: { delay: 15000, pauseAnimationAtEnd: true } | ||
} | ||
} | ||
|
||
export default meta | ||
type Story = StoryObj<typeof UploadDatasetFiles> | ||
|
||
export const Default: Story = { | ||
decorators: [WithLayout, WithDataset], | ||
render: () => <UploadDatasetFiles fileRepository={new FileMockRepository()} /> | ||
} |
49 changes: 49 additions & 0 deletions
49
tests/component/sections/upload-dataset-files/UploadDatasetFiles.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { DatasetRepository } from '../../../../src/dataset/domain/repositories/DatasetRepository' | ||
import { DatasetMother } from '../../dataset/domain/models/DatasetMother' | ||
import { FileRepository } from '../../../../src/files/domain/repositories/FileRepository' | ||
import { Dataset as DatasetModel } from '../../../../src/dataset/domain/models/Dataset' | ||
import { ReactNode } from 'react' | ||
import { DatasetProvider } from '../../../../src/sections/dataset/DatasetProvider' | ||
import { UploadDatasetFiles } from '../../../../src/sections/upload-dataset-files/UploadDatasetFiles' | ||
|
||
const fileRepository: FileRepository = {} as FileRepository | ||
const datasetRepository: DatasetRepository = {} as DatasetRepository | ||
|
||
describe('Dataset', () => { | ||
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> | ||
) | ||
} | ||
|
||
it('renders skeleton while loading', () => { | ||
const testDataset = DatasetMother.create() | ||
|
||
mountWithDataset(<UploadDatasetFiles fileRepository={fileRepository} />, testDataset) | ||
|
||
cy.findByText('Temporary Loading until having shape of skeleton').should('exist') | ||
cy.findByText(testDataset.version.title).should('not.exist') | ||
}) | ||
|
||
it('renders page not found when dataset is null', () => { | ||
const emptyDataset = DatasetMother.createEmpty() | ||
|
||
mountWithDataset(<UploadDatasetFiles fileRepository={fileRepository} />, emptyDataset) | ||
|
||
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') | ||
}) | ||
}) |