Skip to content

Commit

Permalink
fix(content-manager): compute document status based on locale (#19653)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoward1994 committed Mar 5, 2024
1 parent cbe7d7a commit 6679b9c
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -122,15 +122,17 @@ export default ({ strapi }: { strapi: Strapi }) => ({
async getManyAvailableStatus(uid: Common.UID.SingleType, documents: DocumentVersion[]) {
if (!documents.length) return [];

// The status of all documents should be the same
// The status and locale of all documents should be the same
const status = documents[0].publishedAt !== null ? 'published' : 'draft';
const locale = documents[0]?.locale;
const otherStatus = status === 'published' ? 'draft' : 'published';

return strapi.documents(uid).findMany({
filters: {
documentId: { $in: documents.map((d) => d.documentId).filter(Boolean) },
},
status: otherStatus,
locale,
fields: ['documentId', 'locale', 'updatedAt', 'createdAt', 'publishedAt'],
}) as unknown as DocumentMetadata['availableStatus'];
},
Expand Down

0 comments on commit 6679b9c

Please sign in to comment.