Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection page show lock/unlock icon for restricted files in the card #576

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"dependencies": {
"@faker-js/faker": "7.6.0",
"@iqss/dataverse-client-javascript": "2.0.0-alpha.11",
"@iqss/dataverse-client-javascript": "2.0.0-alpha.13",
"@iqss/dataverse-design-system": "*",
"@istanbuljs/nyc-config-typescript": "1.0.2",
"@tanstack/react-table": "8.9.2",
Expand Down
2 changes: 2 additions & 0 deletions src/files/domain/models/FileItemTypePreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export interface FileItemTypePreview {
datasetCitation: string
publicationStatuses: PublicationStatus[]
releaseOrCreateDate: Date
restricted: boolean
canDownloadFile: boolean
}

export interface FilePreviewChecksum {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export class JSFileItemTypePreviewMapper {
datasetPersistentId: jsFilePreview.datasetPersistentId,
datasetCitation: jsFilePreview.datasetCitation,
publicationStatuses: jsFilePreview.publicationStatuses,
releaseOrCreateDate: jsFilePreview.releaseOrCreateDate
releaseOrCreateDate: jsFilePreview.releaseOrCreateDate,
restricted: jsFilePreview.restricted,
canDownloadFile: jsFilePreview.canDownloadFile
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,7 @@
color: black;
}
}

.restricted-icon {
margin: -5px -5px 0 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Route } from '@/sections/Route.enum'
import { LinkToPage } from '@/sections/shared/link-to-page/LinkToPage'
import { DatasetLabels } from '@/sections/dataset/dataset-labels/DatasetLabels'
import { FileCardHelper } from './FileCardHelper'
import { FileAccessRestrictedIcon } from '../../../../file/file-access/FileAccessRestrictedIcon'
import styles from './FileCard.module.scss'

interface FileCardHeaderProps {
Expand All @@ -21,6 +22,12 @@ export function FileCardHeader({ filePreview }: FileCardHeaderProps) {
return (
<header className={styles['card-header-container']}>
<div className={styles['left-side-content']}>
<div className={styles['restricted-icon']} data-testid="file-access-restricted-icon">
<FileAccessRestrictedIcon
restricted={filePreview.restricted}
canDownloadFile={filePreview.canDownloadFile}
/>
</div>
<LinkToPage
page={Route.FILES}
type={DvObjectType.FILE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export class FileItemTypePreviewMother {
datasetCitation: faker.lorem.paragraph(),
publicationStatuses: [PublicationStatus.Published],
releaseOrCreateDate: faker.date.past(),
restricted: faker.datatype.boolean(),
canDownloadFile: faker.datatype.boolean(),
...props
}
}
Expand Down Expand Up @@ -60,6 +62,8 @@ export class FileItemTypePreviewMother {
datasetCitation: 'test citation',
publicationStatuses: [PublicationStatus.Published],
releaseOrCreateDate: new Date('2023-05-15T08:21:01Z'),
restricted: false,
canDownloadFile: true,
...props
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ describe('FileCard', () => {
const filePreview = FileItemTypePreviewMother.create()
cy.customMount(<FileCard filePreview={filePreview} />)

filePreview.restricted
? cy.findByTestId('file-access-restricted-icon').should('exist')
: cy.findByTestId('file-access-restricted-icon').should('not.exist')
cy.contains(DateHelper.toDisplayFormat(filePreview.releaseOrCreateDate)).should('exist')
cy.contains(filePreview.fileType).should('exist')
filePreview.checksum?.type && cy.contains(filePreview.checksum?.type).should('exist')
Expand Down
Loading