From b758da13fabd1561ea90ef5c61c705c6356e3640 Mon Sep 17 00:00:00 2001 From: Cheng Shi Date: Mon, 27 Oct 2025 16:49:38 -0400 Subject: [PATCH 1/7] fix: summaries version tab --- public/locales/en/dataset.json | 2 +- public/locales/en/file.json | 1 + .../domain/models/FileVersionSummaryInfo.ts | 1 + .../dataset-versions/DatasetVersions.tsx | 45 +++++++------- .../DatasetVersionsDifferenceTable.tsx | 17 ++++- .../file/file-version/FileVersions.tsx | 43 ++++++++++--- .../useFileVersionSummaryDescription.tsx | 4 +- .../dataset-versions/DatasetVersions.spec.tsx | 48 ++++++++++++++ ...tasetVersionsViewDifferencesModal.spec.tsx | 34 ++++++++++ ...eDatasetVersionSummaryDescription.spec.tsx | 4 +- .../file/file-version/FileVersions.spec.tsx | 62 +++++++++++++++++++ .../useFileVersionSummaryDescription.spec.tsx | 8 --- 12 files changed, 224 insertions(+), 45 deletions(-) diff --git a/public/locales/en/dataset.json b/public/locales/en/dataset.json index 8353e0254..21abfb1b6 100644 --- a/public/locales/en/dataset.json +++ b/public/locales/en/dataset.json @@ -283,7 +283,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..234ebd64f 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", diff --git a/src/files/domain/models/FileVersionSummaryInfo.ts b/src/files/domain/models/FileVersionSummaryInfo.ts index caca9ed50..d313ccbd0 100644 --- a/src/files/domain/models/FileVersionSummaryInfo.ts +++ b/src/files/domain/models/FileVersionSummaryInfo.ts @@ -12,6 +12,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..ba67912cd 100644 --- a/src/sections/dataset/dataset-versions/DatasetVersions.tsx +++ b/src/sections/dataset/dataset-versions/DatasetVersions.tsx @@ -111,23 +111,26 @@ export function DatasetVersions({ {datasetVersionSummaries?.map((dataset, index) => { - const previousVersion = - index < datasetVersionSummaries.length - 1 - ? datasetVersionSummaries[index + 1] - : null + // Helper function to check if a version is deaccessioned + const isVersionDeaccessioned = (version: DatasetVersionSummaryInfo) => + typeof version.summary === 'object' && + version.summary !== null && + 'deaccessioned' in version.summary - const isPreviousVersionDeaccessioned = - previousVersion && - typeof previousVersion.summary === 'object' && - previousVersion.summary !== null && - 'deaccessioned' in previousVersion.summary + // Find the last non-deaccessioned previous version + 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 +138,7 @@ export function DatasetVersions({ ((dataset.versionNumber === DatasetVersionState.DRAFT || isCurrentVersionDeaccessioned) && canUpdateDataset) - - const showViewDetails = - previousVersion && - typeof dataset.summary !== 'string' && - !isCurrentVersionDeaccessioned && - !isPreviousVersionDeaccessioned + const showViewDetails = !isCurrentVersionDeaccessioned && previousVersion return ( @@ -173,7 +171,7 @@ export function DatasetVersions({

- {showViewDetails && ( + {showViewDetails && previousVersion && ( { + const { t } = useTranslation('dataset') const summaryText: Record = useDatasetVersionSummaryDescription(summary) return ( @@ -255,6 +254,10 @@ export const SummaryDescription = ({ {Object.entries(summaryText).map(([key, value]) => typeof summary === 'string' ? ( {value} + ) : key === t('versions.deaccessionedReason') ? ( + + {key}: {value} + ) : ( {key}: {key == 'Files' ? {value} : value};  diff --git a/src/sections/dataset/dataset-versions/view-difference/DatasetVersionsDifferenceTable.tsx b/src/sections/dataset/dataset-versions/view-difference/DatasetVersionsDifferenceTable.tsx index bf2a32686..09b18b127 100644 --- a/src/sections/dataset/dataset-versions/view-difference/DatasetVersionsDifferenceTable.tsx +++ b/src/sections/dataset/dataset-versions/view-difference/DatasetVersionsDifferenceTable.tsx @@ -12,6 +12,7 @@ export const DatasetVersionsDifferenceTable = ({ differences }: datasetVersionsDifferenceTableProps) => { const { t } = useTranslation('dataset') + const { t: tFile } = useTranslation('file') const { oldVersion, newVersion, @@ -129,14 +130,26 @@ export const DatasetVersionsDifferenceTable = ({ {file.changed.map((change) => (

- {change.fieldName}: {change.oldValue || ''} + {change.fieldName === 'isRestricted' + ? `${t('versions.access')}: ${ + change.oldValue === 'true' + ? tFile('fileAccess.restricted.name') + : tFile('fileAccess.public.name') + }` + : `${change.fieldName}: ${change.oldValue || ''}`}
))} {file.changed.map((change) => (
- {change.fieldName}: {change.newValue || ''} + {change.fieldName === 'isRestricted' + ? `${t('versions.access')}: ${ + change.newValue === 'true' + ? tFile('fileAccess.restricted.name') + : tFile('fileAccess.public.name') + }` + : `${change.fieldName}: ${change.newValue || ''}`}
))} diff --git a/src/sections/file/file-version/FileVersions.tsx b/src/sections/file/file-version/FileVersions.tsx index 88c5b2233..4796dc3ce 100644 --- a/src/sections/file/file-version/FileVersions.tsx +++ b/src/sections/file/file-version/FileVersions.tsx @@ -75,11 +75,23 @@ export function FileVersions({ {fileVersionSummaries?.map((fileVersion) => { const isCurrentVersion = fileVersion.datasetVersion === displayVersion + // Helper functions for readability + const hasDataFile = fileVersion.datafileId + const hasSummaryChanges = + fileVersion.fileDifferenceSummary !== undefined && + Object.entries(fileVersion.fileDifferenceSummary).length > 0 + const isReleased = fileVersion.versionState === DatasetVersionState.RELEASED + const isDeaccessionedWithAccess = + fileVersion.versionState === DatasetVersionState.DEACCESSIONED && canEditOwnerDataset + const isDraftWithAccess = + fileVersion.versionState === DatasetVersionState.DRAFT && canEditOwnerDataset + const isLinkable = - fileVersion.versionState === DatasetVersionState.RELEASED || - (fileVersion.versionState === DatasetVersionState.DEACCESSIONED && - canEditOwnerDataset) || - (fileVersion.versionState === DatasetVersionState.DRAFT && canEditOwnerDataset) + hasDataFile && + hasSummaryChanges && + (isReleased || isDeaccessionedWithAccess || isDraftWithAccess) + + console.log('fileVersion', fileVersion, isLinkable) return ( @@ -98,7 +110,10 @@ export function FileVersions({ - + {fileVersion.contributors} {fileVersion.publishedDate && @@ -116,7 +131,13 @@ export function FileVersions({ ) } -export const SummaryDescription = ({ summary }: { summary?: FileDifferenceSummary }) => { +export const SummaryDescription = ({ + summary, + isNoVersions +}: { + summary?: FileDifferenceSummary + isNoVersions?: boolean +}) => { const summaryText: Record | string = useFileVersionSummaryDescription(summary) const { t } = useTranslation('file') @@ -124,10 +145,18 @@ export const SummaryDescription = ({ summary }: { summary?: FileDifferenceSummar return {summaryText} } + if (isNoVersions) { + return {t('fileVersion.noVersions')} + } + + if (!summary || !Object.entries(summary).length) { + return {t('fileVersion.noChange')} + } + if (summaryText[t('fileVersion.deaccessionedReason')]) { return ( - Deaccessioned Reason: {summaryText[t('fileVersion.deaccessionedReason')]} + {t('fileVersion.deaccessionedReason')}: {summaryText[t('fileVersion.deaccessionedReason')]} ) } diff --git a/src/sections/file/file-version/useFileVersionSummaryDescription.tsx b/src/sections/file/file-version/useFileVersionSummaryDescription.tsx index 51533b7e5..e22bb8b6a 100644 --- a/src/sections/file/file-version/useFileVersionSummaryDescription.tsx +++ b/src/sections/file/file-version/useFileVersionSummaryDescription.tsx @@ -10,11 +10,9 @@ export const useFileVersionSummaryDescription = ( ): Record | string => { const { t } = useTranslation('file') - if (!summary || !Object.entries(summary).length) return t('fileVersion.noChange') - const description: Record = {} - Object.entries(summary).forEach(([key, value]) => { + Object.entries(summary ?? {}).forEach(([key, value]) => { switch (key) { case 'file': { if ((value as FileChangeType) && typeof value === 'string') { diff --git a/tests/component/sections/dataset/dataset-versions/DatasetVersions.spec.tsx b/tests/component/sections/dataset/dataset-versions/DatasetVersions.spec.tsx index ece0e1b2a..239f5c178 100644 --- a/tests/component/sections/dataset/dataset-versions/DatasetVersions.spec.tsx +++ b/tests/component/sections/dataset/dataset-versions/DatasetVersions.spec.tsx @@ -35,6 +35,8 @@ const versionSummaryInfoDraft: DatasetVersionSummaryInfo[] = [ publishedOn: '' } ] +const versionSummaryInfoDeaccessioned = DatasetVersionsSummariesMother.createDeaccessioned() + const datasetVersionDiff: DatasetVersionDiff = DatasetVersionDiffMother.create() describe('DatasetVersions', () => { @@ -54,6 +56,52 @@ describe('DatasetVersions', () => { cy.findByText('DRAFT').should('exist').and('have.attr', 'href') }) + it('should not show view detail buttons if the version is deaccessioned', () => { + cy.customMount( + + ) + datasetsRepository.getDatasetVersionsSummaries = cy + .stub() + .resolves(versionSummaryInfoDeaccessioned) + + cy.findByTestId('dataset-versions-table').should('exist') + cy.get('tr').eq(1).find('td').eq(2).findByText('View Details').should('not.exist') + }) + + it('should show view detail buttons if previous version is deaccessioned', () => { + cy.customMount( + + ) + const versionSummaryInfoNoPreviousVersion = [ + { + id: 12, + versionNumber: '5.0', + summary: {}, + contributors: 'Test ', + publishedOn: '' + }, + ...versionSummaryInfoDeaccessioned + ] + datasetsRepository.getDatasetVersionsSummaries = cy + .stub() + .resolves(versionSummaryInfoNoPreviousVersion) + + cy.findByTestId('dataset-versions-table').should('exist') + cy.get('tr').eq(1).find('td').eq(2).findByText('View Details').should('exist') + }) + beforeEach(() => { cy.customMount( { cy.findByTestId(`file-replaced-row-${file.newFile.fileId}`).should('exist') }) }) + + it('should show Access Granted for restricted files', () => { + cy.customMount( + {}} + isLoading={false} + errorHandling={''} + datasetVersionDifferences={{ + ...datasetVersionDiff, + fileChanges: [ + { + fileName: 'blob (2)', + md5: '53d3d10e00812f7c55e0c9c3935f3769', + fileId: 40, + changed: [ + { + fieldName: 'isRestricted', + oldValue: 'false', + newValue: 'true' + } + ] + } + ] + }} + /> + ) + + cy.findByTestId(`file-changed-row-40`).find('td').eq(1).should('have.text', 'Access: Public') + cy.findByTestId(`file-changed-row-40`) + .find('td') + .eq(2) + .should('have.text', 'Access: Restricted') + }) }) diff --git a/tests/component/sections/dataset/dataset-versions/useDatasetVersionSummaryDescription.spec.tsx b/tests/component/sections/dataset/dataset-versions/useDatasetVersionSummaryDescription.spec.tsx index 7f204d7ff..ec76ea230 100644 --- a/tests/component/sections/dataset/dataset-versions/useDatasetVersionSummaryDescription.spec.tsx +++ b/tests/component/sections/dataset/dataset-versions/useDatasetVersionSummaryDescription.spec.tsx @@ -29,9 +29,7 @@ describe('useDatasetVersionSummaryDescription', () => { expect(result.current) .haveOwnProperty('Files') - .equal( - 'Added: 2; Removed: 1; Replaced: 1; File Metadata Changed: 3; Variable Metadata Changed: 1' - ) + .equal('Added: 2; Removed: 1; Replaced: 1; Metadata Changed: 3; Variable Metadata Changed: 1') expect(result.current) .haveOwnProperty('Citation Metadata') .equal('Description (Changed); Title (1 Added)') diff --git a/tests/component/sections/file/file-version/FileVersions.spec.tsx b/tests/component/sections/file/file-version/FileVersions.spec.tsx index e5a80cd82..abac21b38 100644 --- a/tests/component/sections/file/file-version/FileVersions.spec.tsx +++ b/tests/component/sections/file/file-version/FileVersions.spec.tsx @@ -112,6 +112,38 @@ describe('FileVersions', () => { cy.get('span').contains('DRAFT').should('exist') }) + it('disables the link button for version without datafileId', () => { + const file = [{ ...fileVersionSummaries[0], datafileId: undefined }] + fileRepository.getFileVersionSummaries = cy.stub().resolves(file) + cy.customMount( + + ) + cy.findByText('2.0').should('exist') + cy.findByTestId('file-version-link-2.0').should('not.exist') + }) + + it('disables the link button for version with empty fileDifferenceSummary', () => { + const file = [{ ...fileVersionSummaries[0], fileDifferenceSummary: {}, datafileId: 1 }] + fileRepository.getFileVersionSummaries = cy.stub().resolves(file) + cy.customMount( + + ) + cy.findByText('2.0').should('exist') + cy.findByTestId('file-version-link-2.0').should('not.exist') + }) + it('the version number should be disable and bold if it is the current version', () => { const currentFile = [{ ...fileVersionSummaries[0], datasetVersion: '2.0' }] @@ -127,4 +159,34 @@ describe('FileVersions', () => { ) cy.get('strong').contains('2.0') }) + + it('returns correctly when summary is empty', () => { + const file = [{ ...fileVersionSummaries[0], fileDifferenceSummary: {}, datafileId: 1 }] + fileRepository.getFileVersionSummaries = cy.stub().resolves(file) + cy.customMount( + + ) + cy.findByText('No changes associated with this version.').should('exist') + }) + + it('returns correctly when datafileId is undefined', () => { + const file = [{ ...fileVersionSummaries[0], datafileId: undefined }] + fileRepository.getFileVersionSummaries = cy.stub().resolves(file) + cy.customMount( + + ) + cy.contains('No changes associated with this version.').should('exist') + }) }) diff --git a/tests/component/sections/file/file-version/useFileVersionSummaryDescription.spec.tsx b/tests/component/sections/file/file-version/useFileVersionSummaryDescription.spec.tsx index 7761e3635..25b1d8a4a 100644 --- a/tests/component/sections/file/file-version/useFileVersionSummaryDescription.spec.tsx +++ b/tests/component/sections/file/file-version/useFileVersionSummaryDescription.spec.tsx @@ -35,12 +35,4 @@ describe('useFileVersionSummaryDescription', () => { .haveOwnProperty('Deaccessioned Reason') .equal('Removed at author request') }) - - it('returns correctly when summary is empty', () => { - const summary: FileDifferenceSummary = {} - - const { result } = renderHook(() => useFileVersionSummaryDescription(summary)) - - expect(result.current).equal('No changes associated with this version.') - }) }) From 38c8531ebaee79373e5df07baa5747f64d4c3829 Mon Sep 17 00:00:00 2001 From: Cheng Shi Date: Mon, 27 Oct 2025 17:18:28 -0400 Subject: [PATCH 2/7] changelog and other fixes --- CHANGELOG.md | 2 ++ public/locales/en/file.json | 1 - .../dataset/dataset-versions/DatasetVersions.tsx | 2 -- src/sections/file/file-version/FileVersions.tsx | 9 +-------- .../sections/file/file-version/FileVersions.spec.tsx | 2 +- 5 files changed, 4 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b708bdf7..d39d887f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,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 textFile not included in this version. (#879) ### Removed diff --git a/public/locales/en/file.json b/public/locales/en/file.json index 234ebd64f..c08a349a8 100644 --- a/public/locales/en/file.json +++ b/public/locales/en/file.json @@ -29,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/sections/dataset/dataset-versions/DatasetVersions.tsx b/src/sections/dataset/dataset-versions/DatasetVersions.tsx index ba67912cd..b5124f6fb 100644 --- a/src/sections/dataset/dataset-versions/DatasetVersions.tsx +++ b/src/sections/dataset/dataset-versions/DatasetVersions.tsx @@ -111,13 +111,11 @@ export function DatasetVersions({ {datasetVersionSummaries?.map((dataset, index) => { - // Helper function to check if a version is deaccessioned const isVersionDeaccessioned = (version: DatasetVersionSummaryInfo) => typeof version.summary === 'object' && version.summary !== null && 'deaccessioned' in version.summary - // Find the last non-deaccessioned previous version const findLastNonDeaccessionedPreviousVersion = () => { for (let i = index + 1; i < datasetVersionSummaries.length; i++) { const version = datasetVersionSummaries[i] diff --git a/src/sections/file/file-version/FileVersions.tsx b/src/sections/file/file-version/FileVersions.tsx index 4796dc3ce..a06af7d33 100644 --- a/src/sections/file/file-version/FileVersions.tsx +++ b/src/sections/file/file-version/FileVersions.tsx @@ -77,9 +77,6 @@ export function FileVersions({ const isCurrentVersion = fileVersion.datasetVersion === displayVersion // Helper functions for readability const hasDataFile = fileVersion.datafileId - const hasSummaryChanges = - fileVersion.fileDifferenceSummary !== undefined && - Object.entries(fileVersion.fileDifferenceSummary).length > 0 const isReleased = fileVersion.versionState === DatasetVersionState.RELEASED const isDeaccessionedWithAccess = fileVersion.versionState === DatasetVersionState.DEACCESSIONED && canEditOwnerDataset @@ -87,11 +84,7 @@ export function FileVersions({ fileVersion.versionState === DatasetVersionState.DRAFT && canEditOwnerDataset const isLinkable = - hasDataFile && - hasSummaryChanges && - (isReleased || isDeaccessionedWithAccess || isDraftWithAccess) - - console.log('fileVersion', fileVersion, isLinkable) + hasDataFile && (isReleased || isDeaccessionedWithAccess || isDraftWithAccess) return ( diff --git a/tests/component/sections/file/file-version/FileVersions.spec.tsx b/tests/component/sections/file/file-version/FileVersions.spec.tsx index abac21b38..1d1db6007 100644 --- a/tests/component/sections/file/file-version/FileVersions.spec.tsx +++ b/tests/component/sections/file/file-version/FileVersions.spec.tsx @@ -187,6 +187,6 @@ describe('FileVersions', () => { isInView /> ) - cy.contains('No changes associated with this version.').should('exist') + cy.contains('File not included in this version.').should('exist') }) }) From 0c2cb1abd0dd4bc2e71695b29ab4117c6e6020b0 Mon Sep 17 00:00:00 2001 From: Cheng Shi Date: Mon, 3 Nov 2025 18:13:26 -0500 Subject: [PATCH 3/7] some bug fixes --- CHANGELOG.md | 2 +- .../dataset-versions/DatasetVersions.tsx | 21 +++++++------------ .../file/file-version/FileVersion.module.scss | 7 +++++++ .../file/file-version/FileVersions.tsx | 18 +++++++++------- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d39d887f5..5d6616ea8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,7 @@ 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 textFile not included in this version. (#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/src/sections/dataset/dataset-versions/DatasetVersions.tsx b/src/sections/dataset/dataset-versions/DatasetVersions.tsx index b5124f6fb..f609a8fea 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,11 +111,6 @@ export function DatasetVersions({ {datasetVersionSummaries?.map((dataset, index) => { - const isVersionDeaccessioned = (version: DatasetVersionSummaryInfo) => - typeof version.summary === 'object' && - version.summary !== null && - 'deaccessioned' in version.summary - const findLastNonDeaccessionedPreviousVersion = () => { for (let i = index + 1; i < datasetVersionSummaries.length; i++) { const version = datasetVersionSummaries[i] @@ -169,7 +164,7 @@ export function DatasetVersions({

- {showViewDetails && previousVersion && ( + {showViewDetails && ( ) : ( - {key}: {key == 'Files' ? {value} : value};  + {key}: {key === 'Files' ? {value} : value};  ) )} diff --git a/src/sections/file/file-version/FileVersion.module.scss b/src/sections/file/file-version/FileVersion.module.scss index 626da08d1..e658b3f49 100644 --- a/src/sections/file/file-version/FileVersion.module.scss +++ b/src/sections/file/file-version/FileVersion.module.scss @@ -1,3 +1,5 @@ +@import 'node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module'; + .file-versions-table { width: 100%; margin: auto; @@ -16,3 +18,8 @@ vertical-align: top; } } + +.no-summary-text { + font-style: italic; + color: $dv-subtext-color; +} \ No newline at end of file diff --git a/src/sections/file/file-version/FileVersions.tsx b/src/sections/file/file-version/FileVersions.tsx index a06af7d33..2de567658 100644 --- a/src/sections/file/file-version/FileVersions.tsx +++ b/src/sections/file/file-version/FileVersions.tsx @@ -138,15 +138,9 @@ export const SummaryDescription = ({ return {summaryText} } - if (isNoVersions) { - return {t('fileVersion.noVersions')} - } - - if (!summary || !Object.entries(summary).length) { - return {t('fileVersion.noChange')} - } + const deaccessionedReason = summaryText[t('fileVersion.deaccessionedReason')] - if (summaryText[t('fileVersion.deaccessionedReason')]) { + if (deaccessionedReason) { return ( {t('fileVersion.deaccessionedReason')}: {summaryText[t('fileVersion.deaccessionedReason')]} @@ -154,6 +148,14 @@ export const SummaryDescription = ({ ) } + if (isNoVersions) { + return {t('fileVersion.noVersions')} + } + + if (!summary || !Object.entries(summary).length) { + return {t('fileVersion.noChange')} + } + const summaryTextParts = Object.entries(summaryText).map(([key, value], index) => { const content = key === 'file' ? ( From 37436e3cb84e7918fc8ea697aa96fdce1b01020e Mon Sep 17 00:00:00 2001 From: Cheng Shi Date: Mon, 3 Nov 2025 18:20:53 -0500 Subject: [PATCH 4/7] chore: fix a lint error --- src/sections/file/file-version/FileVersion.module.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sections/file/file-version/FileVersion.module.scss b/src/sections/file/file-version/FileVersion.module.scss index e658b3f49..b1d2c9c46 100644 --- a/src/sections/file/file-version/FileVersion.module.scss +++ b/src/sections/file/file-version/FileVersion.module.scss @@ -22,4 +22,4 @@ .no-summary-text { font-style: italic; color: $dv-subtext-color; -} \ No newline at end of file +} From 3feee867f4669fcd06f8b1786bd2ff263e66d7b8 Mon Sep 17 00:00:00 2001 From: Cheng Shi Date: Wed, 12 Nov 2025 00:53:59 -0500 Subject: [PATCH 5/7] fix: review suggestions and tests --- public/locales/en/dataset.json | 3 ++- src/files/domain/models/File.ts | 4 ++-- .../dataset-versions/DatasetVersions.tsx | 14 ++++++++++--- .../DatasetViewDetailButton.tsx | 11 ++++++++++ .../useDatasetVersionSummaryDescription.tsx | 13 +++++++----- .../useGetDatasetVersionDiff.ts | 17 ++++++++++++++-- .../dataset-versions/DatasetVersions.spec.tsx | 9 +++++---- ...eDatasetVersionSummaryDescription.spec.tsx | 13 ++++++++++++ .../file/file-version/FileVersions.spec.tsx | 20 +++++++++++++++---- 9 files changed, 83 insertions(+), 21 deletions(-) diff --git a/public/locales/en/dataset.json b/public/locales/en/dataset.json index 1c8cea830..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" 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/sections/dataset/dataset-versions/DatasetVersions.tsx b/src/sections/dataset/dataset-versions/DatasetVersions.tsx index f609a8fea..271144053 100644 --- a/src/sections/dataset/dataset-versions/DatasetVersions.tsx +++ b/src/sections/dataset/dataset-versions/DatasetVersions.tsx @@ -163,7 +163,10 @@ export function DatasetVersions({

- + {showViewDetails && ( { } export const SummaryDescription = ({ - summary + summary, + versionNumber }: { summary?: DatasetVersionSummary | DatasetVersionSummaryStringValues + versionNumber?: string }) => { const { t } = useTranslation('dataset') - const summaryText: Record = useDatasetVersionSummaryDescription(summary) + const summaryText: Record = useDatasetVersionSummaryDescription( + summary, + versionNumber + ) return ( <> 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 ( <>