Skip to content

Commit

Permalink
Match PublishDatasetModal.tsx to JSF
Browse files Browse the repository at this point in the history
  • Loading branch information
ekraffmiller committed Nov 18, 2024
1 parent c0d45f6 commit d91fd51
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 34 deletions.
9 changes: 6 additions & 3 deletions public/locales/en/dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a>{{parentCollectionName}}</a> 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 <a>{{parentCollectionName}}</a> 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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
margin-bottom: 0;
color: $dv-warning-color;
}

.secondaryText {
color: $dv-subtext-color;
}
83 changes: 63 additions & 20 deletions src/sections/dataset/publish-dataset/PublishDatasetHelpText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<p className={styles.warningText}>
{!releasedVersionExists && parentCollectionIsReleased && <>{t('publish.draftQuestion')}</>}
{!releasedVersionExists && !parentCollectionIsReleased && (
<Trans
t={t}
i18nKey={'publish.releaseCollectionQuestion'}
values={{ parentCollectionName }}
components={{ a: <Link to={RouteWithParams.COLLECTIONS(parentCollectionId)} /> }}
/>
)}
{releasedVersionExists && <>{t('publish.previouslyReleasedQuestion')}</>}
</p>
)
}
function renderSubText(
t: TFunction,
releasedVersionExists: boolean,
requiresMajorVersionUpdate: boolean,
nextMajorVersion: string,
parentCollectionIsReleased: boolean
) {
return (
<p className={styles.secondaryText}>
{!releasedVersionExists && !parentCollectionIsReleased && (
<>{t('publish.releaseCollectionSubtext')}</>
)}
{!releasedVersionExists && parentCollectionIsReleased && <>{t('publish.draftSubtext')}</>}
{releasedVersionExists && !requiresMajorVersionUpdate && (
<>{t('publish.previouslyReleasedSubtext')}</>
)}
{releasedVersionExists && requiresMajorVersionUpdate && (
<>{t('publish.requiresMajorReleaseSubtext', { versionNumber: nextMajorVersion })}</>
)}
</p>
)
}

export function PublishDatasetHelpText({
Expand All @@ -25,24 +71,21 @@ export function PublishDatasetHelpText({

return (
<Stack direction="vertical">
<p className={styles.warningText}>
{!releasedVersionExists && parentCollectionIsReleased && <>{t('publish.draftQuestion')}</>}
{!releasedVersionExists && !parentCollectionIsReleased && (
<Trans
t={t}
i18nKey={'publish.releaseCollectionQuestion'}
values={{ parentCollectionName }}
components={{ a: <Link to={RouteWithParams.COLLECTIONS(parentCollectionId)} /> }}
/>
)}
{releasedVersionExists && <>{t('publish.previouslyReleasedQuestion')}</>}
</p>
<p>
{releasedVersionExists && requiresMajorVersionUpdate && (
<>{t('publish.requiresMajorRelease', { versionNumber: nextMajorVersion })}</>
)}
</p>
<p>{t('publish.termsText')}</p>
{renderWarningText(
t,
releasedVersionExists,
parentCollectionIsReleased,
parentCollectionName,
parentCollectionId
)}

{renderSubText(
t,
releasedVersionExists,
requiresMajorVersionUpdate,
nextMajorVersion,
parentCollectionIsReleased
)}
</Stack>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
.errorText {
color: $dv-danger-color;
}

.secondaryText {
color: $dv-subtext-color;
}
23 changes: 12 additions & 11 deletions src/sections/dataset/publish-dataset/PublishDatasetModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -85,21 +85,14 @@ export function PublishDatasetModal({
<PublishDatasetHelpText
releasedVersionExists={releasedVersionExists}
nextMajorVersion={nextMajorVersionString}
parentCollectionIsReleased={parentCollection.isReleased}
parentCollectionIsReleased={parentCollection.isReleased ?? true}
parentCollectionName={parentCollection.name}
parentCollectionId={parentCollection.id}
requiresMajorVersionUpdate={requiresMajorVersionUpdate}
/>
<License
license={{
name: defaultLicense.name,
uri: defaultLicense.uri,
iconUri: defaultLicense.iconUri
}}
requiresMajorVersionUpdate={requiresMajorVersionUpdate ?? false}
/>

{releasedVersionExists && !requiresMajorVersionUpdate && (
<>
<Form.Group.Text>{t('publish.selectVersion')}</Form.Group.Text>
<Form.RadioGroup title={'Update Version'}>
<Form.Group.Radio
defaultChecked
Expand Down Expand Up @@ -128,6 +121,14 @@ export function PublishDatasetModal({
</Form.RadioGroup>
</>
)}
<License
license={{
name: defaultLicense.name,
uri: defaultLicense.uri,
iconUri: defaultLicense.iconUri
}}
/>
<p className={styles.secondaryText}>{t('publish.termsText')}</p>
</Stack>
<span className={styles.errorText}>
{submissionStatus === SubmissionStatus.Errored &&
Expand Down

0 comments on commit d91fd51

Please sign in to comment.