Skip to content

Commit 95231da

Browse files
authored
fix(ui): versions in documentInfo and status component reverse latest true changes (#8417)
1 parent 8acbda0 commit 95231da

File tree

3 files changed

+6
-24
lines changed

3 files changed

+6
-24
lines changed

packages/ui/src/elements/PublishButton/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ export const DefaultPublishButton: React.FC<{ label?: string }> = ({ label: labe
4343
const { code } = useLocale()
4444
const label = labelProp || t('version:publishChanges')
4545

46-
const hasNewerVersions =
47-
unpublishedVersions?.totalDocs > 0 && unpublishedVersions?.docs[0]?.version?._status === 'draft'
46+
const hasNewerVersions = unpublishedVersions?.totalDocs > 0
4847
const canPublish = hasPublishPermission && (modified || hasNewerVersions || !publishedDoc)
4948
const operation = useOperation()
5049

packages/ui/src/elements/Status/index.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,14 @@ export const Status: React.FC = () => {
4141

4242
let statusToRender: 'changed' | 'draft' | 'published'
4343

44-
const isChangedFromPublished = unpublishedVersions?.docs?.[0]?.version?._status === 'draft'
45-
46-
if (unpublishedVersions?.docs?.length > 0 && isChangedFromPublished && publishedDoc) {
44+
if (unpublishedVersions?.docs?.length > 0 && publishedDoc) {
4745
statusToRender = 'changed'
4846
} else if (!publishedDoc) {
4947
statusToRender = 'draft'
50-
} else if (publishedDoc && unpublishedVersions?.docs?.length <= 2) {
48+
} else if (publishedDoc && unpublishedVersions?.docs?.length <= 0) {
5149
statusToRender = 'published'
5250
}
5351

54-
const lastVersion = unpublishedVersions?.docs?.[0]
55-
56-
if (lastVersion && lastVersion.publishedLocale) {
57-
statusToRender = locale === lastVersion.publishedLocale ? 'published' : 'draft'
58-
}
59-
6052
const performAction = useCallback(
6153
async (action: 'revert' | 'unpublish') => {
6254
let url

packages/ui/src/providers/DocumentInfo/index.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -340,18 +340,9 @@ const DocumentInfo: React.FC<
340340
and: [
341341
...versionParams.where.and,
342342
{
343-
or: [
344-
{
345-
updatedAt: {
346-
greater_than: publishedJSON.updatedAt,
347-
},
348-
},
349-
{
350-
latest: {
351-
equals: true,
352-
},
353-
},
354-
],
343+
updatedAt: {
344+
greater_than: publishedJSON.updatedAt,
345+
},
355346
},
356347
],
357348
},

0 commit comments

Comments
 (0)