Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This changelog follows the principles of [Keep a Changelog](https://keepachangel
- Changed the way we were handling DATE type metadata field validation to better match the backend validation and give users better error messages. For example, for an input like “foo AD”, we now show “Production Date is not a valid date. The AD year must be numeric.“. For an input like “99999 AD”, we now show “Production Date is not a valid date. The AD year cant be higher than 9999.“. For an input like “[-9999?], we now show “Production Date is not a valid date. The year in brackets cannot be negative.“, etc.
- The SPA now fetches the runtime configuration from `config.js` on each load, allowing configurations without rebuilding the app. We don't use `.env` variables at build time anymore.
- Renamed dataset template fetch/create use cases and DTOs to `getTemplatesByCollectionId` and `CreateTemplateDTO` for API alignment, and added new `getTemplate` and `deleteTemplate` use cases for retrieving a single template by ID and deleting templates.
- Added disclaimer text and custom popup text to Publish Dataset modal for better communication of the implications of publishing a dataset. The text can be configured through the runtime configuration.

### Fixed

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

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@dnd-kit/sortable": "8.0.0",
"@dnd-kit/utilities": "3.2.2",
"@faker-js/faker": "7.6.0",
"@iqss/dataverse-client-javascript": "2.0.0-alpha.85",
"@iqss/dataverse-client-javascript": "2.1.0-pr422.1631011",
"@iqss/dataverse-design-system": "*",
"@istanbuljs/nyc-config-typescript": "1.0.2",
"@tanstack/react-table": "8.9.2",
Expand Down
2 changes: 2 additions & 0 deletions src/info/domain/repositories/DataverseInfoRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ export interface DataverseInfoRepository {
getHasPublicStore: () => Promise<Setting<boolean>>
getExternalStatusesAllowed: () => Promise<Setting<string[]>>
getAvailableDatasetMetadataExportFormats: () => Promise<DatasetMetadataExportFormats>
getDatasetPublishPopupCustomText: () => Promise<Setting<string>>
getPublishDatasetDisclaimerText: () => Promise<Setting<string>>
}
8 changes: 8 additions & 0 deletions src/info/domain/useCases/getDatasetPublishPopupCustomText.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Setting } from '@/settings/domain/models/Setting'
import { DataverseInfoRepository } from '../repositories/DataverseInfoRepository'

export function getDatasetPublishPopupCustomText(
dataverseInfoRepository: DataverseInfoRepository
): Promise<Setting<string>> {
return dataverseInfoRepository.getDatasetPublishPopupCustomText()
}
8 changes: 8 additions & 0 deletions src/info/domain/useCases/getPublishDatasetDisclaimerText.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Setting } from '@/settings/domain/models/Setting'
import { DataverseInfoRepository } from '../repositories/DataverseInfoRepository'

export function getPublishDatasetDisclaimerText(
dataverseInfoRepository: DataverseInfoRepository
): Promise<Setting<string>> {
return dataverseInfoRepository.getPublishDatasetDisclaimerText()
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
getMaxEmbargoDurationInMonths,
getZipDownloadLimit,
getAvailableDatasetMetadataExportFormats,
getPublishDatasetDisclaimerText,
getDatasetPublishPopupCustomText,
ReadError
} from '@iqss/dataverse-client-javascript'
import { DataverseInfoRepository } from '@/info/domain/repositories/DataverseInfoRepository'
Expand Down Expand Up @@ -102,4 +104,47 @@ export class DataverseInfoJSDataverseRepository implements DataverseInfoReposito
getAvailableDatasetMetadataExportFormats(): Promise<DatasetMetadataExportFormats> {
return getAvailableDatasetMetadataExportFormats.execute()
}

getPublishDatasetDisclaimerText(): Promise<Setting<string>> {
return getPublishDatasetDisclaimerText
.execute()
.then((text) => {
const trimmedLength = text?.trim().length ?? 0
console.debug(
`[DataverseInfo] Loaded ${SettingName.PUBLISH_DATASET_DISCLAIMER_TEXT} (length=${trimmedLength})`
)

return {
name: SettingName.PUBLISH_DATASET_DISCLAIMER_TEXT,
value: text
}
})
.catch((error: unknown) => {
console.warn(
`[DataverseInfo] Failed loading ${SettingName.PUBLISH_DATASET_DISCLAIMER_TEXT}; defaulting to empty string`,
error
)

// In case of error, we default to an empty string which indicates no disclaimer text.
return {
name: SettingName.PUBLISH_DATASET_DISCLAIMER_TEXT,
value: ''
}
})
}
getDatasetPublishPopupCustomText(): Promise<Setting<string>> {
return getDatasetPublishPopupCustomText
.execute()
.then((text) => ({
name: SettingName.DATASET_PUBLISH_POPUP_CUSTOM_TEXT,
value: text
}))
.catch(() => {
// In case of error, we default to an empty string which indicates no custom text.
return {
name: SettingName.DATASET_PUBLISH_POPUP_CUSTOM_TEXT,
value: ''
}
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,22 @@
.secondaryText {
color: $dv-subtext-color;
}

.disclaimerText {
+ label {
color: $dv-danger-color;
}
}

.customPopupTextBlock {
border: 1px solid $dv-border-color;
background-color: #f8f9fa;
border-left: 4px solid $dv-primary-color;
padding: 0.75rem 1rem;
border-radius: 0.25rem;
}

.customPopupText {
margin: 0;
color: $dv-text-color;
}
50 changes: 46 additions & 4 deletions src/sections/dataset/publish-dataset/PublishDatasetModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ import { PublishDatasetHelpText } from './PublishDatasetHelpText'
import { CollectionRepository } from '@/collection/domain/repositories/CollectionRepository'
import { UpwardHierarchyNode } from '@/shared/hierarchy/domain/models/UpwardHierarchyNode'
import { DatasetLicense } from '@/dataset/domain/models/Dataset'
import styles from './PublishDatasetModal.module.scss'
import { PublishLicense } from '@/sections/dataset/publish-dataset/PublishLicense'
import { CustomTerms } from '@/sections/dataset/dataset-terms/CustomTerms'
import { useSettings } from '@/sections/settings/SettingsContext'
import { SettingName } from '@/settings/domain/models/Setting'
import styles from './PublishDatasetModal.module.scss'

interface PublishDatasetModalProps {
show: boolean
Expand Down Expand Up @@ -53,6 +55,7 @@ export function PublishDatasetModal({
const { t } = useTranslation('dataset')
const { user } = useSession()
const navigate = useNavigate()
const { getSettingByName } = useSettings()
const { submissionStatus, submitPublish, publishError } = usePublishDataset(
repository,
collectionRepository,
Expand All @@ -69,6 +72,19 @@ export function PublishDatasetModal({
}
const nextMajorVersionString = nextMajorVersion ? nextMajorVersion : ''
const nextMinorVersionString = nextMinorVersion ? nextMinorVersion : ''

const publishDisclaimerText = getSettingByName<string>(
SettingName.PUBLISH_DATASET_DISCLAIMER_TEXT
)?.value

const datasetPublishPopupCustomText = getSettingByName<string>(
SettingName.DATASET_PUBLISH_POPUP_CUSTOM_TEXT
)?.value

const shouldShowCustomPopupText = Boolean(datasetPublishPopupCustomText?.trim())
const shouldShowDisclaimer = Boolean(publishDisclaimerText?.trim())
const [isDisclaimerAccepted, setIsDisclaimerAccepted] = useState(false)

function onPublishSucceed() {
navigate(
`${Route.DATASETS}?${QueryParamKey.PERSISTENT_ID}=${persistentId}&${QueryParamKey.VERSION}=${DatasetNonNumericVersionSearchParam.DRAFT}`,
Expand All @@ -81,8 +97,13 @@ export function PublishDatasetModal({
}
const modalTitle = t('publish.title')

const handleCloseWithReset = () => {
setIsDisclaimerAccepted(false)
handleClose()
}

return (
<Modal show={show} onHide={handleClose} size="xl" ariaLabel={modalTitle}>
<Modal show={show} onHide={handleCloseWithReset} size="xl" ariaLabel={modalTitle}>
<Modal.Header>
<Modal.Title>{t('publish.title')}</Modal.Title>
</Modal.Header>
Expand All @@ -97,6 +118,10 @@ export function PublishDatasetModal({
requiresMajorVersionUpdate={requiresMajorVersionUpdate ?? false}
/>

{shouldShowCustomPopupText && (
<p className={styles.secondaryText}>{datasetPublishPopupCustomText}</p>
)}

{releasedVersionExists && !requiresMajorVersionUpdate && (
<>
<Form.RadioGroup title={'Update Version'}>
Expand Down Expand Up @@ -139,10 +164,24 @@ export function PublishDatasetModal({
window.open(newUrl, '_blank')
}}
/>

<div>
<CustomTerms customTerms={customTerms} />
</div>
<p className={styles.secondaryText}>{t('publish.termsText')}</p>

{shouldShowDisclaimer && (
<Form.Group>
<Form.Group.Checkbox
className={styles.disclaimerText}
id="publish-disclaimer-checkbox"
name="publish-disclaimer-checkbox"
checked={isDisclaimerAccepted}
onChange={(e) => setIsDisclaimerAccepted(e.target.checked)}
label={publishDisclaimerText}
/>
</Form.Group>
)}
</Stack>
<span className={styles.errorText}>
{submissionStatus === SubmissionStatus.Errored &&
Expand All @@ -159,7 +198,10 @@ export function PublishDatasetModal({
submitPublish(versionUpdateType)
}}
type="submit"
disabled={submissionStatus === SubmissionStatus.IsSubmitting}>
disabled={
submissionStatus === SubmissionStatus.IsSubmitting ||
(shouldShowDisclaimer && !isDisclaimerAccepted)
}>
<Stack direction="horizontal" gap={1}>
{t('publish.continueButton')}
{submissionStatus === SubmissionStatus.IsSubmitting && (
Expand All @@ -171,7 +213,7 @@ export function PublishDatasetModal({
withSpacing
variant="secondary"
type="button"
onClick={handleClose}
onClick={handleCloseWithReset}
disabled={submissionStatus === SubmissionStatus.IsSubmitting}>
{t('publish.cancelButton')}
</Button>
Expand Down
6 changes: 5 additions & 1 deletion src/sections/settings/SettingsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Setting, SettingName } from '../../settings/domain/models/Setting'
import { DataverseInfoRepository } from '@/info/domain/repositories/DataverseInfoRepository'
import { getZipDownloadLimit } from '@/info/domain/useCases/getZipDownloadLimit'
import { getMaxEmbargoDurationInMonths } from '@/info/domain/useCases/getMaxEmbargoDurationInMonths'
import { getPublishDatasetDisclaimerText } from '@/info/domain/useCases/getPublishDatasetDisclaimerText'
import { getDatasetPublishPopupCustomText } from '@/info/domain/useCases/getDatasetPublishPopupCustomText'
import { getHasPublicStore } from '@/info/domain/useCases/getHasPublicStore'
import { getExternalStatusesAllowed } from '@/info/domain/useCases/getExternalStatusesAllowed'
import { AppLoader } from '../shared/layout/app-loader/AppLoader'
Expand All @@ -26,7 +28,9 @@ export function SettingsProvider({
getZipDownloadLimit(dataverseInfoRepository),
getMaxEmbargoDurationInMonths(dataverseInfoRepository),
getHasPublicStore(dataverseInfoRepository),
getExternalStatusesAllowed(dataverseInfoRepository)
getExternalStatusesAllowed(dataverseInfoRepository),
getDatasetPublishPopupCustomText(dataverseInfoRepository),
getPublishDatasetDisclaimerText(dataverseInfoRepository)
])

setSettings(settingsResponse)
Expand Down
4 changes: 3 additions & 1 deletion src/settings/domain/models/Setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ export enum SettingName {
ZIP_DOWNLOAD_LIMIT = 'ZIP_DOWNLOAD_LIMIT',
ALLOWED_EXTERNAL_STATUSES = 'ALLOWED_EXTERNAL_STATUSES',
HAS_PUBLIC_STORE = 'HAS_PUBLIC_STORE',
MAX_EMBARGO_DURATION_IN_MONTHS = 'MAX_EMBARGO_DURATION_IN_MONTHS'
MAX_EMBARGO_DURATION_IN_MONTHS = 'MAX_EMBARGO_DURATION_IN_MONTHS',
PUBLISH_DATASET_DISCLAIMER_TEXT = 'PUBLISH_DATASET_DISCLAIMER_TEXT',
DATASET_PUBLISH_POPUP_CUSTOM_TEXT = 'DATASET_PUBLISH_POPUP_CUSTOM_TEXT'
}

export interface Setting<T> {
Expand Down
10 changes: 10 additions & 0 deletions src/stories/WithSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ export const WithSettings = (Story: StoryFn) => {

case SettingName.MAX_EMBARGO_DURATION_IN_MONTHS:
return SettingMother.createMaxEmbargoDurationInMonths(-1) as Setting<T>
case SettingName.DATASET_PUBLISH_POPUP_CUSTOM_TEXT:
return SettingMother.createDatasetPublishPopupCustomText(
'This is custom text for the dataset publish popup.'
) as Setting<T>
case SettingName.PUBLISH_DATASET_DISCLAIMER_TEXT:
return SettingMother.createPublishDatasetDisclaimerText(
'This is custom text for the publish dataset disclaimer.'
) as Setting<T>
default:
throw new Error(`No mock implementation for setting`)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { CollectionMockRepository } from '@/stories/collection/CollectionMockRep
import { UpwardHierarchyNodeMother } from '@tests/component/shared/hierarchy/domain/models/UpwardHierarchyNodeMother'
import { CustomTermsMother } from '@tests/component/dataset/domain/models/TermsOfUseMother'
import { LicenseMother } from '@tests/component/dataset/domain/models/LicenseMother'
import { WithSettings } from '@/stories/WithSettings'

const meta: Meta<typeof PublishDatasetModal> = {
title: 'Sections/Dataset Page/PublishDatasetModal',
Expand Down Expand Up @@ -117,3 +118,33 @@ export const WithCustomTerms: Story = {
handleClose={() => {}}></PublishDatasetModal>
)
}
export const withTextSettings: Story = {
decorators: [WithLoggedInUser, WithSettings],
render: () => (
<PublishDatasetModal
show={true}
repository={new DatasetMockRepository()}
collectionRepository={new CollectionMockRepository()}
parentCollection={UpwardHierarchyNodeMother.createCollection()}
persistentId={'test'}
license={LicenseMother.create()}
customTerms={undefined}
releasedVersionExists={false}
handleClose={() => {}}></PublishDatasetModal>
)
}
export const withTextSettingsAndCustomTerms: Story = {
decorators: [WithLoggedInUser, WithSettings],
render: () => (
<PublishDatasetModal
show={true}
repository={new DatasetMockRepository()}
collectionRepository={new CollectionMockRepository()}
parentCollection={UpwardHierarchyNodeMother.createCollection()}
persistentId={'test'}
license={undefined}
customTerms={CustomTermsMother.create()}
releasedVersionExists={false}
handleClose={() => {}}></PublishDatasetModal>
)
}
Loading
Loading