Skip to content

Commit

Permalink
updates based on review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ekraffmiller committed Sep 3, 2024
1 parent 272d359 commit 89bf3e3
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ export class DatasetJSDataverseRepository implements DatasetRepository {
datasetDetails.jsDataset.versionInfo.state === DatasetVersionState.DRAFT &&
datasetDetails.jsDataset.publicationDate !== undefined
) {
// If the dataset is a draft, but has a publication date, then we need the version
// numbers of the latest published version to show in the "Publish" button
return this.getLatestPublishedVersionNumbers(datasetDetails)
} else {
return datasetDetails
Expand Down Expand Up @@ -214,10 +216,10 @@ export class DatasetJSDataverseRepository implements DatasetRepository {
canManageDatasetPermissions: true,
canDeleteDatasetDraft: true,
canViewUnpublishedDataset: true
},
[],
0,
0
}, // TODO Connect with JS dataset permissions for privateUrl when it is available in js-dataverse
[], // TODO Connect with JS dataset locks for privateUrl when it is available in js-dataverse
0, // TODO Connect with JS dataset filesTotalDownloadSize for privateUrl when it is available in js-dataverse
0 // TODO Connect with JS dataset filesTotalDownloadSize for privateUrl when it is available in js-dataverse
)
)
.catch((error: ReadError) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const InputLevelsTable = ({
})}>
<div className={styles['close-button-container']}>{closeButton}</div>

<Table>
<Table bordered={false}>
<tbody>
{Object.entries(blockMetadataInputLevelFields.metadataFields).map(([key, field]) => (
<InputLevelFieldRow metadataField={field} disabled={disabled} key={key} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@import "node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module";

.container {
margin: 10px;
padding: 10px;
background-color: $dv-info-box-color;
border: 1px solid black;
Expand Down
93 changes: 46 additions & 47 deletions src/sections/dataset/publish-dataset/PublishDatasetModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Button, Modal } from '@iqss/dataverse-design-system'
import { Button, Modal, Stack } from '@iqss/dataverse-design-system'
import { Form } from '@iqss/dataverse-design-system'
import type { DatasetRepository } from '../../../dataset/domain/repositories/DatasetRepository'
import { VersionUpdateType } from '../../../dataset/domain/models/VersionUpdateType'
Expand All @@ -23,19 +23,19 @@ interface PublishDatasetModalProps {
repository: DatasetRepository
persistentId: string
releasedVersionExists: boolean
nextMajorVersion: string | undefined
nextMinorVersion: string | undefined
handleClose: () => void
nextMajorVersion?: string
nextMinorVersion?: string
}

export function PublishDatasetModal({
show,
repository,
persistentId,
releasedVersionExists,
handleClose,
nextMajorVersion,
nextMinorVersion,
handleClose
nextMinorVersion
}: PublishDatasetModalProps) {
const { t } = useTranslation('dataset')
const { user } = useSession()
Expand Down Expand Up @@ -64,57 +64,56 @@ export function PublishDatasetModal({
)
handleClose()
}
if (releasedVersionExists && (!nextMajorVersion || !nextMinorVersion)) {
console.log('Error: nextMajorVersion or nextMinorVersion is missing')
return null
}

return (
<Modal show={show} onHide={handleClose} size="lg">
<Modal show={show} onHide={handleClose} size="xl">
<Modal.Header>
<Modal.Title>Publish Dataset</Modal.Title>
</Modal.Header>
<Modal.Body>
<PublishDatasetHelpText releasedVersionExists={releasedVersionExists} />
<License
license={{
name: defaultLicense.name,
uri: defaultLicense.uri,
iconUri: defaultLicense.iconUri
}}
/>
{releasedVersionExists && (
<>
<p>{t('publish.selectVersion')}</p>
<Form.RadioGroup title={'Update Version'}>
<Form.Group.Radio
defaultChecked
onClick={handleVersionUpdateTypeChange}
name="update-type"
label={t('publish.minorVersion') + ` (${nextMinorVersionString})`}
id="update-type-minor"
value={VersionUpdateType.MINOR}
/>
<Form.Group.Radio
onClick={handleVersionUpdateTypeChange}
name="update-type"
label={t('publish.majorVersion') + ` (${nextMajorVersionString})`}
id="update-type-major"
value={VersionUpdateType.MAJOR}
/>
{user?.superuser && (
<Stack direction="vertical">
<PublishDatasetHelpText releasedVersionExists={releasedVersionExists} />
<License
license={{
name: defaultLicense.name,
uri: defaultLicense.uri,
iconUri: defaultLicense.iconUri
}}
/>
{releasedVersionExists && (
<>
<Form.Group.Text>{t('publish.selectVersion')}</Form.Group.Text>
<Form.RadioGroup title={'Update Version'}>
<Form.Group.Radio
defaultChecked
onClick={handleVersionUpdateTypeChange}
name="update-type"
label={t('publish.minorVersion') + ` (${nextMinorVersionString})`}
id="update-type-minor"
value={VersionUpdateType.MINOR}
/>
<Form.Group.Radio
onClick={handleVersionUpdateTypeChange}
name="update-type"
label={t('publish.updateCurrentVersion')}
id="update-type-current"
// TODO: Remove disabled when JSVersionUpdateType.UPDATE_CURRENT is available in js-dataverse
disabled={true}
value={VersionUpdateType.UPDATE_CURRENT}
label={`${t('publish.majorVersion')} (${nextMajorVersionString})`}
id="update-type-major"
value={VersionUpdateType.MAJOR}
/>
)}
</Form.RadioGroup>
</>
)}
{user?.superuser && (
<Form.Group.Radio
onClick={handleVersionUpdateTypeChange}
name="update-type"
label={t('publish.updateCurrentVersion')}
id="update-type-current"
// TODO: Remove disabled when JSVersionUpdateType.UPDATE_CURRENT is available in js-dataverse
disabled={true}
value={VersionUpdateType.UPDATE_CURRENT}
/>
)}
</Form.RadioGroup>
</>
)}
</Stack>
<span className={styles.errorText}>
{submissionStatus === SubmissionStatus.Errored &&
`${t('publish.error')} ${publishError ? publishError : ''}`}
Expand Down
39 changes: 0 additions & 39 deletions src/sections/dataset/publish-dataset/useGetVersionLabels.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export const Default: Story = {
repository={new DatasetMockRepository()}
persistentId={'test'}
releasedVersionExists={false}
nextMinorVersion={undefined}
nextMajorVersion={undefined}
handleClose={() => {}}></PublishDatasetModal>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ describe('Dataset', () => {
})
})

it.only('successfully loads the files tab with files', () => {
it('successfully loads the files tab with files', () => {
cy.wrap(DatasetHelper.createWithFiles(FileHelper.createMany(3)), { timeout: 5000 })
.its('persistentId')
.then((persistentId: string) => {
Expand Down

0 comments on commit 89bf3e3

Please sign in to comment.