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/238-integration-single-file-download
  • Loading branch information
MellyGray committed Dec 11, 2023
2 parents d458245 + 333c7c6 commit 2758d01
Show file tree
Hide file tree
Showing 60 changed files with 1,345 additions and 372 deletions.
14 changes: 12 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,19 @@
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"warn",
{ "vars": "all", "varsIgnorePattern": "^_", "args": "after-used", "argsIgnorePattern": "^_" }
{
"vars": "all",
"varsIgnorePattern": "^_",
"args": "after-used",
"argsIgnorePattern": "^_"
}
],
"@typescript-eslint/no-empty-function": [
"error",
{
"allow": ["arrowFunctions"]
}
],
"@typescript-eslint/no-empty-function": ["error", { "allow": ["arrowFunctions"] }],
"react/react-in-jsx-scope": "off",
"prettier/prettier": [
"error",
Expand Down
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,45 @@

First install node >=16 and npm >=8. Recommended versions `node v19` and `npm v9`.

### Create a `.npmrc` file and add a token

To install the [@iqss/dataverse-client-javascript](https://github.com/IQSS/dataverse-client-javascript/pkgs/npm/dataverse-client-javascript)
from the GitHub registry, necessary for connecting with the Dataverse API, follow these steps to create an `.npmrc` file in
the root of your project using your GitHub token.

1. **Copy `.npmrc.example`**

Duplicate the `.npmrc.example` file in your project and save it as `.npmrc`.

2. **Replace the Token**

Open the newly created `.npmrc` file and replace `YOUR_GITHUB_TOKEN` with your actual GitHub token.

```plaintext
legacy-peer-deps=true
//npm.pkg.github.com/:_authToken=<YOUR_GITHUB_AUTH_TOKEN>
@iqss:registry=https://npm.pkg.github.com/
```

#### How to Get a GitHub Token

If you don't have a GitHub token yet, follow these steps:

1. Go to your GitHub account settings.

2. Navigate to "Developer settings" -> "Personal access tokens."

3. Click "Personal access tokens" -> "Tokens (classic)" -> "Generate new token (classic)".

4. Give the token a name and select the "read:packages" scope.

5. Copy the generated token.

6. Replace `YOUR_GITHUB_AUTH_TOKEN` in the `.npmrc` file with the copied token.

Now, you should be able to install the Dataverse JavaScript client using npm.

### `npm install`

Run this command to install the dependencies. You may see a message about vulnerabilities after running this command. \
Expand Down
1 change: 1 addition & 0 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ RUN npm run build

WORKDIR /usr/src/app
COPY package.json ./
COPY package-lock.json ./
COPY .npmrc ./
RUN npm install

Expand Down
28 changes: 24 additions & 4 deletions package-lock.json

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

3 changes: 2 additions & 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-pr97.418bf5e",
"@iqss/dataverse-client-javascript": "2.0.0-pr99.c36f1db",
"@iqss/dataverse-design-system": "*",
"@istanbuljs/nyc-config-typescript": "1.0.2",
"@tanstack/react-table": "8.9.2",
Expand All @@ -28,6 +28,7 @@
"i18next": "22.4.9",
"i18next-browser-languagedetector": "7.0.1",
"i18next-http-backend": "2.1.1",
"moment-timezone": "0.5.43",
"react-bootstrap": "2.7.2",
"react-bootstrap-icons": "1.10.3",
"react-i18next": "12.1.5",
Expand Down
24 changes: 24 additions & 0 deletions public/locales/en/dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,30 @@
"uploadFiles": "Upload Files"
},
"alerts": {
"publishInProgress": {
"heading": "Publish in Progress",
"alertText": "The dataset is locked while the persistent identifiers are being registered or updated, and/or the physical files are being validated."
},
"filesUpdated": {
"heading": "Success!",
"alertText": "One or more files have been updated."
},
"termsUpdated": {
"heading": "Success!",
"alertText": "The terms for this dataset have been updated."
},
"thumbnailUpdated": {
"heading": "Success!",
"alertText": "Dataset thumbnail updated."
},
"datasetDeleted": {
"heading": "Success!",
"alertText": "This dataset draft has been deleted."
},
"metadataUpdated": {
"heading": "Success!",
"alertText": "The metadata for this dataset has been updated."
},
"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"
Expand Down
23 changes: 23 additions & 0 deletions src/alert/domain/models/Alert.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { AlertVariant } from '@iqss/dataverse-design-system/dist/components/alert/AlertVariant'

export enum AlertMessageKey {
DRAFT_VERSION = 'draftVersion',
REQUESTED_VERSION_NOT_FOUND = 'requestedVersionNotFound',
REQUESTED_VERSION_NOT_FOUND_SHOW_DRAFT = 'requestedVersionNotFoundShowDraft',
SHARE_UNPUBLISHED_DATASET = 'shareUnpublishedDataset',
UNPUBLISHED_DATASET = 'unpublishedDataset',
METADATA_UPDATED = 'metadataUpdated',
FILES_UPDATED = 'filesUpdated',
TERMS_UPDATED = 'termsUpdated',
THUMBNAIL_UPDATED = 'thumbnailUpdated',
DATASET_DELETED = 'datasetDeleted',
PUBLISH_IN_PROGRESS = 'publishInProgress'
}

export class Alert {
constructor(
public readonly variant: AlertVariant,
public readonly messageKey: AlertMessageKey,
public dynamicFields?: object
) {}
}
76 changes: 29 additions & 47 deletions src/dataset/domain/models/Dataset.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AlertVariant } from '@iqss/dataverse-design-system/dist/components/alert/AlertVariant'
import { Alert, AlertMessageKey } from '../../../alert/domain/models/Alert'

export enum DatasetLabelSemanticMeaning {
DATASET = 'dataset',
Expand All @@ -24,22 +24,6 @@ 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 @@ -259,20 +243,19 @@ export interface DatasetPermissions {
}

export interface DatasetLock {
id: number
userPersistentId: string
reason: DatasetLockReason
}

export enum DatasetLockReason {
INGEST = 'ingest',
WORKFLOW = 'workflow',
IN_REVIEW = 'inReview',
DCM_UPLOAD = 'dcmUpload',
GLOBUS_UPLOAD = 'globusUpload',
INGEST = 'Ingest',
WORKFLOW = 'Workflow',
IN_REVIEW = 'InReview',
DCM_UPLOAD = 'DcmUpload',
GLOBUS_UPLOAD = 'GlobusUpload',
FINALIZE_PUBLICATION = 'finalizePublication',

EDIT_IN_PROGRESS = 'editInProgress',
FILE_VALIDATION_FAILED = 'fileValidationFailed'
EDIT_IN_PROGRESS = 'EditInProgress',
FILE_VALIDATION_FAILED = 'FileValidationFailed'
}

export interface PrivateUrl {
Expand All @@ -286,7 +269,7 @@ export class Dataset {
public readonly version: DatasetVersion,
public readonly citation: string,
public readonly labels: DatasetLabel[],
public readonly alerts: DatasetAlert[],
public readonly alerts: Alert[],
public readonly summaryFields: DatasetMetadataBlock[],
public readonly license: DatasetLicense,
public readonly metadataBlocks: DatasetMetadataBlocks,
Expand All @@ -303,8 +286,8 @@ export class Dataset {
return this.metadataBlocks[0].fields.title
}

public get isLockedFromPublishing(): boolean {
return this.isLockedFromEdits
public checkIsLockedFromPublishing(userPersistentId: string): boolean {
return this.checkIsLockedFromEdits(userPersistentId)
}

public get isLocked(): boolean {
Expand All @@ -315,12 +298,19 @@ export class Dataset {
return this.locks.some((lock) => lock.reason === DatasetLockReason.WORKFLOW)
}

public get isLockedFromEdits(): boolean {
public checkIsLockedFromEdits(userPersistentId: string): boolean {
const lockedReasonIsInReview = this.locks.some(
(lock) => lock.reason === DatasetLockReason.IN_REVIEW
)
// If the lock reason is workflow and the workflow userId is the same as the current user, then the user can edit
// TODO - Ask how we want to manage pending workflows

if (
this.locks.some(
(lock) =>
lock.reason === DatasetLockReason.WORKFLOW && lock.userPersistentId === userPersistentId
)
) {
return false
}

return this.isLocked && !(lockedReasonIsInReview && this.permissions.canPublishDataset)
}
Expand Down Expand Up @@ -357,7 +347,7 @@ export class Dataset {

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

constructor(
public readonly persistentId: string,
Expand Down Expand Up @@ -428,7 +418,7 @@ export class Dataset {
this.version.publishingStatus === DatasetPublishingStatus.DRAFT &&
this.permissions.canPublishDataset
) {
this.alerts.push(new DatasetAlert('warning', DatasetAlertMessageKey.DRAFT_VERSION))
this.alerts.push(new Alert('warning', AlertMessageKey.DRAFT_VERSION))
}
if (this.version.requestedVersion) {
if (this.version.latestVersionStatus == DatasetPublishingStatus.RELEASED) {
Expand All @@ -437,20 +427,16 @@ export class Dataset {
returnedVersion: `${this.version.toString()}`
}
this.alerts.push(
new DatasetAlert(
'warning',
DatasetAlertMessageKey.REQUESTED_VERSION_NOT_FOUND,
dynamicFields
)
new Alert('warning', AlertMessageKey.REQUESTED_VERSION_NOT_FOUND, dynamicFields)
)
} else {
const dynamicFields = {
requestedVersion: this.version.requestedVersion
}
this.alerts.push(
new DatasetAlert(
new Alert(
'warning',
DatasetAlertMessageKey.REQUESTED_VERSION_NOT_FOUND_SHOW_DRAFT,
AlertMessageKey.REQUESTED_VERSION_NOT_FOUND_SHOW_DRAFT,
dynamicFields
)
)
Expand All @@ -460,14 +446,10 @@ export class Dataset {
if (this.permissions.canPublishDataset) {
const dynamicFields = { privateUrl: this.privateUrl.urlSnippet + this.privateUrl.token }
this.alerts.push(
new DatasetAlert(
'info',
DatasetAlertMessageKey.SHARE_UNPUBLISHED_DATASET,
dynamicFields
)
new Alert('info', AlertMessageKey.SHARE_UNPUBLISHED_DATASET, dynamicFields)
)
} else {
this.alerts.push(new DatasetAlert('warning', DatasetAlertMessageKey.UNPUBLISHED_DATASET))
this.alerts.push(new Alert('warning', AlertMessageKey.UNPUBLISHED_DATASET))
}
}
}
Expand Down
Loading

0 comments on commit 2758d01

Please sign in to comment.