Skip to content

Commit

Permalink
feat(FilesTable)
Browse files Browse the repository at this point in the history
  • Loading branch information
MellyGray committed Jul 11, 2023
1 parent 19e5f2d commit e149420
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/sections/dataset/dataset-files/DatasetFiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function DatasetFiles({
datasetVersion
}: DatasetFilesProps) {
const [criteria, setCriteria] = useState<FileCriteria>()
const MINIMUM_FILES_TO_SHOW_CRITERIA_INPUTS = 2
const { files, isLoading } = useFiles(
filesRepository,
datasetPersistentId,
Expand All @@ -40,7 +41,9 @@ export function DatasetFiles({

return (
<>
{files.length !== 0 && <FileCriteriaInputs onCriteriaChange={handleCriteriaChange} />}
{files.length >= MINIMUM_FILES_TO_SHOW_CRITERIA_INPUTS && (
<FileCriteriaInputs onCriteriaChange={handleCriteriaChange} />
)}
<FilesTable table={table} />
</>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Meta, StoryObj } from '@storybook/react'
import { FileCriteriaInputs } from '../../../../sections/dataset/dataset-files/file-criteria-inputs/FileCriteriaInputs'
import { WithI18next } from '../../../WithI18next'

const meta: Meta<typeof FileCriteriaInputs> = {
title: 'Sections/Dataset Page/DatasetFiles/FilesTable/FileCriteriaInputs',
component: FileCriteriaInputs,
decorators: [WithI18next]
}

export default meta
type Story = StoryObj<typeof FileCriteriaInputs>

export const Default: Story = {
render: () => <FileCriteriaInputs onCriteriaChange={() => {}} />
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ describe('DatasetFiles', () => {
)
})

it('does not render the files criteria inputs when there are no files', () => {
fileRepository.getAllByDatasetPersistentId = cy.stub().resolves([])
it('does not render the files criteria inputs when there are less than 2 files', () => {
fileRepository.getAllByDatasetPersistentId = cy.stub().resolves(FileMother.createMany(1))

cy.customMount(
<DatasetFiles
Expand Down

0 comments on commit e149420

Please sign in to comment.