fix(ui): versions in documentInfo and status component reverse latest true changes (#8417)

This commit is contained in:
Paul
2024-09-25 13:36:58 -06:00
committed by GitHub
parent 8acbda078e
commit 95231daf14
3 changed files with 6 additions and 24 deletions

View File

@@ -43,8 +43,7 @@ export const DefaultPublishButton: React.FC<{ label?: string }> = ({ label: labe
const { code } = useLocale()
const label = labelProp || t('version:publishChanges')
const hasNewerVersions =
unpublishedVersions?.totalDocs > 0 && unpublishedVersions?.docs[0]?.version?._status === 'draft'
const hasNewerVersions = unpublishedVersions?.totalDocs > 0
const canPublish = hasPublishPermission && (modified || hasNewerVersions || !publishedDoc)
const operation = useOperation()

View File

@@ -41,22 +41,14 @@ export const Status: React.FC = () => {
let statusToRender: 'changed' | 'draft' | 'published'
const isChangedFromPublished = unpublishedVersions?.docs?.[0]?.version?._status === 'draft'
if (unpublishedVersions?.docs?.length > 0 && isChangedFromPublished && publishedDoc) {
if (unpublishedVersions?.docs?.length > 0 && publishedDoc) {
statusToRender = 'changed'
} else if (!publishedDoc) {
statusToRender = 'draft'
} else if (publishedDoc && unpublishedVersions?.docs?.length <= 2) {
} else if (publishedDoc && unpublishedVersions?.docs?.length <= 0) {
statusToRender = 'published'
}
const lastVersion = unpublishedVersions?.docs?.[0]
if (lastVersion && lastVersion.publishedLocale) {
statusToRender = locale === lastVersion.publishedLocale ? 'published' : 'draft'
}
const performAction = useCallback(
async (action: 'revert' | 'unpublish') => {
let url

View File

@@ -339,20 +339,11 @@ const DocumentInfo: React.FC<
...versionParams.where,
and: [
...versionParams.where.and,
{
or: [
{
updatedAt: {
greater_than: publishedJSON.updatedAt,
},
},
{
latest: {
equals: true,
},
},
],
},
],
},
}