Skip to content

Commit 6381f92

Browse files
committed
Merge branch 'develop' into StorageQuota
2 parents 543cf39 + e0ddce8 commit 6381f92

27 files changed

Lines changed: 502 additions & 212 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ This changelog follows the principles of [Keep a Changelog](https://keepachangel
2727
- 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.
2828
- 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.
2929
- 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.
30+
- 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.
3031
- Dataset page Terms tab title now depends on permissions: users with dataset update permission see `Terms and Guestbook`, and read-only users see `Terms`.
3132

3233
### Fixed

package-lock.json

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/info/domain/repositories/DataverseInfoRepository.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ export interface DataverseInfoRepository {
1212
getHasPublicStore: () => Promise<Setting<boolean>>
1313
getExternalStatusesAllowed: () => Promise<Setting<string[]>>
1414
getAvailableDatasetMetadataExportFormats: () => Promise<DatasetMetadataExportFormats>
15+
getDatasetPublishPopupCustomText: () => Promise<Setting<string>>
16+
getPublishDatasetDisclaimerText: () => Promise<Setting<string>>
1517
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Setting } from '@/settings/domain/models/Setting'
2+
import { DataverseInfoRepository } from '../repositories/DataverseInfoRepository'
3+
4+
export function getDatasetPublishPopupCustomText(
5+
dataverseInfoRepository: DataverseInfoRepository
6+
): Promise<Setting<string>> {
7+
return dataverseInfoRepository.getDatasetPublishPopupCustomText()
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Setting } from '@/settings/domain/models/Setting'
2+
import { DataverseInfoRepository } from '../repositories/DataverseInfoRepository'
3+
4+
export function getPublishDatasetDisclaimerText(
5+
dataverseInfoRepository: DataverseInfoRepository
6+
): Promise<Setting<string>> {
7+
return dataverseInfoRepository.getPublishDatasetDisclaimerText()
8+
}

src/info/infrastructure/repositories/DataverseInfoJSDataverseRepository.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {
44
getMaxEmbargoDurationInMonths,
55
getZipDownloadLimit,
66
getAvailableDatasetMetadataExportFormats,
7+
getPublishDatasetDisclaimerText,
8+
getDatasetPublishPopupCustomText,
79
ReadError
810
} from '@iqss/dataverse-client-javascript'
911
import { DataverseInfoRepository } from '@/info/domain/repositories/DataverseInfoRepository'
@@ -102,4 +104,37 @@ export class DataverseInfoJSDataverseRepository implements DataverseInfoReposito
102104
getAvailableDatasetMetadataExportFormats(): Promise<DatasetMetadataExportFormats> {
103105
return getAvailableDatasetMetadataExportFormats.execute()
104106
}
107+
108+
getPublishDatasetDisclaimerText(): Promise<Setting<string>> {
109+
return getPublishDatasetDisclaimerText
110+
.execute()
111+
.then((text) => {
112+
return {
113+
name: SettingName.PUBLISH_DATASET_DISCLAIMER_TEXT,
114+
value: text
115+
}
116+
})
117+
.catch(() => {
118+
// In case of error, we default to an empty string which indicates no disclaimer text.
119+
return {
120+
name: SettingName.PUBLISH_DATASET_DISCLAIMER_TEXT,
121+
value: ''
122+
}
123+
})
124+
}
125+
getDatasetPublishPopupCustomText(): Promise<Setting<string>> {
126+
return getDatasetPublishPopupCustomText
127+
.execute()
128+
.then((text) => ({
129+
name: SettingName.DATASET_PUBLISH_POPUP_CUSTOM_TEXT,
130+
value: text
131+
}))
132+
.catch(() => {
133+
// In case of error, we default to an empty string which indicates no custom text.
134+
return {
135+
name: SettingName.DATASET_PUBLISH_POPUP_CUSTOM_TEXT,
136+
value: ''
137+
}
138+
})
139+
}
105140
}

src/sections/dataset/publish-dataset/PublishDatasetModal.module.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,21 @@
77
.secondaryText {
88
color: $dv-subtext-color;
99
}
10+
11+
.disclaimerText {
12+
+ label {
13+
color: $dv-danger-color;
14+
}
15+
}
16+
17+
.customPopupTextBlock {
18+
border: 1px solid $dv-border-color;
19+
background-color: #f8f9fa;
20+
padding: 0.75rem 1rem;
21+
border-radius: 0.25rem;
22+
}
23+
24+
.customPopupText {
25+
margin: 0;
26+
color: $dv-text-color;
27+
}

src/sections/dataset/publish-dataset/PublishDatasetModal.tsx

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ import { PublishDatasetHelpText } from './PublishDatasetHelpText'
1717
import { CollectionRepository } from '@/collection/domain/repositories/CollectionRepository'
1818
import { UpwardHierarchyNode } from '@/shared/hierarchy/domain/models/UpwardHierarchyNode'
1919
import { DatasetLicense } from '@/dataset/domain/models/Dataset'
20-
import styles from './PublishDatasetModal.module.scss'
2120
import { PublishLicense } from '@/sections/dataset/publish-dataset/PublishLicense'
2221
import { CustomTerms } from '@/sections/dataset/dataset-terms/CustomTerms'
22+
import { useSettings } from '@/sections/settings/SettingsContext'
23+
import { SettingName } from '@/settings/domain/models/Setting'
24+
import styles from './PublishDatasetModal.module.scss'
2325

2426
interface PublishDatasetModalProps {
2527
show: boolean
@@ -53,6 +55,7 @@ export function PublishDatasetModal({
5355
const { t } = useTranslation('dataset')
5456
const { user } = useSession()
5557
const navigate = useNavigate()
58+
const { getSettingByName } = useSettings()
5659
const { submissionStatus, submitPublish, publishError } = usePublishDataset(
5760
repository,
5861
collectionRepository,
@@ -69,6 +72,19 @@ export function PublishDatasetModal({
6972
}
7073
const nextMajorVersionString = nextMajorVersion ? nextMajorVersion : ''
7174
const nextMinorVersionString = nextMinorVersion ? nextMinorVersion : ''
75+
76+
const publishDisclaimerText = getSettingByName<string>(
77+
SettingName.PUBLISH_DATASET_DISCLAIMER_TEXT
78+
)?.value
79+
80+
const datasetPublishPopupCustomText = getSettingByName<string>(
81+
SettingName.DATASET_PUBLISH_POPUP_CUSTOM_TEXT
82+
)?.value
83+
84+
const shouldShowCustomPopupText = Boolean(datasetPublishPopupCustomText?.trim())
85+
const shouldShowDisclaimer = Boolean(publishDisclaimerText?.trim())
86+
const [isDisclaimerAccepted, setIsDisclaimerAccepted] = useState(false)
87+
7288
function onPublishSucceed() {
7389
navigate(
7490
`${Route.DATASETS}?${QueryParamKey.PERSISTENT_ID}=${persistentId}&${QueryParamKey.VERSION}=${DatasetNonNumericVersionSearchParam.DRAFT}`,
@@ -81,8 +97,13 @@ export function PublishDatasetModal({
8197
}
8298
const modalTitle = t('publish.title')
8399

100+
const handleCloseWithReset = () => {
101+
setIsDisclaimerAccepted(false)
102+
handleClose()
103+
}
104+
84105
return (
85-
<Modal show={show} onHide={handleClose} size="xl" ariaLabel={modalTitle}>
106+
<Modal show={show} onHide={handleCloseWithReset} size="xl" ariaLabel={modalTitle}>
86107
<Modal.Header>
87108
<Modal.Title>{t('publish.title')}</Modal.Title>
88109
</Modal.Header>
@@ -97,6 +118,12 @@ export function PublishDatasetModal({
97118
requiresMajorVersionUpdate={requiresMajorVersionUpdate ?? false}
98119
/>
99120

121+
{shouldShowCustomPopupText && (
122+
<div className={styles.customPopupTextBlock}>
123+
<p className={styles.customPopupText}>{datasetPublishPopupCustomText}</p>
124+
</div>
125+
)}
126+
100127
{releasedVersionExists && !requiresMajorVersionUpdate && (
101128
<>
102129
<Form.RadioGroup title={'Update Version'}>
@@ -139,10 +166,24 @@ export function PublishDatasetModal({
139166
window.open(newUrl, '_blank')
140167
}}
141168
/>
169+
142170
<div>
143171
<CustomTerms customTerms={customTerms} />
144172
</div>
145173
<p className={styles.secondaryText}>{t('publish.termsText')}</p>
174+
175+
{shouldShowDisclaimer && (
176+
<Form.Group>
177+
<Form.Group.Checkbox
178+
className={styles.disclaimerText}
179+
id="publish-disclaimer-checkbox"
180+
name="publish-disclaimer-checkbox"
181+
checked={isDisclaimerAccepted}
182+
onChange={(e) => setIsDisclaimerAccepted(e.target.checked)}
183+
label={publishDisclaimerText}
184+
/>
185+
</Form.Group>
186+
)}
146187
</Stack>
147188
<span className={styles.errorText}>
148189
{submissionStatus === SubmissionStatus.Errored &&
@@ -159,7 +200,10 @@ export function PublishDatasetModal({
159200
submitPublish(versionUpdateType)
160201
}}
161202
type="submit"
162-
disabled={submissionStatus === SubmissionStatus.IsSubmitting}>
203+
disabled={
204+
submissionStatus === SubmissionStatus.IsSubmitting ||
205+
(shouldShowDisclaimer && !isDisclaimerAccepted)
206+
}>
163207
<Stack direction="horizontal" gap={1}>
164208
{t('publish.continueButton')}
165209
{submissionStatus === SubmissionStatus.IsSubmitting && (
@@ -171,7 +215,7 @@ export function PublishDatasetModal({
171215
withSpacing
172216
variant="secondary"
173217
type="button"
174-
onClick={handleClose}
218+
onClick={handleCloseWithReset}
175219
disabled={submissionStatus === SubmissionStatus.IsSubmitting}>
176220
{t('publish.cancelButton')}
177221
</Button>

src/sections/settings/SettingsProvider.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { Setting, SettingName } from '../../settings/domain/models/Setting'
44
import { DataverseInfoRepository } from '@/info/domain/repositories/DataverseInfoRepository'
55
import { getZipDownloadLimit } from '@/info/domain/useCases/getZipDownloadLimit'
66
import { getMaxEmbargoDurationInMonths } from '@/info/domain/useCases/getMaxEmbargoDurationInMonths'
7+
import { getPublishDatasetDisclaimerText } from '@/info/domain/useCases/getPublishDatasetDisclaimerText'
8+
import { getDatasetPublishPopupCustomText } from '@/info/domain/useCases/getDatasetPublishPopupCustomText'
79
import { getHasPublicStore } from '@/info/domain/useCases/getHasPublicStore'
810
import { getExternalStatusesAllowed } from '@/info/domain/useCases/getExternalStatusesAllowed'
911
import { AppLoader } from '../shared/layout/app-loader/AppLoader'
@@ -26,7 +28,9 @@ export function SettingsProvider({
2628
getZipDownloadLimit(dataverseInfoRepository),
2729
getMaxEmbargoDurationInMonths(dataverseInfoRepository),
2830
getHasPublicStore(dataverseInfoRepository),
29-
getExternalStatusesAllowed(dataverseInfoRepository)
31+
getExternalStatusesAllowed(dataverseInfoRepository),
32+
getDatasetPublishPopupCustomText(dataverseInfoRepository),
33+
getPublishDatasetDisclaimerText(dataverseInfoRepository)
3034
])
3135

3236
setSettings(settingsResponse)

src/settings/domain/models/Setting.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ export enum SettingName {
22
ZIP_DOWNLOAD_LIMIT = 'ZIP_DOWNLOAD_LIMIT',
33
ALLOWED_EXTERNAL_STATUSES = 'ALLOWED_EXTERNAL_STATUSES',
44
HAS_PUBLIC_STORE = 'HAS_PUBLIC_STORE',
5-
MAX_EMBARGO_DURATION_IN_MONTHS = 'MAX_EMBARGO_DURATION_IN_MONTHS'
5+
MAX_EMBARGO_DURATION_IN_MONTHS = 'MAX_EMBARGO_DURATION_IN_MONTHS',
6+
PUBLISH_DATASET_DISCLAIMER_TEXT = 'PUBLISH_DATASET_DISCLAIMER_TEXT',
7+
DATASET_PUBLISH_POPUP_CUSTOM_TEXT = 'DATASET_PUBLISH_POPUP_CUSTOM_TEXT'
68
}
79

810
export interface Setting<T> {

0 commit comments

Comments
 (0)