Skip to content

Commit

Permalink
feat(FileMetadata): add persistentId
Browse files Browse the repository at this point in the history
  • Loading branch information
MellyGray committed Jan 15, 2024
1 parent 7c6d583 commit 3c680c8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/files/domain/models/File.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ export interface File {
restricted: boolean
permissions: FilePermissions
labels: FileLabel[]
persistentId?: string
thumbnail?: string
}
3 changes: 3 additions & 0 deletions src/sections/file/file-metadata/FileMetadata.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.row {
margin: 12px 0;
}
13 changes: 11 additions & 2 deletions src/sections/file/file-metadata/FileMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Accordion, Col, Row } from '@iqss/dataverse-design-system'
import { File } from '../../../files/domain/models/File'
import { FilePreview } from '../file-preview/FilePreview'
import { FileLabels } from '../../dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/FileLabels'
import styles from './FileMetadata.module.scss'

interface FileMetadataProps {
file: File
Expand All @@ -13,7 +14,7 @@ export function FileMetadata({ file }: FileMetadataProps) {
<Accordion.Item eventKey="0">
<Accordion.Header>File Metadata</Accordion.Header>
<Accordion.Body>
<Row>
<Row className={styles.row}>
<Col sm={3}>
<strong>Preview</strong>
</Col>
Expand All @@ -22,7 +23,7 @@ export function FileMetadata({ file }: FileMetadataProps) {
</Col>
</Row>
{file.labels.length > 0 && (
<Row>
<Row className={styles.row}>
<Col sm={3}>
<strong>File Tags</strong>
</Col>
Expand All @@ -31,6 +32,14 @@ export function FileMetadata({ file }: FileMetadataProps) {
</Col>
</Row>
)}
{file.persistentId && (
<Row className={styles.row}>
<Col sm={3}>
<strong>File Persistent ID</strong>
</Col>
<Col>{file.persistentId}</Col>
</Row>
)}
</Accordion.Body>
</Accordion.Item>
</Accordion>
Expand Down
2 changes: 2 additions & 0 deletions tests/component/files/domain/models/FileMother.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class FileMother {
},
labels: faker.datatype.boolean() ? FileLabelMother.createMany(3) : [],
thumbnail: faker.datatype.boolean() ? faker.image.imageUrl() : undefined,
persistentId: faker.datatype.boolean() ? faker.datatype.uuid() : undefined,
...props
}
}
Expand All @@ -29,6 +30,7 @@ export class FileMother {
permissions: {
canDownloadFile: true
},
persistentId: 'doi:10.5072/FK2/ABC123',
...props
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,13 @@ describe('FileMetadata', () => {

cy.findByText('File Tags').should('not.exist')
})

it('renders the file persistent id', () => {
cy.customMount(
<FileMetadata file={FileMother.create({ persistentId: 'doi:10.5072/FK2/ABC123' })} />
)

cy.findByText('File Persistent ID').should('exist')
cy.findByText('doi:10.5072/FK2/ABC123').should('exist')
})
})

0 comments on commit 3c680c8

Please sign in to comment.