Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: add separator and sorting for unpublished entries #7624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ascender1729 wants to merge 3 commits into decaporg:main
base: main
Choose a base branch
Loading
from ascender1729:7542-sort-unpublished-entries

Conversation

Copy link

@ascender1729 ascender1729 commented Oct 7, 2025
edited
Loading

Summary

Fixes #7542

This PR implements proper sorting and visual separation for unpublished entries in collections when editorial workflow is enabled.

Changes

  • Added a visual separator between published and unpublished entries with "Unpublished Entries" heading
  • Implemented sorting for unpublished entries using the same sorting criteria as published entries
  • Added translation key for internationalization support
  • Passed sortFields through the component chain for proper sorting functionality
  • Refactored EntryListing to use React.Fragment for better code readability
  • Added .claude/settings.local.json to .gitignore

Technical Implementation

  • Modified EntryListing component to render published and unpublished entries separately using React.Fragment
  • Created sortEntries() method that applies the collection's sort configuration to unpublished entries
  • Added styled components (SectionSeparator and SectionHeading) for visual separation
  • Enhanced component props to include sortFields throughout the chain

Before

Unpublished entries were appended to the bottom of the list without sorting or visual separation, making the UI unpredictable.

After

  • Unpublished entries are now sorted according to the collection's sort settings
  • Clear visual separator with "Unpublished Entries" heading
  • Consistent user experience with predictable ordering

Test Plan

  1. Enable editorial workflow in CMS configuration
  2. Create draft entries in a collection with sorting enabled
  3. Verify unpublished entries appear below published entries with separator
  4. Verify unpublished entries follow the same sort order as published entries

Testing Completed

  • All existing tests pass
  • Updated snapshots for new component props
  • Linting and formatting checks pass

Review Feedback Addressed

  • Refactored array spread to use React.Fragment for improved readability (per Copilot suggestion)
  • Added .claude/settings.local.json to .gitignore (per @martinjagodic feedback)

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements proper sorting and visual separation for unpublished entries in collections when editorial workflow is enabled, addressing issue #7542.

  • Adds visual separation between published and unpublished entries with a dedicated "Unpublished Entries" section heading
  • Implements consistent sorting for unpublished entries using the same criteria as published entries
  • Passes sortFields through the component chain to enable proper sorting functionality

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/decap-cms-locales/src/en/index.js Adds translation key for "Unpublished Entries" header
packages/decap-cms-core/src/components/Collection/Entries/EntryListing.js Main implementation with sorting logic and visual separator components
packages/decap-cms-core/src/components/Collection/Entries/EntriesCollection.js Passes sortFields prop from state to child components
packages/decap-cms-core/src/components/Collection/Entries/Entries.js Forwards sortFields prop to EntryListing component
packages/decap-cms-core/src/components/Collection/Entries/tests/snapshots/EntriesCollection.spec.js.snap Updates test snapshots for new sortfields prop
.claude/settings.local.json Adds Claude AI configuration file

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 176 to 182
return [
...publishedCards.toArray(),
<SectionSeparator key="separator">
<SectionHeading>{t('collection.entries.unpublishedHeader')}</SectionHeading>
</SectionSeparator>,
...unpublishedCards.toArray(),
];
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Mixing array spread operations with JSX elements creates a complex return structure. Consider using React.Fragment or a wrapper component for better readability and maintainability.

Suggested change
return [
...publishedCards.toArray(),
<SectionSeparator key="separator">
<SectionHeading>{t('collection.entries.unpublishedHeader')}</SectionHeading>
</SectionSeparator>,
...unpublishedCards.toArray(),
];
return (
<React.Fragment>
{publishedCards.toArray()}
<SectionSeparator key="separator">
<SectionHeading>{t('collection.entries.unpublishedHeader')}</SectionHeading>
</SectionSeparator>
{unpublishedCards.toArray()}
</React.Fragment>
);

Copilot uses AI. Check for mistakes.

Copy link
Member

@martinjagodic martinjagodic Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense

Comment on lines 176 to 182
return [
...publishedCards.toArray(),
<SectionSeparator key="separator">
<SectionHeading>{t('collection.entries.unpublishedHeader')}</SectionHeading>
</SectionSeparator>,
...unpublishedCards.toArray(),
];
Copy link
Member

@martinjagodic martinjagodic Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense

@ascender1729 ascender1729 force-pushed the 7542-sort-unpublished-entries branch from 4dee1bd to d00ae9b Compare October 8, 2025 13:23
Implements proper sorting and visual separation for unpublished entries
in collections when editorial workflow is enabled.
Changes:
- Add visual separator with "Unpublished Entries" heading
- Implement sorting for unpublished entries using collection sort config
- Extract unpublished entries logic into separate method
- Add translation key for internationalization support
- Pass sortFields through component chain
Technical implementation:
- Modify EntryListing to render published/unpublished separately
- Create sortEntries() method for applying sort configuration
- Add styled components for visual separation
- Enhance component props to include sortFields
Fixes decaporg#7542 
- Add .claude/settings.local.json to .gitignore
- Refactor EntryListing to use React.Fragment instead of array spread for better readability
@ascender1729 ascender1729 force-pushed the 7542-sort-unpublished-entries branch from d00ae9b to 7edb37f Compare October 8, 2025 13:32
Copy link
Member

@martinjagodic martinjagodic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this to a test repo and after I publish an entry, I get this error on the collection view:

TypeError: r.toArray is not a function at eS.sortEntries (/decap-cms.js:33:76838) at eS.getUnpublishedEntriesList (/decap-cms.js:33:77329) at eS.renderCardsForSingleCollection (/decap-cms.js:33:77684) at eS.render (/decap-cms.js:33:78581) at js (/decap-cms.js:5:725468) at Xs (/decap-cms.js:5:731984) at Xu (/decap-cms.js:5:769131) at Ku (/decap-cms.js:5:769060) at Gu (/decap-cms.js:5:768902) at ju (/decap-cms.js:5:765711)

Do you have a test repo where you tested this? It'a bit cumbersome to test anything with EW...

currentEntries: '%{smart_count} entry |||| %{smart_count} entries',
},
collection: {
sidebar: {
Copy link
Member

@martinjagodic martinjagodic Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have collection object above in the file, please don't duplicate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@martinjagodic martinjagodic martinjagodic left review comments

Copilot code review Copilot Copilot left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Unpublished entries listed at the end of the collection with no sorting

AltStyle によって変換されたページ (->オリジナル) /