fix(ui): versions in documentInfo and status component reverse latest true changes (#8417)
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -339,20 +339,11 @@ const DocumentInfo: React.FC<
|
||||
...versionParams.where,
|
||||
and: [
|
||||
...versionParams.where.and,
|
||||
{
|
||||
or: [
|
||||
{
|
||||
updatedAt: {
|
||||
greater_than: publishedJSON.updatedAt,
|
||||
},
|
||||
},
|
||||
{
|
||||
latest: {
|
||||
equals: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user