diff --git a/CHANGELOG.md b/CHANGELOG.md index a05833c16..d39576ff8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ This changelog follows the principles of [Keep a Changelog](https://keepachangel - Add word-break to items text to prevent layout issues when long descriptions without spaces are entered. (#839) - Show toast notification when API token is copied to clipboard. +- Dataset versions: (1) file changes should be `Access: Restricted` instead of `isResticted: true/false`; (2) logic of View Detail button. (#879) +- File versions: (1) logic of linking to a file version; (2)If file not included, show text information "File not included in this version.". (#879) ### Removed diff --git a/public/locales/en/dataset.json b/public/locales/en/dataset.json index c8dcdfacd..4c3057f17 100644 --- a/public/locales/en/dataset.json +++ b/public/locales/en/dataset.json @@ -257,7 +257,6 @@ "type": "Type", "description": "Description", "access": "Access", - "needTwoVersions": "Please select two versions to view the differences.", "viewDetails": "View Details", "fileReplaced": "File Replaced", "termsOfUseandAccess": "Terms of Use/Access", @@ -270,6 +269,8 @@ "firstDraft": "This is a draft version.", "versionDeaccessioned": "Deaccessioned Reason: The research article has been retracted.", "previousVersionDeaccessioned": "Due to the previous version being deaccessioned, there are no difference notes available for this published version.", + "thisIsADraftVersion": "This is a draft version.", + "noVersionDifferences": "There are no differences between version {{oldVersion}} and version {{newVersion}}.", "citationMetadata": { "changed": "Changed", "added": "{{count}} Added" @@ -283,7 +284,7 @@ "added": "Added: {{count}}", "removed": "Removed: {{count}}", "replaced": "Replaced: {{count}}", - "fileMetadataChanged": "File Metadata Changed: {{count}}", + "fileMetadataChanged": "Metadata Changed: {{count}}", "variableMetadataChanged": "Variable Metadata Changed: {{count}}" }, "termsAccessChanged": "Changed" diff --git a/public/locales/en/file.json b/public/locales/en/file.json index 1e26c3414..c08a349a8 100644 --- a/public/locales/en/file.json +++ b/public/locales/en/file.json @@ -12,6 +12,7 @@ "summary": "Summary", "contributors": "Contributors", "noChange": "No changes associated with this version.", + "noVersions": "File not included in this version.", "file": "file", "fileChanged": "[File {{name}}]", "access": "File Access", @@ -28,7 +29,6 @@ }, "error": "Error on loading file versions" }, - "fileNotChange": "No changes associated with this version", "subtext": "This file is part of \"{{datasetTitle}}\".", "datasetCitationTitle": "Dataset Citation", "fileCitationTitle": "File Citation", diff --git a/src/files/domain/models/File.ts b/src/files/domain/models/File.ts index eee4af473..934a44635 100644 --- a/src/files/domain/models/File.ts +++ b/src/files/domain/models/File.ts @@ -4,7 +4,7 @@ import { FileAccess } from './FileAccess' import { FilePermissions } from './FilePermissions' import { FileIngest } from './FileIngest' import { UpwardHierarchyNode } from '../../../shared/hierarchy/domain/models/UpwardHierarchyNode' -import { FileVersionSummaryInfo } from './FileVersionSummaryInfo' +import { FileVersionSummarySubset } from './FileVersionSummaryInfo' export interface File { id: number @@ -17,5 +17,5 @@ export interface File { permissions: FilePermissions metadata: FileMetadata ingest: FileIngest - fileVersionSummaries?: FileVersionSummaryInfo[] + fileVersionSummaries?: FileVersionSummarySubset } diff --git a/src/files/domain/models/FileVersionSummaryInfo.ts b/src/files/domain/models/FileVersionSummaryInfo.ts index 9c128ad04..064671c54 100644 --- a/src/files/domain/models/FileVersionSummaryInfo.ts +++ b/src/files/domain/models/FileVersionSummaryInfo.ts @@ -17,6 +17,7 @@ export interface FileVersionSummaryInfo { } export type FileDifferenceSummary = { + datafileId?: number file?: FileChangeType fileAccess?: 'Restricted' | 'Unrestricted' fileMetadata?: FileMetadataChange[] diff --git a/src/sections/dataset/dataset-versions/DatasetVersions.tsx b/src/sections/dataset/dataset-versions/DatasetVersions.tsx index 95ea2faef..271144053 100644 --- a/src/sections/dataset/dataset-versions/DatasetVersions.tsx +++ b/src/sections/dataset/dataset-versions/DatasetVersions.tsx @@ -26,6 +26,11 @@ interface DatasetVersionsProps { isCurrentVersionDeaccessioned?: boolean } +const isVersionDeaccessioned = (version: DatasetVersionSummaryInfo) => + typeof version.summary === 'object' && + version.summary !== null && + 'deaccessioned' in version.summary + export function DatasetVersions({ datasetRepository, datasetId, @@ -61,12 +66,7 @@ export function DatasetVersions({ const selectableVersions = datasetVersionSummaries && - datasetVersionSummaries.filter((version) => { - const summary = version.summary - const isDeaccessioned = - typeof summary === 'object' && summary !== null && 'deaccessioned' in summary - return !isDeaccessioned - }) + datasetVersionSummaries.filter((version) => !isVersionDeaccessioned(version)) const isCheckBoxValid = (selectableVersions?.length ?? 0) > 2 useEffect(() => { @@ -111,23 +111,19 @@ export function DatasetVersions({ {datasetVersionSummaries?.map((dataset, index) => { - const previousVersion = - index < datasetVersionSummaries.length - 1 - ? datasetVersionSummaries[index + 1] - : null - - const isPreviousVersionDeaccessioned = - previousVersion && - typeof previousVersion.summary === 'object' && - previousVersion.summary !== null && - 'deaccessioned' in previousVersion.summary + const findLastNonDeaccessionedPreviousVersion = () => { + for (let i = index + 1; i < datasetVersionSummaries.length; i++) { + const version = datasetVersionSummaries[i] + if (!isVersionDeaccessioned(version)) { + return version + } + } + return null + } + const previousVersion = findLastNonDeaccessionedPreviousVersion() const isCurrentVersion = dataset.versionNumber === currentVersionNumber - - const isCurrentVersionDeaccessioned = - typeof dataset.summary === 'object' && - dataset.summary !== null && - 'deaccessioned' in dataset.summary + const isCurrentVersionDeaccessioned = isVersionDeaccessioned(dataset) const isLinkable = (dataset.versionNumber !== DatasetVersionState.DRAFT && @@ -135,12 +131,7 @@ export function DatasetVersions({ ((dataset.versionNumber === DatasetVersionState.DRAFT || isCurrentVersionDeaccessioned) && canUpdateDataset) - - const showViewDetails = - previousVersion && - typeof dataset.summary !== 'string' && - !isCurrentVersionDeaccessioned && - !isPreviousVersionDeaccessioned + const showViewDetails = !isCurrentVersionDeaccessioned && previousVersion return ( @@ -172,7 +163,10 @@ export function DatasetVersions({

- + {showViewDetails && ( { } export const SummaryDescription = ({ - summary + summary, + versionNumber }: { summary?: DatasetVersionSummary | DatasetVersionSummaryStringValues + versionNumber?: string }) => { - const summaryText: Record = useDatasetVersionSummaryDescription(summary) + const { t } = useTranslation('dataset') + const summaryText: Record = useDatasetVersionSummaryDescription( + summary, + versionNumber + ) return ( <> {Object.entries(summaryText).map(([key, value]) => typeof summary === 'string' ? ( {value} + ) : key === t('versions.deaccessionedReason') ? ( + + {key}: {value} + ) : ( - {key}: {key == 'Files' ? {value} : value};  + {key}: {key === 'Files' ? {value} : value};  ) )} diff --git a/src/sections/dataset/dataset-versions/DatasetViewDetailButton.tsx b/src/sections/dataset/dataset-versions/DatasetViewDetailButton.tsx index 6f43e0e9b..d8de7bbec 100644 --- a/src/sections/dataset/dataset-versions/DatasetViewDetailButton.tsx +++ b/src/sections/dataset/dataset-versions/DatasetViewDetailButton.tsx @@ -26,6 +26,17 @@ export function DatasetViewDetailButton({ newVersion: newVersionNumber }) + if (!differences) { + return ( + + {t('datasetVersionSummary.noVersionDifferences', { + oldVersion: oldVersionNumber, + newVersion: newVersionNumber + })} + + ) + } + return ( <>