Skip to content

Commit

Permalink
Revert "Merge branch 'develop' into 506-api-token-section-read-curren…
Browse files Browse the repository at this point in the history
…t-api-token-integration"

This reverts commit b7d5a4d, reversing
changes made to 1d8d8f7.
  • Loading branch information
ChengShi-1 committed Oct 16, 2024
1 parent b7d5a4d commit 912a055
Show file tree
Hide file tree
Showing 28 changed files with 72 additions and 342 deletions.
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"dependencies": {
"@faker-js/faker": "7.6.0",
"@iqss/dataverse-client-javascript": "2.0.0-alpha.2",
"@iqss/dataverse-client-javascript": "2.0.0-alpha.1",
"@iqss/dataverse-design-system": "*",
"@istanbuljs/nyc-config-typescript": "1.0.2",
"@tanstack/react-table": "8.9.2",
Expand Down
4 changes: 2 additions & 2 deletions public/locales/en/dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@
"publish": {
"draftQuestion": "Are you sure you want to publish this dataset? Once you do so, it must remain public.",
"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?",
"termsText": "To publish with custom Terms of Use, click the Cancel button and go to the Terms tab for this dataset.",
"termsText1": "By default datasets are published with the CC0-\"Public Domain Dedication\" waiver. Learn more about the CC0 waiver <a href=\"{{cc0Link}}\">here</a>: ",
"termsText2": "To publish with custom Terms of Use, 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",
"cancelButton": "Cancel",
Expand Down
1 change: 0 additions & 1 deletion src/collection/domain/repositories/CollectionRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export interface CollectionRepository {
create(collection: CollectionDTO, hostCollection?: string): Promise<number>
getFacets(collectionIdOrAlias: number | string): Promise<CollectionFacet[]>
getUserPermissions(collectionIdOrAlias: number | string): Promise<CollectionUserPermissions>
publish(collectionIdOrAlias: number | string): Promise<void>
getItems(
collectionId: string,
paginationInfo: CollectionItemsPaginationInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export class JSCollectionMapper {
id,
undefined,
undefined,
undefined,
JSUpwardHierarchyNodeMapper.toUpwardHierarchyNode(jsUpwardHierarchyNode)
)
}
Expand Down
7 changes: 0 additions & 7 deletions src/dataset/domain/models/Dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,6 @@ export class Dataset {
return this.locks.some((lock) => lock.reason === DatasetLockReason.WORKFLOW)
}

public get parentCollectionNode(): UpwardHierarchyNode {
return this.hierarchy
.toArray()
.filter((item) => item.type === 'collection')
.at(-1) as UpwardHierarchyNode
}

public checkIsLockedFromEdits(userPersistentId: string): boolean {
const lockedReasonIsInReview = this.locks.some(
(lock) => lock.reason === DatasetLockReason.IN_REVIEW
Expand Down
1 change: 0 additions & 1 deletion src/dataset/infrastructure/mappers/JSDatasetMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ export class JSDatasetMapper {
id.toString(),
persistentId,
version.number.toString(),
undefined,
JSUpwardHierarchyNodeMapper.toUpwardHierarchyNode(jsUpwardHierarchyNode)
)
}
Expand Down
1 change: 0 additions & 1 deletion src/files/infrastructure/mappers/JSFileMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export class JSFileMapper {
id.toString(),
undefined,
undefined,
undefined,
JSUpwardHierarchyNodeMapper.toUpwardHierarchyNode(jsUpwardHierarchyNode)
)
}
Expand Down
10 changes: 1 addition & 9 deletions src/sections/dataset/Dataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ import useCheckPublishCompleted from './useCheckPublishCompleted'
import useUpdateDatasetAlerts from './useUpdateDatasetAlerts'
import { QueryParamKey, Route } from '../Route.enum'
import { MetadataBlockInfoRepository } from '../../metadata-block-info/domain/repositories/MetadataBlockInfoRepository'
import { CollectionRepository } from '../../collection/domain/repositories/CollectionRepository'

interface DatasetProps {
datasetRepository: DatasetRepository
fileRepository: FileRepository
metadataBlockInfoRepository: MetadataBlockInfoRepository
collectionRepository: CollectionRepository
created?: boolean
metadataUpdated?: boolean
filesTabInfiniteScrollEnabled?: boolean
Expand All @@ -42,7 +40,6 @@ export function Dataset({
datasetRepository,
fileRepository,
metadataBlockInfoRepository,
collectionRepository,
created,
metadataUpdated,
filesTabInfiniteScrollEnabled,
Expand All @@ -54,7 +51,6 @@ export function Dataset({
const navigate = useNavigate()
const { hideModal, isModalOpen } = useNotImplementedModal()
const publishCompleted = useCheckPublishCompleted(publishInProgress, dataset, datasetRepository)

useUpdateDatasetAlerts({
dataset,
created,
Expand Down Expand Up @@ -106,11 +102,7 @@ export function Dataset({
<DatasetCitation thumbnail={dataset.thumbnail} version={dataset.version} />
</Col>
<Col sm={3}>
<DatasetActionButtons
datasetRepository={datasetRepository}
collectionRepository={collectionRepository}
dataset={dataset}
/>
<DatasetActionButtons datasetRepository={datasetRepository} dataset={dataset} />
</Col>
</Row>
<Row>
Expand Down
4 changes: 0 additions & 4 deletions src/sections/dataset/DatasetFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import { NotImplementedModalProvider } from '../not-implemented/NotImplementedMo
import { AlertProvider } from '../alerts/AlertProvider'
import { searchParamVersionToDomainVersion } from '../../router'
import { FILES_TAB_INFINITE_SCROLL_ENABLED } from './config'
import { CollectionJSDataverseRepository } from '@/collection/infrastructure/repositories/CollectionJSDataverseRepository'

const collectionRepository = new CollectionJSDataverseRepository()
const datasetRepository = new DatasetJSDataverseRepository()
const fileRepository = new FileJSDataverseRepository()
const metadataBlockInfoRepository = new MetadataBlockInfoJSDataverseRepository()
Expand Down Expand Up @@ -68,7 +66,6 @@ function DatasetWithSearchParams() {
searchParams={{ privateUrlToken: privateUrlToken }}
isPublishing={publishInProgress}>
<Dataset
collectionRepository={collectionRepository}
datasetRepository={datasetRepository}
fileRepository={fileRepository}
metadataBlockInfoRepository={metadataBlockInfoRepository}
Expand All @@ -84,7 +81,6 @@ function DatasetWithSearchParams() {
searchParams={{ persistentId: persistentId, version: version }}
isPublishing={publishInProgress}>
<Dataset
collectionRepository={collectionRepository}
datasetRepository={datasetRepository}
fileRepository={fileRepository}
metadataBlockInfoRepository={metadataBlockInfoRepository}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@ import { EditDatasetMenu } from './edit-dataset-menu/EditDatasetMenu'
import { LinkDatasetButton } from './link-dataset-button/LinkDatasetButton'
import { useTranslation } from 'react-i18next'
import { DatasetRepository } from '../../../dataset/domain/repositories/DatasetRepository'
import { CollectionRepository } from '../../../collection/domain/repositories/CollectionRepository'

interface DatasetActionButtonsProps {
dataset: Dataset
datasetRepository: DatasetRepository
collectionRepository: CollectionRepository
}

export function DatasetActionButtons({
dataset,
datasetRepository,
collectionRepository
}: DatasetActionButtonsProps) {
export function DatasetActionButtons({ dataset, datasetRepository }: DatasetActionButtonsProps) {
const { t } = useTranslation('dataset')
return (
<ButtonGroup aria-label={t('datasetActionButtons.title')} vertical className={styles.group}>
Expand All @@ -31,11 +25,7 @@ export function DatasetActionButtons({
fileDownloadSizes={dataset.fileDownloadSizes}
downloadUrls={dataset.downloadUrls}
/>
<PublishDatasetMenu
dataset={dataset}
datasetRepository={datasetRepository}
collectionRepository={collectionRepository}
/>
<PublishDatasetMenu dataset={dataset} datasetRepository={datasetRepository} />
<SubmitForReviewButton dataset={dataset} />
<EditDatasetMenu dataset={dataset} />
<LinkDatasetButton dataset={dataset} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,13 @@ import { DatasetRepository } from '../../../../dataset/domain/repositories/Datas
import { Dataset, DatasetPublishingStatus } from '../../../../dataset/domain/models/Dataset'
import { ChangeCurationStatusMenu } from './ChangeCurationStatusMenu'
import { PublishDatasetModal } from '../../publish-dataset/PublishDatasetModal'
import { CollectionRepository } from '../../../../collection/domain/repositories/CollectionRepository'

interface PublishDatasetMenuProps {
dataset: Dataset
datasetRepository: DatasetRepository
collectionRepository: CollectionRepository
}

export function PublishDatasetMenu({
dataset,
datasetRepository,
collectionRepository
}: PublishDatasetMenuProps) {
export function PublishDatasetMenu({ dataset, datasetRepository }: PublishDatasetMenuProps) {
const { user } = useSession()
const { t } = useTranslation('dataset')
const [showModal, setShowModal] = useState(false)
Expand All @@ -42,8 +36,6 @@ export function PublishDatasetMenu({
<PublishDatasetModal
show={showModal}
repository={datasetRepository}
collectionRepository={collectionRepository}
parentCollection={dataset.parentCollectionNode}
persistentId={dataset.persistentId}
releasedVersionExists={dataset.version.someDatasetVersionHasBeenReleased}
nextMajorVersion={dataset.nextMajorVersion}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
@import "node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module";

.container {
padding: 10px;
background-color: $dv-info-box-color;
border: 1px solid black;
}

.warningText {
margin-bottom: 0;
Expand Down
58 changes: 17 additions & 41 deletions src/sections/dataset/publish-dataset/PublishDatasetHelpText.tsx
Original file line number Diff line number Diff line change
@@ -1,52 +1,28 @@
import { useTranslation, Trans } from 'react-i18next'
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'

interface PublishDatasetHelpTextProps {
releasedVersionExists: boolean
parentCollectionIsReleased: boolean | undefined
parentCollectionName: string
parentCollectionId: string
}

function getWarningTextKey(
releasedVersionExists: boolean,
parentCollectionIsReleased: boolean | undefined
): string {
if (!releasedVersionExists) {
if (!parentCollectionIsReleased) {
return 'publish.releaseCollectionQuestion'
} else return 'publish.draftQuestion'
}
return 'publish.previouslyReleasedQuestion'
}

export function PublishDatasetHelpText({
releasedVersionExists,
parentCollectionIsReleased,
parentCollectionName,
parentCollectionId
}: PublishDatasetHelpTextProps) {
export function PublishDatasetHelpText({ releasedVersionExists }: PublishDatasetHelpTextProps) {
const { t } = useTranslation('dataset')
const warningText = getWarningTextKey(releasedVersionExists, parentCollectionIsReleased)

const cc0Link = 'https://creativecommons.org/publicdomain/zero/1.0/'
return (
<Stack direction="vertical">
<p className={styles.warningText}>
{!parentCollectionIsReleased ? (
<Trans
t={t}
i18nKey={warningText}
values={{ parentCollectionName }}
components={{ a: <Link to={RouteWithParams.COLLECTIONS(parentCollectionId)} /> }}
/>
) : (
<>{t(warningText)}</>
)}
</p>
<p>{t('publish.termsText')}</p>
</Stack>
<>
{!releasedVersionExists && <p className={styles.warningText}>{t('publish.draftQuestion')}</p>}
{releasedVersionExists && (
<p className={styles.warningText}>{t('publish.previouslyReleasedQuestion')}</p>
)}
<div className={styles.container}>
<Trans
t={t}
i18nKey="publish.termsText1"
values={{ cc0Link }}
components={{ a: <a href={cc0Link} /> }}
/>
<p>{t('publish.termsText2')}</p>
</div>
</>
)
}
22 changes: 4 additions & 18 deletions src/sections/dataset/publish-dataset/PublishDatasetModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,24 @@ import { useState } from 'react'
import { useTranslation } from 'react-i18next'
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'
import type { DatasetRepository } from '../../../dataset/domain/repositories/DatasetRepository'
import { VersionUpdateType } from '../../../dataset/domain/models/VersionUpdateType'
import { useSession } from '../../session/SessionContext'
import { License } from '../dataset-summary/License'
import {
DatasetNonNumericVersionSearchParam,
defaultLicense
} from '@/dataset/domain/models/Dataset'
} from '../../../dataset/domain/models/Dataset'
import { SubmissionStatus } from '../../shared/form/DatasetMetadataForm/useSubmitDataset'
import { usePublishDataset } from './usePublishDataset'
import { PublishDatasetHelpText } from './PublishDatasetHelpText'
import styles from './PublishDatasetModal.module.scss'
import { useNavigate } from 'react-router-dom'
import { QueryParamKey, Route } from '../../Route.enum'
import { CollectionRepository } from '@/collection/domain/repositories/CollectionRepository'
import { UpwardHierarchyNode } from '@/shared/hierarchy/domain/models/UpwardHierarchyNode'

interface PublishDatasetModalProps {
show: boolean
repository: DatasetRepository
collectionRepository: CollectionRepository
parentCollection: UpwardHierarchyNode
persistentId: string
releasedVersionExists: boolean
handleClose: () => void
Expand All @@ -34,8 +30,6 @@ interface PublishDatasetModalProps {
export function PublishDatasetModal({
show,
repository,
collectionRepository,
parentCollection,
persistentId,
releasedVersionExists,
handleClose,
Expand All @@ -45,11 +39,8 @@ export function PublishDatasetModal({
const { t } = useTranslation('dataset')
const { user } = useSession()
const navigate = useNavigate()

const { submissionStatus, submitPublish, publishError } = usePublishDataset(
repository,
collectionRepository,
parentCollection,
persistentId,
onPublishSucceed
)
Expand Down Expand Up @@ -80,12 +71,7 @@ export function PublishDatasetModal({
</Modal.Header>
<Modal.Body>
<Stack direction="vertical">
<PublishDatasetHelpText
releasedVersionExists={releasedVersionExists}
parentCollectionIsReleased={parentCollection.isReleased}
parentCollectionName={parentCollection.name}
parentCollectionId={parentCollection.id}
/>
<PublishDatasetHelpText releasedVersionExists={releasedVersionExists} />
<License
license={{
name: defaultLicense.name,
Expand Down
Loading

0 comments on commit 912a055

Please sign in to comment.