From d91fd5180e8244368207bd0d00f72e922bbc0177 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Mon, 18 Nov 2024 13:36:39 -0500 Subject: [PATCH] Match PublishDatasetModal.tsx to JSF --- public/locales/en/dataset.json | 9 +- .../PublishDatasetHelpText.module.scss | 4 + .../PublishDatasetHelpText.tsx | 83 ++++++++++++++----- .../PublishDatasetModal.module.scss | 4 + .../publish-dataset/PublishDatasetModal.tsx | 23 ++--- 5 files changed, 89 insertions(+), 34 deletions(-) diff --git a/public/locales/en/dataset.json b/public/locales/en/dataset.json index d1b5812de..d7d4b54c0 100644 --- a/public/locales/en/dataset.json +++ b/public/locales/en/dataset.json @@ -112,10 +112,13 @@ } }, "publish": { - "draftQuestion": "Are you sure you want to publish this dataset? Once you do so, it must remain public.", + "draftQuestion": "Are you sure you want to publish this dataset? Once you do so, it must remain published.", + "draftSubtext": "This version of the dataset will be published with the following terms:", "previouslyReleasedQuestion": "Are you sure you want to republish this dataset?", - "releaseCollectionQuestion": "This dataset cannot be published until {{parentCollectionName}} is published. Would you like to publish both right now? Once you do so, it must remain public.", - "requiresMajorRelease": "Due to the nature of the changes to the current draft this will be a major release ({{versionNumber}})", + "previouslyReleasedSubtext": "Select if this is a minor or major version update.", + "releaseCollectionQuestion": "This dataset cannot be published until {{parentCollectionName}} is published. Would you like to publish both right now? ", + "releaseCollectionSubtext": "Once you publish this dataset it must remain published.", + "requiresMajorReleaseSubtext": "Due to the nature of the changes to the current draft this will be a major release ({{versionNumber}})", "termsText": "To change the terms for this version, click the Cancel button and go to the Terms tab for this dataset.", "selectVersion": "Select if this is a minor or major version update.", "continueButton": "Continue", diff --git a/src/sections/dataset/publish-dataset/PublishDatasetHelpText.module.scss b/src/sections/dataset/publish-dataset/PublishDatasetHelpText.module.scss index 32f4c0f32..450fb3dfd 100644 --- a/src/sections/dataset/publish-dataset/PublishDatasetHelpText.module.scss +++ b/src/sections/dataset/publish-dataset/PublishDatasetHelpText.module.scss @@ -4,3 +4,7 @@ margin-bottom: 0; color: $dv-warning-color; } + +.secondaryText { + color: $dv-subtext-color; +} \ No newline at end of file diff --git a/src/sections/dataset/publish-dataset/PublishDatasetHelpText.tsx b/src/sections/dataset/publish-dataset/PublishDatasetHelpText.tsx index cfd903e26..545a2511f 100644 --- a/src/sections/dataset/publish-dataset/PublishDatasetHelpText.tsx +++ b/src/sections/dataset/publish-dataset/PublishDatasetHelpText.tsx @@ -3,14 +3,60 @@ import { RouteWithParams } from '@/sections/Route.enum' import { Link } from 'react-router-dom' import { Stack } from '@iqss/dataverse-design-system' import styles from './PublishDatasetHelpText.module.scss' +import { TFunction } from 'i18next' interface PublishDatasetHelpTextProps { releasedVersionExists: boolean nextMajorVersion: string - parentCollectionIsReleased: boolean | undefined + parentCollectionIsReleased: boolean parentCollectionName: string parentCollectionId: string - requiresMajorVersionUpdate?: boolean + requiresMajorVersionUpdate: boolean +} + +function renderWarningText( + t: TFunction, + releasedVersionExists: boolean, + parentCollectionIsReleased: boolean, + parentCollectionName: string, + parentCollectionId: string +) { + return ( +

+ {!releasedVersionExists && parentCollectionIsReleased && <>{t('publish.draftQuestion')}} + {!releasedVersionExists && !parentCollectionIsReleased && ( + }} + /> + )} + {releasedVersionExists && <>{t('publish.previouslyReleasedQuestion')}} +

+ ) +} +function renderSubText( + t: TFunction, + releasedVersionExists: boolean, + requiresMajorVersionUpdate: boolean, + nextMajorVersion: string, + parentCollectionIsReleased: boolean +) { + return ( +

+ {!releasedVersionExists && !parentCollectionIsReleased && ( + <>{t('publish.releaseCollectionSubtext')} + )} + {!releasedVersionExists && parentCollectionIsReleased && <>{t('publish.draftSubtext')}} + {releasedVersionExists && !requiresMajorVersionUpdate && ( + <>{t('publish.previouslyReleasedSubtext')} + )} + {releasedVersionExists && requiresMajorVersionUpdate && ( + <>{t('publish.requiresMajorReleaseSubtext', { versionNumber: nextMajorVersion })} + )} +

+ ) } export function PublishDatasetHelpText({ @@ -25,24 +71,21 @@ export function PublishDatasetHelpText({ return ( -

- {!releasedVersionExists && parentCollectionIsReleased && <>{t('publish.draftQuestion')}} - {!releasedVersionExists && !parentCollectionIsReleased && ( - }} - /> - )} - {releasedVersionExists && <>{t('publish.previouslyReleasedQuestion')}} -

-

- {releasedVersionExists && requiresMajorVersionUpdate && ( - <>{t('publish.requiresMajorRelease', { versionNumber: nextMajorVersion })} - )} -

-

{t('publish.termsText')}

+ {renderWarningText( + t, + releasedVersionExists, + parentCollectionIsReleased, + parentCollectionName, + parentCollectionId + )} + + {renderSubText( + t, + releasedVersionExists, + requiresMajorVersionUpdate, + nextMajorVersion, + parentCollectionIsReleased + )}
) } diff --git a/src/sections/dataset/publish-dataset/PublishDatasetModal.module.scss b/src/sections/dataset/publish-dataset/PublishDatasetModal.module.scss index f7e887adf..2d94cee00 100644 --- a/src/sections/dataset/publish-dataset/PublishDatasetModal.module.scss +++ b/src/sections/dataset/publish-dataset/PublishDatasetModal.module.scss @@ -3,3 +3,7 @@ .errorText { color: $dv-danger-color; } + +.secondaryText { + color: $dv-subtext-color; +} \ No newline at end of file diff --git a/src/sections/dataset/publish-dataset/PublishDatasetModal.tsx b/src/sections/dataset/publish-dataset/PublishDatasetModal.tsx index ac7d3a8f5..c1e1d41aa 100644 --- a/src/sections/dataset/publish-dataset/PublishDatasetModal.tsx +++ b/src/sections/dataset/publish-dataset/PublishDatasetModal.tsx @@ -47,7 +47,7 @@ export function PublishDatasetModal({ const { t } = useTranslation('dataset') const { user } = useSession() const navigate = useNavigate() - + console.log('requiresMajorVersionUpdate', requiresMajorVersionUpdate) const { submissionStatus, submitPublish, publishError } = usePublishDataset( repository, collectionRepository, @@ -85,21 +85,14 @@ export function PublishDatasetModal({ - + {releasedVersionExists && !requiresMajorVersionUpdate && ( <> - {t('publish.selectVersion')} )} + +

{t('publish.termsText')}

{submissionStatus === SubmissionStatus.Errored &&