Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/IQSS/dataverse-frontend
Browse files Browse the repository at this point in the history
…into feature/200-integration-total-dataset-files-size-with-search-criteria
  • Loading branch information
MellyGray committed Nov 2, 2023
2 parents 94a0192 + 1212e31 commit df407d8
Show file tree
Hide file tree
Showing 54 changed files with 1,477 additions and 118 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ jobs:
- name: Run e2e tests
run: npm run test:e2e

- name: Dump docker logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v2
with:
dest: './logs'

- name: Tar logs
if: failure()
run: tar cvzf ./logs.tgz ./logs

- name: Upload logs to GitHub
if: failure()
uses: actions/upload-artifact@master
with:
name: logs.tgz
path: ./logs.tgz

component:
runs-on: ubuntu-latest

Expand Down
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,36 @@ The environment is accessible through the following URLs:
- SPA: https://beta.dataverse.org/spa
- JSF: https://beta.dataverse.org

## Changes from the Style Guide
## Changes from the original JSF application

### Changes from the Style Guide

The design system and frontend in this repo are inspired by the Dataverse Project [Style Guide](https://guides.dataverse.org/en/latest/style/index.html), but the following changes have been made, especially for accessibility.

### Links
#### Links

We added an underline to links to make them accessible.

### File label
#### File label

Now we are using Bootstrap with a theme, so there is only one definition for the secondary color. Since Bootstrap applies
the secondary color to the labels automatically, the color of the file label is now the global secondary color which is
a lighter shade of grey than what it used to be.

We changed the citation block to be white with a colored border, to make the text in the box more accessible.

### Changes in functionality behavior

Our main goal is to replicate the behavior of the original JSF application in all its functionalities, although during development we have found opportunities to review certain behaviors and apply changes where we find appropriate.

#### Dataset files tab search

The original Dataset JSF page uses Solr to search for files based on the available filters. Past dataset versions are not indexed in Solr, so the filter option is not available (hidden) for such versions. When a version is indexed, the search text is searched in Solr, and Solr grammar can be applied. When the version is not indexed, the search text is searched in the database.

The new SPA does not use Solr as the API endpoint it uses performs all queries on the database. Filters and search options are available for all versions in the same way, homogenizing behavior, although losing the possibility of using the Solr grammar.

The decision of this change is made on the assumption that Solr may not be required in the context of files tab search, whose search facets are reduced compared to other in-application searches. Therefore, if we find evidence that the assumption is incorrect, we will work on extending the search capabilities to support Solr.

## Thanks

<a href="https://www.chromatic.com/"><img src="https://user-images.githubusercontent.com/321738/84662277-e3db4f80-af1b-11ea-88f5-91d67a5e59f6.png" width="153" height="30" alt="Chromatic" /></a>
Expand Down
11 changes: 11 additions & 0 deletions dev-env/docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ services:
mem_reservation: 1024m
privileged: false

dv_initializer:
container_name: 'dv_initializer'
image: gdcc/configbaker:unstable
restart: 'no'
command:
- sh
- -c
- 'fix-fs-perms.sh dv'
volumes:
- ./docker-dev-volumes/app/data:/dv

dev_dataverse_bootstrap:
container_name: 'dev_dataverse_bootstrap'
image: gdcc/configbaker:unstable
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,8 @@
"workerDirectory": "public"
},
"readme": "ERROR: No README data found!",
"_id": "[email protected]"
"_id": "[email protected]",
"overrides": {
"@parcel/watcher": "2.1.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function Tooltip({ placement, overlay, children, maxWidth = 200 }: Overla
<OverlayTriggerBS
key={placement}
placement={placement}
overlay={<TooltipBS style={{ maxWidth: maxWidth }}>{overlay}</TooltipBS>}>
overlay={<TooltipBS style={{ maxWidth: maxWidth, position: 'fixed' }}>{overlay}</TooltipBS>}>
<div style={{ display: 'inline-block' }}>{children}</div>
</OverlayTriggerBS>
)
Expand Down
22 changes: 22 additions & 0 deletions public/locales/en/dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,27 @@
"title": "Access Dataset"
},
"uploadFiles": "Upload Files"
},
"alerts": {
"draftVersion": {
"heading": "This draft version needs to be published",
"alertText": "When ready for sharing, please <b>publish</b> it so that others can see these changes"
},
"requestedVersionNotFound": {
"heading": "Info",
"alertText": "Version {{requestedVersion}} was not found. This is version {{returnedVersion}}."
},
"requestedVersionNotFoundShowDraft": {
"heading": "Info",
"alertText": "Version {{requestedVersion}} was not found. This is the DRAFT version."
},
"shareUnpublishedDataset": {
"heading": "Unpublished Dataset Private URL",
"alertText": "Privately share this dataset before it is published: {{privateUrl}}"
},
"unpublishedDataset": {
"heading": "Unpublished Dataset Private URL",
"alertText": "This unpublished dataset is being privately shared."
}
}
}
12 changes: 12 additions & 0 deletions public/locales/en/files.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@
"message": "This file has already been deleted (or replaced) in the current version. It may not be edited.",
"close": "Close"
},
"noSelectedFilesAlert": {
"title": "Select File(s)",
"message": "Please select one or more files.",
"close": "Close"
},
"accessFileMenu": {
"title": "Access File",
"headers": {
Expand All @@ -120,6 +125,13 @@
"provenance": "Provenance",
"delete": "Delete"
}
},
"downloadFiles": {
"title": "Download",
"options": {
"original": "Original Format",
"archival": "Archival Format (.tab)"
}
}
},
"requestAccess": {
Expand Down
87 changes: 84 additions & 3 deletions src/dataset/domain/models/Dataset.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { AlertVariant } from '@iqss/dataverse-design-system/dist/components/alert/AlertVariant'

export enum DatasetLabelSemanticMeaning {
DATASET = 'dataset',
FILE = 'file',
Expand All @@ -22,6 +24,22 @@ export class DatasetLabel {
) {}
}

export enum DatasetAlertMessageKey {
DRAFT_VERSION = 'draftVersion',
REQUESTED_VERSION_NOT_FOUND = 'requestedVersionNotFound',
REQUESTED_VERSION_NOT_FOUND_SHOW_DRAFT = 'requestedVersionNotFoundShowDraft',
SHARE_UNPUBLISHED_DATASET = 'shareUnpublishedDataset',
UNPUBLISHED_DATASET = 'unpublishedDataset'
}

export class DatasetAlert {
constructor(
public readonly variant: AlertVariant,
public readonly message: DatasetAlertMessageKey,
public readonly dynamicFields?: object
) {}
}

export enum MetadataBlockName {
CITATION = 'citation',
GEOSPATIAL = 'geospatial',
Expand Down Expand Up @@ -191,6 +209,7 @@ export interface DatasetLicense {
uri: string
iconUri?: string
}

const defaultLicense: DatasetLicense = {
name: 'CC0 1.0',
uri: 'https://creativecommons.org/publicdomain/zero/1.0',
Expand All @@ -217,7 +236,9 @@ export class DatasetVersion {
public readonly isInReview: boolean,
public readonly latestVersionStatus: DatasetPublishingStatus,
public readonly majorNumber?: number,
public readonly minorNumber?: number
public readonly minorNumber?: number,
// requestedVersion will be set if the user requested a version that did not exist.
public readonly requestedVersion?: string
) {}

toString(): string | DatasetNonNumericVersion {
Expand Down Expand Up @@ -254,20 +275,27 @@ export enum DatasetLockReason {
FILE_VALIDATION_FAILED = 'fileValidationFailed'
}

export interface PrivateUrl {
token: string
urlSnippet: string
}

export class Dataset {
constructor(
public readonly persistentId: string,
public readonly version: DatasetVersion,
public readonly citation: string,
public readonly labels: DatasetLabel[],
public readonly alerts: DatasetAlert[],
public readonly summaryFields: DatasetMetadataBlock[],
public readonly license: DatasetLicense,
public readonly metadataBlocks: DatasetMetadataBlocks,
public readonly permissions: DatasetPermissions,
public readonly locks: DatasetLock[],
public readonly hasValidTermsOfAccess: boolean,
public readonly isValid: boolean,
public readonly isReleased: boolean
public readonly isReleased: boolean,
public readonly privateUrl?: PrivateUrl
) {}

public getTitle(): string {
Expand Down Expand Up @@ -298,6 +326,7 @@ export class Dataset {

static Builder = class {
public readonly labels: DatasetLabel[] = []
public readonly alerts: DatasetAlert[] = []

constructor(
public readonly persistentId: string,
Expand All @@ -310,9 +339,11 @@ export class Dataset {
public readonly locks: DatasetLock[],
public readonly hasValidTermsOfAccess: boolean,
public readonly isValid: boolean,
public readonly isReleased: boolean
public readonly isReleased: boolean,
public readonly privateUrl?: PrivateUrl
) {
this.withLabels()
this.withAlerts()
}

withLabels() {
Expand Down Expand Up @@ -360,12 +391,62 @@ export class Dataset {
}
}

private withAlerts(): void {
if (
this.version.publishingStatus === DatasetPublishingStatus.DRAFT &&
this.permissions.canPublishDataset
) {
this.alerts.push(new DatasetAlert('warning', DatasetAlertMessageKey.DRAFT_VERSION))
}
if (this.version.requestedVersion) {
if (this.version.latestVersionStatus == DatasetPublishingStatus.RELEASED) {
const dynamicFields = {
requestedVersion: this.version.requestedVersion,
returnedVersion: `${this.version.toString()}`
}
this.alerts.push(
new DatasetAlert(
'warning',
DatasetAlertMessageKey.REQUESTED_VERSION_NOT_FOUND,
dynamicFields
)
)
} else {
const dynamicFields = {
requestedVersion: this.version.requestedVersion
}
this.alerts.push(
new DatasetAlert(
'warning',
DatasetAlertMessageKey.REQUESTED_VERSION_NOT_FOUND_SHOW_DRAFT,
dynamicFields
)
)
}
}
if (this.privateUrl) {
if (this.permissions.canPublishDataset) {
const dynamicFields = { privateUrl: this.privateUrl.urlSnippet + this.privateUrl.token }
this.alerts.push(
new DatasetAlert(
'info',
DatasetAlertMessageKey.SHARE_UNPUBLISHED_DATASET,
dynamicFields
)
)
} else {
this.alerts.push(new DatasetAlert('warning', DatasetAlertMessageKey.UNPUBLISHED_DATASET))
}
}
}

build(): Dataset {
return new Dataset(
this.persistentId,
this.version,
this.citation,
this.labels,
this.alerts,
this.summaryFields,
this.license,
this.metadataBlocks,
Expand Down
23 changes: 17 additions & 6 deletions src/dataset/infrastructure/mappers/JSDatasetMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,21 @@ import {
DatasetMetadataBlocks,
DatasetMetadataFields,
DatasetVersion,
MetadataBlockName
MetadataBlockName,
PrivateUrl
} from '../../domain/models/Dataset'

export class JSDatasetMapper {
static toDataset(jsDataset: JSDataset, citation: string, summaryFieldsNames: string[]): Dataset {
static toDataset(
jsDataset: JSDataset,
citation: string,
summaryFieldsNames: string[],
requestedVersion?: string,
privateUrl?: PrivateUrl
): Dataset {
return new Dataset.Builder(
jsDataset.persistentId,
JSDatasetMapper.toVersion(jsDataset.versionId, jsDataset.versionInfo),
JSDatasetMapper.toVersion(jsDataset.versionId, jsDataset.versionInfo, requestedVersion),
citation,
JSDatasetMapper.toSummaryFields(jsDataset.metadataBlocks, summaryFieldsNames),
jsDataset.license,
Expand All @@ -41,13 +48,16 @@ export class JSDatasetMapper {
[], // TODO Connect with dataset locks
true, // TODO Connect with dataset hasValidTermsOfAccess
true, // TODO Connect with dataset isValid
!!jsDataset.versionInfo.releaseTime // TODO Connect with dataset isReleased
jsDataset.versionInfo.releaseTime !== undefined &&
!isNaN(jsDataset.versionInfo.releaseTime.getTime()), // TODO Connect with dataset isReleased,
privateUrl
).build()
}

static toVersion(
jDatasetVersionId: number,
jsDatasetVersionInfo: JSDatasetVersionInfo
jsDatasetVersionInfo: JSDatasetVersionInfo,
requestedVersion?: string
): DatasetVersion {
return new DatasetVersion(
jDatasetVersionId,
Expand All @@ -56,7 +66,8 @@ export class JSDatasetMapper {
false, // TODO Connect with dataset version isInReview
JSDatasetMapper.toStatus(jsDatasetVersionInfo.state), // TODO Connect with dataset version latestVersionState
jsDatasetVersionInfo.majorNumber,
jsDatasetVersionInfo.minorNumber
jsDatasetVersionInfo.minorNumber,
requestedVersion
)
}

Expand Down
Loading

0 comments on commit df407d8

Please sign in to comment.