Skip to content

Commit

Permalink
resolve merge commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ekraffmiller committed Dec 3, 2023
2 parents 29d8928 + 0576f50 commit 3c46360
Show file tree
Hide file tree
Showing 66 changed files with 1,653 additions and 354 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
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 @@ -61,6 +61,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
9 changes: 9 additions & 0 deletions public/locales/en/files.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"pageSize": "Files per page"
},
"tabularData": {
"name": "Tabular Data",
"variables": "Variables",
"observations": "Observations"
},
Expand Down Expand Up @@ -112,6 +113,14 @@
"title": "Access File",
"headers": {
"fileAccess": "File Access"
},
"downloadOptions": {
"title": "Download Options",
"options": {
"original": "Original File Format",
"RData": "R Data",
"tabular": "Tab-Delimited"
}
}
},
"editFilesMenu": {
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
) {}
}
106 changes: 59 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'
import { FileDownloadSize } from '../../../files/domain/models/File'

export enum DatasetLabelSemanticMeaning {
Expand All @@ -25,22 +25,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 @@ -260,20 +244,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 @@ -287,7 +270,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 @@ -306,8 +289,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 @@ -318,19 +301,56 @@ 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)
}

public get isLockedFromFileDownload(): boolean {
if (!this.isLocked) {
return false
}

if (
this.locks.some((lock) =>
[
DatasetLockReason.FINALIZE_PUBLICATION,
DatasetLockReason.DCM_UPLOAD,
DatasetLockReason.INGEST
].includes(lock.reason)
)
) {
return true
}

if (
this.locks.some((lock) => lock.reason === DatasetLockReason.IN_REVIEW) &&
!this.permissions.canUpdateDataset
) {
return true
}

// If the lock reason is workflow and the workflow userId is different than the current user, then is locked
// TODO - Ask how we want to manage pending workflows

return false
}

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

constructor(
public readonly persistentId: string,
Expand Down Expand Up @@ -403,7 +423,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 @@ -412,20 +432,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 @@ -435,14 +451,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 3c46360

Please sign in to comment.