Skip to content

Conversation

aannoo
Copy link

@aannoo aannoo commented Apr 8, 2025

Summary

This PR adds a collection size limit feature to Decap CMS, allowing administrators to restrict the number of entries that can be created in a folder collection. This is particularly useful for managing content growth and preventing accidental overpopulation of collections.

The implementation:

  • Adds an optional limit field to the collection configuration schema
  • Introduces a new selectCanCreateNewEntry selector to check if new entries can be created
  • Updates the Collection component to respect collection limits
  • Includes comprehensive tests for the new functionality

Test plan

The changes have been thoroughly tested:

  1. Unit Tests:
npm run test

All tests pass, including:

  • Collection component tests
  • Selector tests
  • Type checking
  • Linting
  1. Manual Testing:
  • Created a collection with a limit of 5 entries
  • Verified that the "New Entry" button is disabled after reaching the limit
  • Confirmed that non-folder collections are unaffected
  • Tested edge cases (undefined limit, null limit)

Checklist

  • I have read the contribution guidelines.
  • Code is properly formatted and linted
  • Tests have been added/updated
  • Documentation is updated
  • Changes are backward compatible

🦊 (A fox, seemingly modest, but is actually representing the joy of open source content management for our Git workflow!)

@aannoo aannoo requested a review from a team as a code owner April 8, 2025 18:06
@PrashantGyawali
Copy link

Any updates on this? Needed exactly this feature 😅

Copy link
Member

@demshy demshy left a comment

Choose a reason for hiding this comment

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

I tested this and it works (also on nested collections). I think we should at least note in the docs the possibilities to overcome this limit:

  • if user manually enters the link
  • if entries are added via EW

I guess we should decide at this point how restrictive we want this feature to be

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants