Tenant-independent pages #13431
Replies: 2 comments 1 reply
-
Why not make it easier to redirect between panels? The |
Beta Was this translation helpful? Give feedback.
-
For anyone interested in how to achieve this right now in one panel without path/auth issues, I did find a much simpler working approach to make things work on the same panel by overriding the view and using the tenant registration class to register our tenant-independent routes:
<?php
namespace App\Filament\Pages;
use Filament\Pages\Page;
use Filament\Panel;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Route;
class NoTenant extends Page
{
...
public static function getRelativeRouteName(): string
{
return 'registration';
}
public static function registerRoutes(Panel $panel): void
{
static::routes($panel);
}
public static function getUrl(array $parameters = [], bool $isAbsolute = true, ?string $panel = null, ?Model $tenant = null): string
{
return route(static::getRouteName($panel), $isAbsolute);
}
} This is just a simple example for one page as I simply needed a page to tell people to contact their system admin instead of showing a 404. But you can abuse the Route::name('pages.')->group(function () use ($panel){
Route::get('profile', MyProfilePage::class);
});
|
Beta Was this translation helpful? Give feedback.
-
One feature that has been requested a few times and that I struggle with not having are tenant-independent pages on panels that use tenancy. I need this feature either way but wanted to open a discussion about it first to define the specs in a way that benefit other too.
My reasoning why this is needed has already been described in a previous discussion that has been closed by the creator without finding a valid answer: #11705
It also contains an implementation concept that I have successfully tested. Perhaps the problem statement wasn't clearly articulated by me, though. I was hoping it will get some more traction if I open a fresh discussion.
Background: When a user is not part of any tenant, they get shown the tenant registration page. While that might be perfect for some, there are use cases in which a user is not allowed to create a tenant. In that case, they are simply stuck in a 404 after logging in. Ideally, they should see something explaining them to contact their system admin or whatever. They should also have access to their profile for example as that does not depend on a tenant. There might be other pages and resources that don't depend on a tenant either. Perhaps they need to submit a ticket. There should be a way of marking a page/resource as tenant-dependent (default), tenant-independent or visible in both states.
Proposed workarounds: A second panel is not an option. Routes are separated, making it not only messy but impossible to seamlessly integrate. It would have two separate logins or, if one is disabled, auth redirects for one panel point to the wrong route.
Current solution: As it needs changes to the routes and the route group blocks the entire namespace, there isn't an easy way to extend Filament to make this work. A fork is currently the only solution.
Suggested solution:
We could have two values for pages and resources
$showOnTenantDependentRoute
and$showOnTenantIndependentRoute
as a boolean or closure and then add some logic to the routes to register them where they are needed. We then add some additional logic in the sidebar to not render the tenant menu if on a tenant-independent route. This worked fine when I tried. I'm looking forward for ideas to improve this.@zepfietje @danharrin would you consider merging this feature?
Beta Was this translation helpful? Give feedback.
All reactions