Handle global filter in routes#661
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements global filter handling in routes by adding a filterKey parameter to all Sharp routes. The filter key is used to maintain global filter state through URL parameters instead of session storage, enabling better support for multi-tenancy and URL-based filter state management.
Key Changes:
- Route restructuring: All Sharp routes now include a
filterKeyparameter (e.g.,/sharp/root/s-list/personinstead of/sharp/s-list/person) - Middleware addition: New
HandleGlobalFiltersmiddleware extracts filter values from URL and sets URL defaults - Filter state management: Global filters now store state in-memory per request rather than in session
- Test infrastructure: Unit tests now require
URL::defaults()setup to handle the new route parameter
Reviewed changes
Copilot reviewed 62 out of 64 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/routes/web.php | Added filterKey parameter to all web routes and redirect routes for backward compatibility |
| src/routes/api.php | Added filterKey parameter to API routes for embedded entity lists and dashboards |
| src/Http/Middleware/HandleGlobalFilters.php | New middleware that parses filterKey from URL and sets current filter values |
| src/Http/Context/SharpContext.php | Added globalFilterUrlSegmentValue() method to build filterKey URL segment |
| src/Http/Context/SharpBreadcrumb.php | Updated to include filterKey in breadcrumb URLs and skip it when parsing segments |
| src/Filters/GlobalRequiredFilter.php | Changed from session-based to in-memory filter value storage |
| src/Filters/GlobalFilters/GlobalFilters.php | Added defaultKey and valuesUrlSeparator static properties |
| src/Http/Controllers/*.php | Updated all controller methods to accept filterKey parameter |
| src/Data/Show/ShowConfigData.php | Added formEditUrl property to show config |
| src/Config/SharpConfigBuilder.php | Added HandleGlobalFilters middleware to common middleware stack |
| tests/Pest.php | Added URL::defaults setup for unit tests |
| tests/Unit/Utils/FakesBreadcrumb.php | Updated to skip filterKey when parsing URL segments |
| resources/js/utils/url.ts | Removed getAppendableParentUri() function (no longer needed) |
| resources/js/show/Show.ts | Removed formUrl getter (now provided by backend) |
| All test files | Updated test URLs to include /root/ filterKey segment |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
# Conflicts: # src/Filters/SelectFilter.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.