Skip to content

Commit

Permalink
merge latest from develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ekraffmiller committed Nov 3, 2023
2 parents 4bf1c82 + 563f95d commit b6b33ed
Show file tree
Hide file tree
Showing 29 changed files with 288 additions and 54 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
working-directory: packages/design-system
run: npm run build

- name: Type check
run: tsc --noEmit

- name: ESLint
run: npm run lint:eslint

Expand Down
12 changes: 1 addition & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,7 @@ jobs:
run: ./run-env.sh "$E2E_DATAVERSE_IMAGE_TAG"

- name: Wait for containers to be ready
run: |
timeout 360s sh -c 'while ! docker logs dev_dataverse_bootstrap 2>&1 | grep -q "your instance has been configured"; do
echo "Checking logs..."
docker logs dev_dataverse_bootstrap | tail -n 5
echo "Text not found, waiting for 2 seconds..."
sleep 2
done'
- name: Display Docker logs
run: |
docker logs dev_dataverse_bootstrap
run: timeout 600s sh -c 'while ! docker logs dev_dataverse_bootstrap 2>&1 | grep -q "your instance has been configured"; do sleep 2; done'

- name: Run e2e tests
run: npm run test:e2e
Expand Down
2 changes: 1 addition & 1 deletion dev-env/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
POSTGRES_VERSION=13
DATAVERSE_DB_USER=dataverse
SOLR_VERSION=9.3.0
REGISTRY=ghcr.io
REGISTRY=docker.io
2 changes: 1 addition & 1 deletion dev-env/run-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export DATAVERSE_IMAGE_TAG=$1
export COMPOSE_HTTP_TIMEOUT=200

# Timeout for Dataverse bootstrap configbaker
export DATAVERSE_BOOTSTRAP_TIMEOUT="5m"
export DATAVERSE_BOOTSTRAP_TIMEOUT="10m"

echo "INFO - Setting up Dataverse on image tag ${DATAVERSE_IMAGE_TAG}..."

Expand Down
16 changes: 9 additions & 7 deletions package-lock.json

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

6 changes: 4 additions & 2 deletions 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-pr93.8996380",
"@iqss/dataverse-client-javascript": "2.0.0-pr97.418bf5e",
"@iqss/dataverse-design-system": "*",
"@istanbuljs/nyc-config-typescript": "1.0.2",
"@tanstack/react-table": "8.9.2",
Expand Down Expand Up @@ -62,9 +62,11 @@
"storybook": "concurrently 'storybook dev -p 6006 && open \"http://localhost:6006\"' 'cd packages/design-system && npm run storybook'",
"build-storybook": "storybook build",
"test:storybook": "test-storybook",
"test:storybook-all": "concurrently 'test-storybook' 'cd packages/design-system && npm run test:storybook'"
"test:storybook-all": "concurrently 'test-storybook' 'cd packages/design-system && npm run test:storybook'",
"typecheck": "tsc --noEmit"
},
"pre-commit": [
"typecheck",
"lint:fix",
"git:add",
"test:unit",
Expand Down
6 changes: 5 additions & 1 deletion src/dataset/domain/models/Dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ export class Dataset {
public readonly hasValidTermsOfAccess: boolean,
public readonly isValid: boolean,
public readonly isReleased: boolean,
public readonly thumbnail?: string,
public readonly privateUrl?: PrivateUrl
) {}

Expand Down Expand Up @@ -340,6 +341,7 @@ export class Dataset {
public readonly hasValidTermsOfAccess: boolean,
public readonly isValid: boolean,
public readonly isReleased: boolean,
public readonly thumbnail?: string,
public readonly privateUrl?: PrivateUrl
) {
this.withLabels()
Expand Down Expand Up @@ -454,7 +456,9 @@ export class Dataset {
this.locks,
this.hasValidTermsOfAccess,
this.isValid,
this.isReleased
this.isReleased,
this.thumbnail,
this.privateUrl
)
}
}
Expand Down
1 change: 1 addition & 0 deletions src/dataset/infrastructure/mappers/JSDatasetMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class JSDatasetMapper {
true, // TODO Connect with dataset isValid
jsDataset.versionInfo.releaseTime !== undefined &&
!isNaN(jsDataset.versionInfo.releaseTime.getTime()), // TODO Connect with dataset isReleased,
undefined, // TODO: get dataset thumbnail from Dataverse https://github.com/IQSS/dataverse-frontend/issues/203
privateUrl
).build()
}
Expand Down
3 changes: 2 additions & 1 deletion src/files/domain/repositories/FileRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export interface FileRepository {
) => Promise<FilesCountInfo>
getFilesTotalDownloadSizeByDatasetPersistentId: (
datasetPersistentId: string,
datasetVersion: DatasetVersion
datasetVersion: DatasetVersion,
criteria?: FileCriteria
) => Promise<number>
getUserPermissionsById: (id: number) => Promise<FileUserPermissions>
}
6 changes: 4 additions & 2 deletions src/files/domain/useCases/getFilesTotalDownloadSize.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { FileRepository } from '../repositories/FileRepository'
import { DatasetVersion } from '../../../dataset/domain/models/Dataset'
import { FileCriteria } from '../models/FileCriteria'

export async function getFilesTotalDownloadSize(
fileRepository: FileRepository,
datasetPersistentId: string,
datasetVersion: DatasetVersion
datasetVersion: DatasetVersion,
criteria?: FileCriteria
): Promise<number> {
return fileRepository
.getFilesTotalDownloadSizeByDatasetPersistentId(datasetPersistentId, datasetVersion)
.getFilesTotalDownloadSizeByDatasetPersistentId(datasetPersistentId, datasetVersion, criteria)
.catch((error: Error) => {
throw new Error(error.message)
})
Expand Down
11 changes: 9 additions & 2 deletions src/files/infrastructure/FileJSDataverseRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,17 @@ export class FileJSDataverseRepository implements FileRepository {

getFilesTotalDownloadSizeByDatasetPersistentId(
datasetPersistentId: string,
datasetVersion: DatasetVersion
datasetVersion: DatasetVersion,
criteria: FileCriteria = new FileCriteria()
): Promise<number> {
return getDatasetFilesTotalDownloadSize
.execute(datasetPersistentId, datasetVersion.toString(), FileDownloadSizeMode.ARCHIVAL)
.execute(
datasetPersistentId,
datasetVersion.toString(),
FileDownloadSizeMode.ARCHIVAL,
DomainFileMapper.toJSFileSearchCriteria(criteria),
includeDeaccessioned
)
.catch((error: ReadError) => {
throw new Error(error.message)
})
Expand Down
7 changes: 6 additions & 1 deletion src/sections/dataset/Dataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ export function Dataset({ fileRepository }: DatasetProps) {
<div className={styles.container}>
<Row>
<Col sm={9}>
<DatasetCitation citation={dataset.citation} version={dataset.version} />
<DatasetCitation
title={dataset.getTitle()}
thumbnail={dataset.thumbnail}
citation={dataset.citation}
version={dataset.version}
/>
</Col>
<Col sm={3}>
<DatasetActionButtons dataset={dataset} />
Expand Down
21 changes: 21 additions & 0 deletions src/sections/dataset/dataset-citation/CitationThumbnail.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { DatasetPublishingStatus } from '../../../dataset/domain/models/Dataset'
import styles from './DatasetCitation.module.scss'
import { Icon, IconName } from '@iqss/dataverse-design-system'

interface CitationThumbnailProps {
thumbnail?: string
title: string
publishingStatus: DatasetPublishingStatus
}

export function CitationThumbnail({ thumbnail, title, publishingStatus }: CitationThumbnailProps) {
if (thumbnail && publishingStatus !== DatasetPublishingStatus.DEACCESSIONED) {
return <img className={styles['preview-image']} src={thumbnail} alt={title} />
}

return (
<div className={styles.icon}>
<Icon name={IconName.DATASET} />
</div>
)
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@import "node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module";

.container {
min-height: 150px;
margin: 0.5rem 0;
padding: 10px;
border: 1px solid $dv-info-border-color;

}

.citation {
Expand All @@ -23,6 +23,13 @@
line-height: 1.1;
}

.preview-image {
width: 100%;
max-width: 140px;
height: auto;
max-height: 140px;
}

.row {
margin-right: -15px;
margin-left: -15px;
Expand Down
19 changes: 12 additions & 7 deletions src/sections/dataset/dataset-citation/DatasetCitation.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { Col, IconName, Icon, QuestionMarkTooltip, Row } from '@iqss/dataverse-design-system'
import { Col, QuestionMarkTooltip, Row } from '@iqss/dataverse-design-system'
import styles from './DatasetCitation.module.scss'
import { useTranslation } from 'react-i18next'
import { DatasetPublishingStatus, DatasetVersion } from '../../../dataset/domain/models/Dataset'
import parse from 'html-react-parser'
import { CitationThumbnail } from './CitationThumbnail'

interface DatasetCitationProps {
thumbnail?: string
title: string
citation: string
version: DatasetVersion
}

export function DatasetCitation({ citation, version }: DatasetCitationProps) {
export function DatasetCitation({ thumbnail, title, citation, version }: DatasetCitationProps) {
const { t } = useTranslation('dataset')
return (
<>
Expand All @@ -20,10 +23,12 @@ export function DatasetCitation({ citation, version }: DatasetCitationProps) {
: styles.container
}>
<Row className={styles.row}>
<Col sm={3}>
<div className={styles.icon}>
<Icon name={IconName.DATASET} />
</div>
<Col sm={2}>
<CitationThumbnail
thumbnail={thumbnail}
title={title}
publishingStatus={version.publishingStatus}
/>
</Col>
<Col>
<Row>
Expand All @@ -48,7 +53,7 @@ export function DatasetCitation({ citation, version }: DatasetCitationProps) {
)
}

function CitationDescription({ citation, version }: DatasetCitationProps) {
function CitationDescription({ citation, version }: { citation: string; version: DatasetVersion }) {
const citationAsReactElement = parse(citation)

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function FileOptionsMenu({ file }: { file: File }) {
<DropdownHeader>
<PencilFill /> {t('actions.optionsMenu.headers.editOptions')}
</DropdownHeader>
<EditFilesOptions files={[file]} />
<EditFilesOptions files={[file]} fileSelection={{ [file.id]: file }} />
</DropdownButton>
</Tooltip>
)
Expand Down
4 changes: 2 additions & 2 deletions src/sections/dataset/dataset-files/useFiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ export function useFiles(
])

useEffect(() => {
getFilesTotalDownloadSize(filesRepository, datasetPersistentId, datasetVersion)
getFilesTotalDownloadSize(filesRepository, datasetPersistentId, datasetVersion, criteria)
.then((filesTotalDownloadSize: number) => {
setFilesTotalDownloadSize(filesTotalDownloadSize)
})
.catch((error) => {
console.error('There was an error getting the files total download size', error)
})
}, [filesRepository, datasetPersistentId, datasetVersion])
}, [filesRepository, datasetPersistentId, datasetVersion, criteria])

return {
files,
Expand Down
Loading

0 comments on commit b6b33ed

Please sign in to comment.