Skip to content

Commit a584d69

Browse files
committed
add logic for PublishDatasetHelpText.tsx warning text, fix translation
1 parent 3fc729f commit a584d69

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

public/locales/en/dataset.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
"previouslyReleasedQuestion": "Are you sure you want to republish this dataset?",
117117
"releaseCollectionQuestion": "This dataset cannot be published until <a>{{parentCollectionName}}</a> is published. Would you like to publish both right now?",
118118
"requiresMajorRelease": "Due to the nature of the changes to the current draft this will be a major release ({{versionNumber}})",
119-
"termsText": "To publish with custom Terms of Use, click the Cancel button and go to the Terms tab for this dataset.",
119+
"termsText": "To change the terms for this version, click the Cancel button and go to the Terms tab for this dataset.",
120120
"selectVersion": "Select if this is a minor or major version update.",
121121
"continueButton": "Continue",
122122
"cancelButton": "Cancel",

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

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@ interface PublishDatasetHelpTextProps {
1313
requiresMajorVersionUpdate?: boolean
1414
}
1515

16-
function getWarningTextKey(
17-
releasedVersionExists: boolean,
18-
parentCollectionIsReleased: boolean | undefined
19-
): string {
20-
if (!releasedVersionExists) {
21-
if (!parentCollectionIsReleased) {
22-
return 'publish.releaseCollectionQuestion'
23-
} else return 'publish.draftQuestion'
24-
}
25-
return 'publish.previouslyReleasedQuestion'
26-
}
27-
2816
export function PublishDatasetHelpText({
2917
releasedVersionExists,
3018
nextMajorVersion,
@@ -34,20 +22,24 @@ export function PublishDatasetHelpText({
3422
requiresMajorVersionUpdate
3523
}: PublishDatasetHelpTextProps) {
3624
const { t } = useTranslation('dataset')
37-
const warningText = getWarningTextKey(releasedVersionExists, parentCollectionIsReleased)
3825

3926
return (
4027
<Stack direction="vertical">
4128
<p className={styles.warningText}>
42-
{!parentCollectionIsReleased ? (
29+
{!releasedVersionExists && parentCollectionIsReleased && <>{t('publish.draftQuestion')}</>}
30+
{!releasedVersionExists && !parentCollectionIsReleased && (
4331
<Trans
4432
t={t}
45-
i18nKey={warningText}
33+
i18nKey={'publish.releaseCollectionQuestion'}
4634
values={{ parentCollectionName }}
4735
components={{ a: <Link to={RouteWithParams.COLLECTIONS(parentCollectionId)} /> }}
4836
/>
49-
) : (
50-
<>{t(warningText)}</>
37+
)}
38+
{releasedVersionExists && !requiresMajorVersionUpdate && (
39+
<>{t('publish.previouslyReleasedQuestion')}</>
40+
)}
41+
{releasedVersionExists && requiresMajorVersionUpdate && (
42+
<Trans t={t} i18nKey={'publish.requiresMajorRelease'} values={{ nextMajorVersion }} />
5143
)}
5244
</p>
5345
<p>{t('publish.termsText')}</p>

0 commit comments

Comments
 (0)