awcodes / filament-quick-create

Plugin for Filament Panels that adds a dropdown menu to the header to quickly create new items.
MIT License
168 stars 26 forks source link

Native Filament v3 profile page doesn't work with Multi-Tenancy + this plugin #32

Closed miguilimzero closed 1 year ago

miguilimzero commented 1 year ago

Filament Version

v3

Plugin Version

v3.1.0

PHP Version

PHP 8.2.8

Problem description

The profile page doesn't render with this plugin installed, as the plugin is trying to render the quick create button without the tenant parameter available.

Expected behavior

The page works correctly & renders.

Steps to reproduce

Reproduction repository

No response

Relevant log output

image

miguilimzero commented 1 year ago

This issue also applies to the native v3 email confirmation page: /email-verification/prompt.

awcodes commented 1 year ago

Sorry, I'm not following, what do the auth flows have to do with this plugin. The auth flows aren't resources and there for aren't register as resources for the plugin.

miguilimzero commented 1 year ago

@awcodes Not the "auth follows", but the authentication pages when the user is authenticated. It sounds confusing, but when the user is logged in, they can access two special auth pages (from what I know): the email verification page and the profile page.

The plugin tries to register the quick button on these pages.

When multi-tenancy is enabled, the plugin must know the tenant id to register the resources in the quick button. The tenant id is always in the URL path ({tenant}), where it is obtained to create the options on the button, except these two special pages.

Now I will contextualize my case. My application is multi-tenant, and it's at the app prefix. When I access the dashboard homepage or any other page, the format will always be: /app/{tenant}/.... The plugin gets the {tenant} parameter to generate the create button for MyResource.

However, when I access the profile page, even with the multi-tenancy enabled, the path will be /app/profile. The plugin tries to register the button on this page and tries to generate the create button for MyResource, but since the {tenant} parameter is missing, it generates the exception in the screenshot.

miguilimzero commented 1 year ago

This is what I understood from the error, but I don't know where the plugin gets the tenant id. What I know is that it can't obtain this value in the profile or confirm email page.

awcodes commented 1 year ago

The tenant is not relevant in this use case. The plugin provides a way to create new item for a resource. So the question is, why are user profile pages getting treated as a resource. I don't see how a page, which is 1:1 for a logged in user is ever a resource.

miguilimzero commented 1 year ago

The profile page is not treated as a resource, the profile page does not have access to the tenant id that the plugin needs to generate the list for my resources.

miguilimzero commented 1 year ago

And the tenant is relevant because to generate the create resource page URL, the plugin must know the tenant id. Example: /app/1/my-resource/create. This URL is inserted in the quick button menu, and this tenant id is not available on the profile page, so the plugin cannot generate that URL.

awcodes commented 1 year ago

Help me to understand why profile pages are a resource. Not saying your wrong, just failing to see how a page is part of a resource.

awcodes commented 1 year ago

Like, do you have a db table of user profiles that that could be displayed in a table?

miguilimzero commented 1 year ago

The profile page is not a resource, see this example:

miguilimzero commented 1 year ago

I don't know if the quick button is shown on the profile page (as it is currently crashing), but it is at least being mounted for it.

awcodes commented 1 year ago

Right but the plugin is a way to create new records for a model. Authentication pages don't belong to a model or a db record. So what are you expecting the plugin to do?

miguilimzero commented 1 year ago

No, you still didn't get it. I'm expecting that the plugin does not try to mount the quick button for authentication pages.

miguilimzero commented 1 year ago

See this example repository: https://github.com/miguilimzero/filament-quick-button-bug-example

The user resource listing page is not working but is irrelevant here.

awcodes commented 1 year ago

Why do your auth page have a topbar? Authentication pages should be extending the simple page. Which doesn't have a topbar. In which case there wouldn't be a render hook to even display the the lW component.

awcodes commented 1 year ago

Not trying to be difficult. What your doing just isn't adding up to me.

miguilimzero commented 1 year ago

There is no topbar, that's what I tried to say. It shouldn't be any quick button on the authentication page, but for some reason, the plugin is trying to mount it in the profile & confirm email page.

awcodes commented 1 year ago

It is rendered with a hook so the only way it would be present is if your extending the wrong page class in your auth views.

miguilimzero commented 1 year ago

Please see the repository example. I'm not doing any kind of page modification. I just created a sample project, added the multi-tenant, and added the plugin. Nothing else. The profile page doesn't work.

miguilimzero commented 1 year ago

It is rendered with a hook so the only way it would be present is if your extending the wrong page class in your auth views.

I understand this part, but for some reason, the DEFAULT profile page is still calling the panels::user-menu.before hook. And this doesn't work with multi-tenant + the plugin.

awcodes commented 1 year ago

I'm not seeing any "Teams" set up for your app in the repo you provided. You have defined the User as the 'Tenant' and that's not right, Users have to belong to a Tenant. They can not be a Tenant themselves.

If you can set all that up and try again and are still seeing issues then feel free to reopen the issue and provide seeders for the db in your repo, i'll be happy to investigate further.