Skip to content

Commit

Permalink
Add privateURL DatasetAlert
Browse files Browse the repository at this point in the history
  • Loading branch information
ekraffmiller committed Oct 3, 2023
1 parent 6ad836a commit f903022
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
3 changes: 2 additions & 1 deletion public/locales/en/dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"alerts": {
"draftVersion": "<b>This draft version needs to be published</b>. When ready for sharing, please <b>publish</b> it so that others can see these changes",
"requestedVersionNotFound": "Info – Version {0} was not found. This is version {1}"
"requestedVersionNotFound": "Info – Version {0} was not found. This is version {1}",
"unpublishedDataset": "Privately share this dataset before it is published: {0}"
}
}
21 changes: 17 additions & 4 deletions src/dataset/domain/models/Dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export class DatasetLabel {

export enum DatasetAlertMessageKey {
DRAFT_VERSION = 'draftVersion',
REQUESTED_VERSION_NOT_FOUND = 'requestedVersionNotFound'
REQUESTED_VERSION_NOT_FOUND = 'requestedVersionNotFound',
UNPUBLISHED_DATASET = 'unpublishedDataset'
}

export class DatasetAlert {
Expand Down Expand Up @@ -271,10 +272,11 @@ export class Dataset {
public readonly citation: string,
public readonly summaryFields: DatasetMetadataBlock[],
public readonly license: DatasetLicense = defaultLicense,
public readonly metadataBlocks: DatasetMetadataBlocks
public readonly metadataBlocks: DatasetMetadataBlocks,
public readonly privateUrl?: string
) {
this.withLabels()
this.withAlerts()
this.withAlerts(privateUrl)
}

withLabels() {
Expand Down Expand Up @@ -322,7 +324,7 @@ export class Dataset {
}
}

private withAlerts(): void {
private withAlerts(privateUrl?: string): void {
if (this.version.publishingStatus === DatasetPublishingStatus.DRAFT) {
this.alerts.push(
new DatasetAlert('warning', DatasetAlertMessageKey.DRAFT_VERSION, undefined, 'Info')
Expand All @@ -339,6 +341,17 @@ export class Dataset {
)
)
}
if (privateUrl) {
const dynamicFields = [privateUrl]
this.alerts.push(
new DatasetAlert(
'info',
DatasetAlertMessageKey.UNPUBLISHED_DATASET,
dynamicFields,
'Unpublished Dataset Private URL'
)
)
}
}

build(): Dataset {
Expand Down
6 changes: 4 additions & 2 deletions src/dataset/infrastructure/mappers/JSDatasetMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export class JSDatasetMapper {
jsDataset: JSDataset,
citation: string,
summaryFieldsNames: string[],
requestedVersion?: string
requestedVersion?: string,
privateUrl?: string
): Dataset {
return new Dataset.Builder(
jsDataset.persistentId,
Expand All @@ -34,7 +35,8 @@ export class JSDatasetMapper {
jsDataset.alternativePersistentId,
jsDataset.publicationDate,
jsDataset.citationDate
)
),
privateUrl
).build()
}

Expand Down

0 comments on commit f903022

Please sign in to comment.