nova-breadcrumbs
nova-breadcrumbs copied to clipboard
Breadcrumbs that respect policies
I'm not sure if this is a silly idea or if its even possible but can the plugin respect policies?
For example, in the scenario where a user is not allowed to view a model:
/**
* Determine whether the user can view the model.
*
* @param \App\Models\User $user
* @param \App\Models\User $model
* @return mixed
*/
public function view(User $user, User $model)
{
return false;
}
When they edit the record the breadcrumbs still include a link to the view page
e.g:
http://app.test/dashboard/resources/users/16
When clicked, the policy kicks in as it should and results in a 403 but this seems misleading from a UI perspective. Maybe in this scenario that section of the breadcrumb should remain as text (not hyperlinked)?
Thanks for your time.
Its something I've considered, and technically is possible. I don't have the time or patience to look at it at the moment, but happy to accept a PR to do it. In theory, it should just be a case of adjusting the breadcrumbs api controller to return null for the path.
Yours is a bit of an odd scenario in that view isn't available, but edit is, so I would suggest, seen as the links always take you to view, we may want to look and direct the user to the edit page if the view policy isn't available.