-
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.
feat(DatasetFiles): complete FileInfoCell with all the file info
- Loading branch information
Showing
31 changed files
with
605 additions
and
47 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
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,8 @@ | ||
{ | ||
"metadataReleased": "Metadata Released", | ||
"published": "Published", | ||
"deposited": "Deposited", | ||
"embargoedWillBeUntil": "Draft: will be embargoed until", | ||
"embargoedUntil" : "Embargoed until", | ||
"embargoedWasThrough": "Was embargoed until" | ||
} |
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
15 changes: 15 additions & 0 deletions
15
src/sections/dataset/dataset-files/files-table/file-info-cell/FileChecksum.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,15 @@ | ||
import styles from './FileInfoCell.module.scss' | ||
import { CopyToClipboardButton } from './copy-to-clipboard-button/CopyToClipboardButton' | ||
|
||
export function FileChecksum({ checksum }: { checksum: string | undefined }) { | ||
if (!checksum) { | ||
return <></> | ||
} | ||
|
||
return ( | ||
<div className={styles['checksum-container']}> | ||
{checksum} | ||
<CopyToClipboardButton text={checksum} /> | ||
</div> | ||
) | ||
} |
13 changes: 13 additions & 0 deletions
13
src/sections/dataset/dataset-files/files-table/file-info-cell/FileDate.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,13 @@ | ||
import { FileDate as FileDateModel } from '../../../../../files/domain/models/File' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
export function FileDate({ date }: { date: FileDateModel }) { | ||
const { t } = useTranslation('files') | ||
return ( | ||
<div> | ||
<span> | ||
{t(date.type)} {date.date} | ||
</span> | ||
</div> | ||
) | ||
} |
8 changes: 8 additions & 0 deletions
8
src/sections/dataset/dataset-files/files-table/file-info-cell/FileDescription.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,8 @@ | ||
import styles from './FileInfoCell.module.scss' | ||
|
||
export function FileDescription({ description }: { description: string | undefined }) { | ||
if (!description) { | ||
return <></> | ||
} | ||
return <div className={styles['description-container']}>{description}</div> | ||
} |
10 changes: 10 additions & 0 deletions
10
src/sections/dataset/dataset-files/files-table/file-info-cell/FileDirectory.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,10 @@ | ||
export function FileDirectory({ directory }: { directory: string | undefined }) { | ||
if (!directory) { | ||
return <></> | ||
} | ||
return ( | ||
<div className="directory-container"> | ||
<span>{directory}</span> | ||
</div> | ||
) | ||
} |
17 changes: 17 additions & 0 deletions
17
src/sections/dataset/dataset-files/files-table/file-info-cell/FileDownloads.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,17 @@ | ||
import { FileStatus } from '../../../../../files/domain/models/File' | ||
|
||
interface FileDownloadsProps { | ||
downloads: number | ||
status: FileStatus | ||
} | ||
export function FileDownloads({ downloads, status }: FileDownloadsProps) { | ||
if (status !== FileStatus.RELEASED) { | ||
return <></> | ||
} | ||
|
||
return ( | ||
<div> | ||
<span>{downloads} Downloads</span> | ||
</div> | ||
) | ||
} |
31 changes: 31 additions & 0 deletions
31
src/sections/dataset/dataset-files/files-table/file-info-cell/FileEmbargoDate.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,31 @@ | ||
import { FileEmbargo, FileStatus } from '../../../../../files/domain/models/File' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
interface FileEmbargoDateProps { | ||
embargo: FileEmbargo | undefined | ||
status: FileStatus | ||
} | ||
|
||
export function FileEmbargoDate({ embargo, status }: FileEmbargoDateProps) { | ||
const { t } = useTranslation('files') | ||
|
||
if (!embargo) { | ||
return <></> | ||
} | ||
|
||
return ( | ||
<div> | ||
<span> | ||
{t(embargoTypeOfDate(embargo.active, status))} {embargo.date} | ||
</span> | ||
</div> | ||
) | ||
} | ||
|
||
const embargoTypeOfDate = (embargoIsActive: boolean, status: FileStatus) => { | ||
if (status === FileStatus.RELEASED) { | ||
return embargoIsActive ? 'embargoedUntil' : 'embargoedWasThrough' | ||
} | ||
|
||
return 'embargoedWillBeUntil' | ||
} |
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
20 changes: 20 additions & 0 deletions
20
src/sections/dataset/dataset-files/files-table/file-info-cell/FileLabels.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,20 @@ | ||
import { FileLabel, FileLabelType } from '../../../../../files/domain/models/File' | ||
import { Badge } from 'dataverse-design-system' | ||
import styles from './FileInfoCell.module.scss' | ||
|
||
const VARIANT_BY_LABEL_TYPE: Record<FileLabelType, 'secondary' | 'info'> = { | ||
[FileLabelType.CATEGORY]: 'secondary', | ||
[FileLabelType.TAG]: 'info' | ||
} | ||
|
||
export function FileLabels({ labels }: { labels: FileLabel[] }) { | ||
return ( | ||
<div className={styles['labels-container']}> | ||
{labels.map((label, index) => ( | ||
<Badge key={`${label.value}-${index}`} variant={VARIANT_BY_LABEL_TYPE[label.type]}> | ||
{label.value} | ||
</Badge> | ||
))} | ||
</div> | ||
) | ||
} |
18 changes: 18 additions & 0 deletions
18
src/sections/dataset/dataset-files/files-table/file-info-cell/FileTabularData.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,18 @@ | ||
import { FileTabularData as FileTabularDataModel } from '../../../../../files/domain/models/File' | ||
import { CopyToClipboardButton } from './copy-to-clipboard-button/CopyToClipboardButton' | ||
|
||
export function FileTabularData({ | ||
tabularData | ||
}: { | ||
tabularData: FileTabularDataModel | undefined | ||
}) { | ||
if (!tabularData) { | ||
return <></> | ||
} | ||
return ( | ||
<div> | ||
{tabularData.variablesCount} Variables, {tabularData.observationsCount} Observations{' '} | ||
{tabularData.unf} <CopyToClipboardButton text={tabularData.unf} /> | ||
</div> | ||
) | ||
} |
File renamed without changes.
23 changes: 23 additions & 0 deletions
23
src/sections/dataset/dataset-files/files-table/file-info-cell/FileType.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,23 @@ | ||
import { FileSize } from '../../../../../files/domain/models/File' | ||
|
||
interface FileTypeProps { | ||
type: string | ||
size: FileSize | ||
} | ||
|
||
export function FileType({ type, size }: FileTypeProps) { | ||
return ( | ||
<div> | ||
<span> | ||
{capitalizeFirstLetter(type)} - {size.toString()} | ||
</span> | ||
</div> | ||
) | ||
} | ||
|
||
function capitalizeFirstLetter(str: string): string { | ||
if (str.length === 0) { | ||
return str | ||
} | ||
return str.charAt(0).toUpperCase() + str.slice(1) | ||
} |
11 changes: 11 additions & 0 deletions
11
...set-files/files-table/file-info-cell/copy-to-clipboard-button/CopyToClipboard.module.scss
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,11 @@ | ||
@import "node_modules/dataverse-design-system/src/lib/components/assets/styles/design-tokens/colors.module"; | ||
|
||
.container { | ||
margin-left: 5px; | ||
cursor: pointer; | ||
} | ||
|
||
.check { | ||
color: $dv-success-color; | ||
font-size: 20px; | ||
} |
Oops, something went wrong.