tfwright / live_admin

Low-config admin UI for Phoenix apps, built on LiveView
MIT License
248 stars 22 forks source link

"New" button is still rendered with create_with: nil or create_with: false #74

Closed TrevorHinesley closed 9 months ago

TrevorHinesley commented 9 months ago

Describe the bug Using v0.11.0, disabling certain verbs no longer works. For instance, use LiveAdmin.Resource, create_with: false or use LiveAdmin.Resource, create_with: nil does not remove the "New" button from the container component.

After some snooping, I wonder if it's because this line changed recently (appearing to have fallbacks that are overriding a falsey value, which is the method that the container relies upon for conditional rendering).

The example app shows create_with: nil being used though, and container.ex compares explicitly to false here, so that might have changed recently too.

To Reproduce Simply insert use LiveAdmin.Resource, create_with: false or use LiveAdmin.Resource, create_with: nil, and "New" will still be clickable.

In iex, this is what's returned for either value above:

iex(1)> MyResource.__live_admin_config__(:create_with)
nil

Since container.ex is checking for false, that will always be true.

Expected behavior I expect "New" to be hidden when create_with: false or create_with: nil is used.

Environment:

tfwright commented 9 months ago

Thanks for the report!

Reproduced and will push a fix shortly

tfwright commented 9 months ago

Fixed in https://github.com/tfwright/live_admin/commit/7660dc779dab546cfa79c109bf1b38b8452aa787

Note that only a value of false will disable, as nil will be interpreted as "missing/default"

TrevorHinesley commented 9 months ago

Thanks a bunch!