-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Allow each domains to have its own routes to avoid duplicate route registration #12462
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make it so this is only used on panels with > 1 domain, not > 0 domains
@danharrin Changed it. Please have look. |
I have a feeling you didnt test that, the routes file still needs updating as its adding the extra param for 1 domain. Please manually test this with one domain or write a test for our suite. |
Ya didn't test after changing to How do I write test for routes? Is there a sample reference in the repo? |
The only test we really need is to hit the dashboard and check it renders, right? Set up a new panel provider with domain configuration. Basically to make sure the routing doesnt error out |
Maybe have one panel provider for single domain, one for multi domains |
Bellow are the tests performed.
Below are the output of Tested the fix with no domain
With Single Domain `% php artisan route:list GET|HEAD / ................................................................................................................................................................................................................................................................................................................................................................... With multiple domains `% php artisan route:list GET|HEAD / ................................................................................................................................................................................................................................................................................................................................................................... |
@danharrin Please check the pest tests. if it looks good. My first pest test. Manually i have verified that the app is working for NoDomain, SingleDomain and MultiDomain. Only missing part in unit tests is how HasRoute handles the route resolution in QueueWorker and ArtisanCommand as triggers. (like calling routes for putting links in emails or notificaitons). For now, if the request doesnt have host, it fall back to first domain (assuming that to be the primary domain, hope app_url might fix)
|
If i run the tests in isolation all 3 new tests passes. But if i run alll tests with |
Fixed the unit tests by modifying HasRoutes to decide based on app()->runningInConsole(). Also, I have set the current Panel to admin for AuthTests (to avoid picking a random Panel, in my case, LoginTest picked multi-domain panel though it is not intended) |
Refactored to only use the first domain while testing, since it could be dangerous to assume the current domain in jobs etc, which now needs to be manually specified |
@danharrin Instead of statically setting, shall we use primaryDomain as a field in each Panel itself with Closure? |
If you want to make an additional PR, sure, but I don't mind the existing solution |
Description
if we register the Panel with multiple domains,
php artisan optimize
fails withUnable to prepare route [login] for serialization. Another route has already been assigned name [filament.dashboard.auth.login].
It is because panel logic is registrying routes with the same name for each domain. This PR tries to fix that.
Closes: #11837
Visual changes
Nil
Functional changes
composer cs
command.