feat: add collection size limit feature
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
limitfield to the collection configuration schema - Introduces a new
selectCanCreateNewEntryselector 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:
- Unit Tests:
npm run test
All tests pass, including:
- Collection component tests
- Selector tests
- Type checking
- Linting
- 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
- [x] I have read the contribution guidelines.
- [x] Code is properly formatted and linted
- [x] Tests have been added/updated
- [x] Documentation is updated
- [x] Changes are backward compatible
🦊 (A fox, seemingly modest, but is actually representing the joy of open source content management for our Git workflow!)
Any updates on this? Needed exactly this feature 😅
@aannoo it's been a while. Are you still interested in merging this PR? What do you think about the possible overrides that @demshy mentioned?
I think we should restrict those, or at least provide a warning in these instances.