Skip to content

Commit 0c2cb1a

Browse files
committed
some bug fixes
1 parent 38c8531 commit 0c2cb1a

File tree

4 files changed

+26
-22
lines changed

4 files changed

+26
-22
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This changelog follows the principles of [Keep a Changelog](https://keepachangel
2323
- Add word-break to items text to prevent layout issues when long descriptions without spaces are entered. (#839)
2424
- Show toast notification when API token is copied to clipboard.
2525
- Dataset versions: (1) file changes should be `Access: Restricted` instead of `isResticted: true/false`; (2) logic of View Detail button. (#879)
26-
- File versions: (1) logic of linking to a file version; (2)If file not included, show textFile not included in this version. (#879)
26+
- 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)
2727

2828
### Removed
2929

src/sections/dataset/dataset-versions/DatasetVersions.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ interface DatasetVersionsProps {
2626
isCurrentVersionDeaccessioned?: boolean
2727
}
2828

29+
const isVersionDeaccessioned = (version: DatasetVersionSummaryInfo) =>
30+
typeof version.summary === 'object' &&
31+
version.summary !== null &&
32+
'deaccessioned' in version.summary
33+
2934
export function DatasetVersions({
3035
datasetRepository,
3136
datasetId,
@@ -61,12 +66,7 @@ export function DatasetVersions({
6166

6267
const selectableVersions =
6368
datasetVersionSummaries &&
64-
datasetVersionSummaries.filter((version) => {
65-
const summary = version.summary
66-
const isDeaccessioned =
67-
typeof summary === 'object' && summary !== null && 'deaccessioned' in summary
68-
return !isDeaccessioned
69-
})
69+
datasetVersionSummaries.filter((version) => !isVersionDeaccessioned(version))
7070
const isCheckBoxValid = (selectableVersions?.length ?? 0) > 2
7171

7272
useEffect(() => {
@@ -111,11 +111,6 @@ export function DatasetVersions({
111111
</thead>
112112
<tbody>
113113
{datasetVersionSummaries?.map((dataset, index) => {
114-
const isVersionDeaccessioned = (version: DatasetVersionSummaryInfo) =>
115-
typeof version.summary === 'object' &&
116-
version.summary !== null &&
117-
'deaccessioned' in version.summary
118-
119114
const findLastNonDeaccessionedPreviousVersion = () => {
120115
for (let i = index + 1; i < datasetVersionSummaries.length; i++) {
121116
const version = datasetVersionSummaries[i]
@@ -169,7 +164,7 @@ export function DatasetVersions({
169164
<td>
170165
<p style={{ display: 'flex', flexWrap: 'wrap', margin: 0, textAlign: 'left' }}>
171166
<SummaryDescription summary={dataset.summary} />
172-
{showViewDetails && previousVersion && (
167+
{showViewDetails && (
173168
<DatasetViewDetailButton
174169
datasetRepository={datasetRepository}
175170
oldVersionNumber={previousVersion.versionNumber}
@@ -258,7 +253,7 @@ export const SummaryDescription = ({
258253
</span>
259254
) : (
260255
<span key={key}>
261-
<strong>{key}</strong>: {key == 'Files' ? <strong>{value}</strong> : value};&nbsp;
256+
<strong>{key}</strong>: {key === 'Files' ? <strong>{value}</strong> : value};&nbsp;
262257
</span>
263258
)
264259
)}

src/sections/file/file-version/FileVersion.module.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import 'node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module';
2+
13
.file-versions-table {
24
width: 100%;
35
margin: auto;
@@ -16,3 +18,8 @@
1618
vertical-align: top;
1719
}
1820
}
21+
22+
.no-summary-text {
23+
font-style: italic;
24+
color: $dv-subtext-color;
25+
}

src/sections/file/file-version/FileVersions.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,24 @@ export const SummaryDescription = ({
138138
return <span style={{ fontStyle: 'italic' }}>{summaryText}</span>
139139
}
140140

141-
if (isNoVersions) {
142-
return <span style={{ fontStyle: 'italic' }}>{t('fileVersion.noVersions')}</span>
143-
}
144-
145-
if (!summary || !Object.entries(summary).length) {
146-
return <span style={{ fontStyle: 'italic' }}>{t('fileVersion.noChange')}</span>
147-
}
141+
const deaccessionedReason = summaryText[t('fileVersion.deaccessionedReason')]
148142

149-
if (summaryText[t('fileVersion.deaccessionedReason')]) {
143+
if (deaccessionedReason) {
150144
return (
151145
<span>
152146
{t('fileVersion.deaccessionedReason')}: {summaryText[t('fileVersion.deaccessionedReason')]}
153147
</span>
154148
)
155149
}
156150

151+
if (isNoVersions) {
152+
return <span className={styles['no-summary-text']}>{t('fileVersion.noVersions')}</span>
153+
}
154+
155+
if (!summary || !Object.entries(summary).length) {
156+
return <span className={styles['no-summary-text']}>{t('fileVersion.noChange')}</span>
157+
}
158+
157159
const summaryTextParts = Object.entries(summaryText).map(([key, value], index) => {
158160
const content =
159161
key === 'file' ? (

0 commit comments

Comments
 (0)